-
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
Add aarch64-unknown-uefi
target
#85357
Add aarch64-unknown-uefi
target
#85357
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This is basically a copy of |
What is the relation of this PR with #85358? |
Hello @petrochenkov! Yeup its kindof a copy of Why add this target?Well, I am building an operating system called Aero and currently is in the process of adding support for {
"arch": "aarch64",
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
"default-hidden-visibility": true,
"emit-debug-gdb-scripts": false,
"exe-suffix": ".efi",
"executables": true,
"is-like-windows": true,
"linker": "rust-lld",
"linker-flavor": "lld-link",
"llvm-target": "aarch64-pc-windows-msvc",
"os": "uefi",
"panic-strategy": "abort",
"pre-link-args": {
"lld-link": [
"/subsystem:EFI_Application",
"/entry:efi_main",
"/machine:arm64"
]
},
"stack_probes": true,
"target-c-int-width": "32",
"target-endian": "little",
"target-pointer-width": "64"
}
|
@Andy-Python-Programmer I believe we also need to write up the reasons why this new |
+1, I personally don't need to be convinced that this target is useful, but we have a formal policy now which we want to test in practice, so filling in the form from https://doc.rust-lang.org/nightly/rustc/target-tier-policy.html#tier-3-target-policy is required. |
This comment has been minimized.
This comment has been minimized.
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.
With the comments fixed as @petrochenkov mentioned, this looks good to me!
I have been having issues while trying to test the target so I could test it on a real device and qemu. I have linked the toolchain using $ cargo +aarchdev build This results in: error: unable to unlink old fallback exe: Access is denied. (os error 5) Updating rust fixed it once but now its back again :( |
Assuming the host is Windows, the error likely means that rustup is trying to remove an executable that is currently running. |
Sorry for the late reply, I tested building a simple UEFI application and tried to build it and it resulted in a lot of allocation errors that its not supported on COFF targets when building core. 2,3d1
< "abi-return-struct-as-int": true,
< "allows-weak-linkage": false,
5d2
< "code-model": "large",
7c4
< "disable-redzone": true,
---
> "default-hidden-visibility": true,
11,12d7
< "is-builtin": true,
< "is-like-msvc": true,
16,19c11
< "linker-is-gnu": false,
< "lld-flavor": "link",
< "llvm-target": "aarch64-unknown-windows",
< "max-atomic-width": 64,
---
> "llvm-target": "aarch64-pc-windows-msvc",
24c16
< "/NOLOGO",
---
> "/subsystem:EFI_Application",
26,32d17
< "/subsystem:efi_application",
< "/machine:arm64"
< ],
< "msvc": [
< "/NOLOGO",
< "/entry:efi_main",
< "/subsystem:efi_application",
36,40c21,23
< "singlethread": true,
< "split-debuginfo": "packed",
< "stack-probes": {
< "kind": "call"
< },
---
> "stack_probes": true,
> "target-c-int-width": "32",
> "target-endian": "little",
42c25
< }
\ No newline at end of file
---
> } Diff from the file that I provided in the above comment and the one that target tend to generate.
|
@Andy-Python-Programmer If not then I suggest to start explicitly adding options from the custom target to the builtin target until it works, then explicitly add all options from |
Nope. It works perfectly fine... |
After a bit of research on the allocation errors, apparently it’s because I have set the code model to large. If I remove the explicit setter for the code model in the target it apparently compiles successfully. Since the code model only applies to the code and not the data and the code model only applies to functions you call through using Since UEFI (uefi is all relocatable) uses relocatable PEs and AFAIK relocatable code does not care about the code model. After this research 🧐, I think it’s perfectly fine to use the small code model in this case (I guess I was wrong about the need of code model set to large here). CC @dvdhrm and @petrochenkov. I suppose it will be perfectly fine to use the small code model in the x86_64 UEFI target too.
Makes sense now, I believe, should set to use the code model to small instead. |
0c7c27d
to
51d6903
Compare
51d6903
to
5044c66
Compare
This comment has been minimized.
This comment has been minimized.
@Andy-Python-Programmer |
Sure. Just doing some final tests and checks. |
Ping from triage: Thank you! |
* This commit adds the aarch64-unknown-uefi target and also adds it into the supported targets list under the tier-3 target table. * Uses the small code model by default Signed-off-by: Andy-Python-Programmer <andypythonappdeveloper@gmail.com>
5044c66
to
44b81fb
Compare
@rustbot label -S-waiting-on-author +S-waiting-on-review |
@bors r+ rollup |
📌 Commit 44b81fb has been approved by |
☀️ Test successful - checks-actions |
This pull request adds the
aarch64-unknown-uefi
target.