4

Github Implement RFC 2951: Native link modifiers by luqmana · Pull Request #8350...

 3 years ago
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.
neoserver,ios ssh client

This comment has been hidden.

// 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

edited

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. :/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK