Github Implement RFC 2951: Native link modifiers by luqmana · Pull Request #8350...
source link: https://github.com/rust-lang/rust/pull/83507
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
This comment has been hidden.
compiler/rustc_session/src/config.rs
Show resolved
compiler/rustc_metadata/src/native_libs.rs
Show resolved
// Even though we pass `whole-archive` (or similar) to the linker here,
// gc-sections (or similar) may end up stripping away any unreferenced
// symbols. So let's try explicitly disabling that.
cmd.no_gc_sections();
petrochenkov on Mar 27
Contributor
Are you sure that this is necessary and linker doesn't disable --gc-sections
automatically when it sees --whole-archive
? If it's necessary, then that's unfortunate.
Anyway, if it's necessary and --gc-sections
is disabled before link_whole_staticlib
, then it should be re-enabled after it.
Or not, because --gc-sections
is not always enabled by default. (Pehaps --push-state
/--pop-state
can help here, although https://sourceware.org/binutils/docs/ld/Options.html doesn't list --gc-sections
among the saved/restored flags.)
What is worse, /OPT:NOREF,NOICF
on MSVC is global and applies to all libraries, not to this specific one. (But again, maybe it's not even necessary?)
petrochenkov on Mar 27 •
Contributor
From reading LLD sources it looks like --gc-sections
is a global flag affecting all files regardless of order in ld-like linkers as well.
luqmana 17 days ago
Author
Member
Yea, I did some quick testing and it seemed like --whole-archive
by itself isn't enough unfortunately. And like you said, it's a global flag. :/
compiler/rustc_codegen_ssa/src/back/linker.rs
Show resolved
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK