Skip to content
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

Merged
merged 1 commit into from
Dec 3, 2019

Conversation

parthsane
Copy link
Contributor

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

@parthsane
Copy link
Contributor Author

r? @alexcrichton

@@ -419,6 +420,10 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
Options.MCOptions.PreserveAsmComments = AsmComments;
Options.MCOptions.ABIName = ABIStr;

if (LinkerIsLLD) {
Options.RelaxELFRelocations = true;
Copy link
Contributor

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.

@parthsane parthsane changed the title Set RelaxELFRelocations if linker flavor is lld Change Linker for x86_64-fortanix-unknown-sgx target to rust-lld Dec 2, 2019
@alexcrichton
Copy link
Member

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.

@jethrogb
Copy link
Contributor

jethrogb commented Dec 2, 2019

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.

@alexcrichton
Copy link
Member

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.

@alexcrichton alexcrichton reopened this Dec 2, 2019
@Centril
Copy link
Contributor

Centril commented Dec 2, 2019

cc @rust-lang/compiler-contributors for possible other reviewer

src/rustllvm/PassWrapper.cpp Outdated Show resolved Hide resolved
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.
@jethrogb
Copy link
Contributor

jethrogb commented Dec 3, 2019

LGTM

@parthsane
Copy link
Contributor Author

I have added relax_elf_relocation as a Target Option and it is false by default. This should prevent the risk of breaking other targets, just in case.
@alexcrichton

@alexcrichton
Copy link
Member

@bors: r+

👍

@bors
Copy link
Contributor

bors commented Dec 3, 2019

📌 Commit 54b2060 has been approved by alexcrichton

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Dec 3, 2019
Centril added a commit to Centril/rust that referenced this pull request Dec 3, 2019
…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
Centril added a commit to Centril/rust that referenced this pull request Dec 3, 2019
…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
bors added a commit that referenced this pull request Dec 3, 2019
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
@bors bors merged commit 54b2060 into rust-lang:master Dec 3, 2019
bors added a commit that referenced this pull request Dec 12, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants