-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Use RelocModel::Pic for UEFI targets #101413
Merged
bors
merged 1 commit into
rust-lang:master
from
nicholasbishop:bishop-remove-uefi-static-reloc
Sep 10, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 assert should not be removed in general, you can add an exception for UEFI with an explanation instead.
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.
done
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.
Should uefi set position_independent_executables and static_position_independent_executables?
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.
Hard to tell by reading the in-code docs what these exactly control. But I think codegen_ssa is the only user and it simply causes PIC output requests to be silently converted to NoPIC output requests. In that case, I think UEFI should set both since PIC is technically supported, though not required nor used by anyone I know.
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 think this assertion is misleading. UEFI does not support dynamic linking, nor are PIC-executables really necessary. However, it still requires a PIC'ish-reloc-model to allow the custom UEFI loaders to relocate the images during load.
I already mentioned this in #100537, it is not clear to me what effect
RelocModel::Static
has. The LLVM docs are basically non-existant. If it causes.reloc
to be stripped from PE32 binaries, then it is not applicable to UEFI.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.
Well, yeah, sure, but my question was rather what exactly it controls? Does it make rustc refuse compilation of non-pic? does it enforce static-pic regardless of what the caller chose? Does it mean pic is mandatory, or just supported?
Maybe there is no clear definition like this, and it just controls the one knob we currently have in codegen_ssa. That would be fine with me. In that case, UEFI should probably set this to
true
.I see. This likely means on PE32
.reloc
is stripped and relocation is not supported? In that case, I think the assertion is wrong and needs to go. A relocatable binary should not imply dynamic-linking or position-independen-code. Since reloc and PIC are different things on UEFI (and also on Windows).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.
It controls if pic compilation is supported or not. It doesn't make it mandatory. In the linker code for the msvc linker it doesn't distinguish between pic and non-pic executables.
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 tested adding this into
uefi_msvc_base
:and it doesn't seem to cause any problem, at least in the simple test I did. Do you want me to add that to this PR?
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.
Friendly ping -- should I add the above lines to this PR? Or should we stick to the existing changes?
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.
Not sure.