-
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
Change Linker for x86_64-fortanix-unknown-sgx target to rust-lld #66957
Conversation
src/rustllvm/PassWrapper.cpp
Outdated
@@ -419,6 +420,10 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine( | |||
Options.MCOptions.PreserveAsmComments = AsmComments; | |||
Options.MCOptions.ABIName = ABIStr; | |||
|
|||
if (LinkerIsLLD) { | |||
Options.RelaxELFRelocations = true; |
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.
Testing the effects of this is difficult, but I've filed fortanix/rust-sgx#202 to track possible future improvements.
4a2475d
to
067ad79
Compare
Could relaxation of elf relocations be a separate parameter in the target configuration? There are existing targets using LLD and this may run a risk of breaking them if they weren't expecting this to be turned on. |
From what I understand, the only reason to not use the relaxations is if you're using a linker that doesn't understand them. LLD does, so there is no reason to turn them off then. Code generation might be improved if the option is turned on. I might be wrong since the feature isn't documented that well. |
If you'd like to pursue this change as-is, then I'd have a similar comment I left on another PR. I do not have the confidence to r+ this change as-is, so you'll need to find a different reviewer. I unfortunately don't know who that different reviewer would be, but you'd likely want to start with the Compiler team. |
cc @rust-lang/compiler-contributors for possible other reviewer |
For SGX, the relocation using the relocation table is done by the code in rust/src/libstd/sys/sgx/abi/reloc.rs and this code should not require relocation. Setting RelaxELFRelocations flag if allows this to happen, hence adding a Target Option for it.
067ad79
to
54b2060
Compare
LGTM |
I have added |
@bors: r+ 👍 |
📌 Commit 54b2060 has been approved by |
…xcrichton Change Linker for x86_64-fortanix-unknown-sgx target to rust-lld Changed linker for `x86_64-fortanix-unknown-sgx` target to `rust-lld` This change needed the RelaxELFRelocations flag to be set for it to work correctly r? @jethrogb
…xcrichton Change Linker for x86_64-fortanix-unknown-sgx target to rust-lld Changed linker for `x86_64-fortanix-unknown-sgx` target to `rust-lld` This change needed the RelaxELFRelocations flag to be set for it to work correctly r? @jethrogb
Rollup of 7 pull requests Successful merges: - #66750 (Update the `wasi` crate for `wasm32-wasi`) - #66878 (Move Sessions into (new) librustc_session) - #66903 (parse_enum_item -> parse_enum_variant) - #66951 (miri: add throw_machine_stop macro) - #66957 (Change Linker for x86_64-fortanix-unknown-sgx target to rust-lld) - #66960 ([const-prop] Fix ICE calculating enum discriminant) - #66973 (Update the minimum external LLVM to 7) Failed merges: r? @ghost
Bootstrap: change logic for choosing linker and rpath This is a follow-up from #66957 and #67023. Apparently there was one more location with a hard-coded list of targets to influence linking. I've filed #67171 to track this madness. r? @alexcrichton
Changed linker for
x86_64-fortanix-unknown-sgx
target torust-lld
This change needed the RelaxELFRelocations flag to be set for it to work correctly
r? @jethrogb