-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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 binary_format to rustc target specs #136637
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
@rustbot label -O-apple +A-target-specs |
☔ The latest upstream changes (presumably #136684) made this pull request unmergeable. Please resolve the merge conflicts. |
These commits modify compiler targets. |
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.
Thanks, this is great. It looks good, but I'll take a closer look to ensure that every single target is still correct after you address my feedback below. Then we can merge it.
37b2ebc
to
97b3d72
Compare
There were 2 places that used this adhoc logic for the binary format This one, I have changed to use the binary format field from Target This one requires the rust/compiler/rustc_codegen_ssa/src/back/metadata.rs Lines 255 to 265 in 905b1bf
|
@@ -208,7 +190,7 @@ fn prefix_and_suffix<'tcx>( | |||
let mut begin = String::new(); | |||
let mut end = String::new(); | |||
match asm_binary_format { | |||
AsmBinaryFormat::Elf => { | |||
BinaryFormat::Elf | BinaryFormat::Xcoff => { |
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.
Added Xcoff here with Elf since it wasn't taken into account before and AsmBinaryFormat defaulted to elf
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.
Hm, I'd expect this to be wrong, but not any more wrong than before, and I don't really know anything about XCoff. Let's leave it like this and open a follow-up issue about this and ping the AIX maintainers there.
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 have created an issue about this at #137219
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.
author of this file here: I just checked, and this is definitely wrong and needs something custom. I don't think we have any tests that would hit this target, so I think this PR can just be merged first, and then we fix naked_asm
for AIX later.
I'll have a stab at a fix, and then hopefully the AIX folks can confirm that what I come up with actually works.
also in general: this is a really nice change, thanks!
☔ The latest upstream changes (presumably #137046) made this pull request unmergeable. Please resolve the merge conflicts. |
97b3d72
to
0dbee32
Compare
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.
For the other use you mentioned, I would add a method to BinaryFormat
that returns the object::BinaryFormat
and use that there.
I also ran the following script to compare your results against the previous logic:
#!/usr/bin/env bash
for target in $(rustc +dev3 --print target-list); do
json=$(rustc +dev3 --print target-spec-json --target "$target" -Zunstable-options 2>/dev/null)
fmt=$(echo "$json"| jq '."binary-format"' -r)
is_like_windows=$(echo "$json"| jq '."is-like-windows"')
is_like_osx=$(echo "$json"| jq '."is-like-osx"')
is_like_wasm=$(echo "$json"| jq '."is-like-wasm"')
if [ "$is_like_windows" = "true" ]; then
if [ "$fmt" != "coff" ]; then
echo "ERROR: $fmt $target"
fi
elif [ "$is_like_osx" = "true" ]; then
if [ "$fmt" != "mach-o" ]; then
echo "ERROR: $fmt $target"
fi
elif [ "$is_like_wasm" = "true" ]; then
if [ "$fmt" != "wasm" ]; then
echo "ERROR: $fmt $target"
fi
else
if [ "$fmt" != "null" ]; then
echo "ERROR: $fmt $target"
fi
fi
done
It found two results:
ERROR: xcoff powerpc64-ibm-aix
ERROR: null x86_64-pc-cygwin
XCoff for AIX is good, but ELF for cygwin is wrong. Cygwin is Windows and uses Coff, you need to adjust that as well.
@@ -208,7 +190,7 @@ fn prefix_and_suffix<'tcx>( | |||
let mut begin = String::new(); | |||
let mut end = String::new(); | |||
match asm_binary_format { | |||
AsmBinaryFormat::Elf => { | |||
BinaryFormat::Elf | BinaryFormat::Xcoff => { |
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.
Hm, I'd expect this to be wrong, but not any more wrong than before, and I don't really know anything about XCoff. Let's leave it like this and open a follow-up issue about this and ping the AIX maintainers there.
0dbee32
to
17f2928
Compare
Thanks! |
Rollup of 8 pull requests Successful merges: - rust-lang#136439 (Misc. `rustc_codegen_ssa` cleanups 🧹) - rust-lang#136543 (intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic) - rust-lang#136637 (Add binary_format to rustc target specs) - rust-lang#137099 (Fix rustdoc test directives that were accidentally ignored 🧐) - rust-lang#137297 (Update `compiler-builtins` to 0.1.147) - rust-lang#137451 (FIx `sym` -> `syn` typo in tail-expr-drop-order type opt-out) - rust-lang#137452 (bootstrap: add module docs for core:metadata) - rust-lang#137483 (rename sub_ptr to offset_from_unsigned) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 8 pull requests Successful merges: - rust-lang#136439 (Misc. `rustc_codegen_ssa` cleanups 🧹) - rust-lang#136543 (intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic) - rust-lang#136637 (Add binary_format to rustc target specs) - rust-lang#137099 (Fix rustdoc test directives that were accidentally ignored 🧐) - rust-lang#137297 (Update `compiler-builtins` to 0.1.147) - rust-lang#137451 (FIx `sym` -> `syn` typo in tail-expr-drop-order type opt-out) - rust-lang#137452 (bootstrap: add module docs for core:metadata) - rust-lang#137483 (rename sub_ptr to offset_from_unsigned) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#136637 - Pyr0de:binary-format, r=Noratrieb Add binary_format to rustc target specs Added binary format field to `TargetOptions` Fixes rust-lang#135724 r? `@Noratrieb`
Added binary format field to
TargetOptions
Fixes #135724
r? @Noratrieb