-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add codegen option strip #71825
add codegen option strip #71825
Conversation
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
Looks good to me, but I think according to the comment in the // If you add a new option, please update:
// - src/librustc_interface/tests.rs
// - src/doc/rustc/src/codegen-options/index.md |
@GabrielMajeri Thanks. I added the relevant sections in aforementioned files. I don't know if there are still things overlooked. |
This comment has been minimized.
This comment has been minimized.
d188309
to
942a16e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable, but I think we can do better than noop
for emscripten and MSVC
@@ -898,6 +909,10 @@ impl<'a> Linker for EmLinker<'a> { | |||
}); | |||
} | |||
|
|||
fn strip(&mut self) { | |||
// noop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For emscripten, you should try to use --llvm-opts
to pass -strip-all
to the LLVM toolchain. See the emcc
documentation
You may also need something like -Wl
to make this work, I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know if --llvm-opts
can be specified multiple times. Can we just add two --llvm-opts
and ['--strip-all']
here? Or we should add an field llvmOpts
in Emlinker
?
This PR introduces the option as immediately stable ( |
Upon some closer investigation, I think this should be added in a slightly different form.
|
Effect of the option on different platforms:
I wouldn't care too much about other target flavors right now, it's safe to do nothing if these options are passed. |
GCC doc says that The relocations required by dynamic linker are still there, and I assumed that all other relocations are removed during linking anyway as unnecessary. cc @mati865 |
Would adding a waring about doing nothing for those targets/linkers is better? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Great! |
move strip option to "Z" add more strip options, remove strip-debuginfo-if-disabled merge strip and debuginfo
Thanks! |
📌 Commit a6c2f73 has been approved by |
⌛ Testing commit a6c2f73 with merge 0f73d7656803c0a3f9b88595e0dc9590eac4c573... |
@bors retry yield |
⌛ Testing commit a6c2f73 with merge cb49bb804985ac5e7d2df2250f9980bfd306ac42... |
@bors retry yield |
⌛ Testing commit a6c2f73 with merge 69da478ebbb84dd58aabace4bd3c803392cff8cb... |
@bors retry yield |
☀️ Test successful - checks-actions, checks-azure |
closes #71757
I don't know if the flags added here works for all linkers. I only tested on my Linux pc. I also don't know what is the best for emlinker, PtxLinker, MsvcLinker. The option for WasmLd is copied from https://aransentin.github.io/cwasm/.