-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 LLVM's UEFI targets #132570
Open
madsmtm
wants to merge
1
commit into
rust-lang:master
Choose a base branch
from
madsmtm:llvm-uefi
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5
−60
Open
Use LLVM's UEFI targets #132570
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
Oops, something went wrong.
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.
Running
./x test tests/assembly/targets/targets-pe.rs
shows that the data layout for ouri686-unknown-uefi
, for it to match Clang'si686-unknown-uefi
, should have the following modifications:i64:64
: Decreases the alignment ofi64
to 32 bits.f64:32:64
: Decreases the alignment off64
to 32 bits.a:0:32
: Decreases the alignment of aggregates (structs?) to 32 bits.S32
withS128
: Increases the natural alignment of the stack to 128 bits.I have no idea if this is the desired behaviour?
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.
These I think are not desirable. Edk2 sets
-malign-double
for ia32 in https://github.com/tianocore/edk2/blob/HEAD/BaseTools/Conf/tools_def.template. So while the UEFI spec isn't super clear on what the alignment fordouble
andlong long
should be on ia32, the de facto alignment is 8 bytes.See rhboot/shim#516 for a real-world example where this makes a difference.
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.
can we file a bug against LLVM, then?
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 would prefer if @nicholasbishop did it, you seem more knowledgeable about it - but I can try to do it if you don't have the time?
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 just did a quick sanity check of compiling C code with these triples, and I suspect this isn't fully implemented in clang yet (tested 19.1.0). Getting errors like:
error: backend data layout 'e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128' does not match expected target description 'e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128'
.I think the implementation work in LLVM is ongoing, so not quite ready for us to use yet. @Prabhuk can you confirm that?
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.
Breaking from edk2 is definitely not desirable. From what I understand, even most of the proprietary UEFI implementations use edk2 as the base.
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.
Apologies for the slow response! I am on vacation till mid November. I have a WIP backend patch (llvm/llvm-project#109320) to support X86_64 first. I am debugging a assertion failure I ran into while compiling a downstream EFI example. I will prioritize upstreaming fixing it and sending out a PR as soon as I return. aarch64 will be next. w.r.t to data layout, I need to look at a closer look once I return before commenting.
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.
CC: @frobtech @petrhosek