-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
De-duplicate and improve definition of core::ffi::c_char #132975
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cuviper (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Failed to set assignee to
|
I think r? @joshtriplett should work. |
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.
Some OSes are no longer conditioned on, for example, os=nto
arch=aarch64
or os=l4re
, arch=x86_64
are missing.
I didn't manually verify everything, but at least l4re
and x86_64
just got flipped from u8
, which it appears to have been manually set to, to i8
.
Can we get a summary of what changed in terms of supported target triples? I would expect disagreements with clang
to be rare, but this patch looks like it accidentally changes obscure targets at a minimum. It might also be clearer what changed if we didn't have the 4-branch if statement for 2 results.
05aff14
to
05f561b
Compare
I'm pretty sure this still changes |
As Apple and Windows targets always use signed char, you could simplify the cfg statement further to |
I'm trying to figure out if that value is intentional or not. It dates back to 2cf0a4a, |
Looks like l4re should be setting this for all architectures, I spotted |
c19462d
to
4d8abde
Compare
r? libs-api |
4d8abde
to
5e82b5e
Compare
I have validated the new c_char definitions against my build of clang that has fixes for MSP430, Xtensa (although printing the builtin defines fails with Unlike #131319 this PR does not have links to all the ABI docs, but it does have a correct definition for l4re (which clang does not support and treats as unknown OS). |
As for L4Re:
({x86_64,aarch64}-l4re-gcc are from https://l4re.org/download/snapshots/toolchain/.) As for Xtensa: However, it appears that Xtensa has multiple ABIs. (Section 1.4 "Calling convention" of Overview of Xtensa ISA https://dl.espressif.com/github_assets/espressif/xtensa-isa-doc/releases/download/latest/Xtensa.pdf) |
5e82b5e
to
4e3c262
Compare
As noted in rust-lang#132975 (comment), the default for userland apps is to follow the architecture defaults, the -funsigned-char flag only applies to kernel builds.
Rebased and fixed the l4re issue.
Thanks for checking this, I've updated the change to remove l4re from the list. I've done this as a separate commit in case this needs to be reverted in the future.
Regarding Xtensa, my Clang change to make it unsigned by default was approved by Xtensa developers and has been merged now: llvm/llvm-project#115967. |
Pinging some target maintainers (checkbox = acked):
If you were pinged here, this PR will change one of your target's definition of |
I don't think that's actually what -unknown- means, FWIW. Looking at the platform support list I see quite a lot of targets that contain the string -unknown- and are not embedded systems. |
I have confirmed with the folks working on the illumos ARM port that char is unsigned there to match the prevailing winds, so this makes sense to us, thanks! |
This is correct for Trusty as far as I know, we expect |
Interesting, it looks like this is probably a bug in the target definition, which means it uses the windows ABI in Clang: This should be "aarch64-unknown-uefi" which Clang understands
|
This is fine for Redox OS. |
As noticed in [1], the LLVM target string for aarch64 UEFI is not correct. Fix it here. Link: rust-lang#132975 (comment) [1]
That is mildly amusing. Opened #134156 to fix it. |
With the libs-api approval I don't think there is any reason to hold off, especially considering it was mentioned during the meeting that this is better to have toward the beginning of a release cycle (we are reasonably early now, next branch is January 3rd for stable on February 20th). @bors r+ Thanks everyone who took a look at this. |
Digging deeper it looks like this is only partially supported in Clang (x86 supports the triple, aarch64 triggers assertions). I do wonder if Clang's output here is wrong and Rust is correct - I imagine UEFI follows the Windows ABIs since it is COFF-based? But I haven't found a spec for the UEFI AArch64 ABI. |
Confirmed: for Thanks for the fix. |
It looks like indeed With that said, I guess it is on us to fix this downstream, and we'll know the impact pretty soon, given the "bors +r" from a couple of hours ago. |
This aligns Hermit to its definitions in |
Hmm, looks like we need to fix then the ESP IDF I also wonder (excuse my ignorance) what this change means with regards to interop with C code compiled with GCC, as it seems GCC always treats |
I think this answer might just be referring to x86, https://gcc.gnu.org/onlinedocs/gcc-4.2.2/gcc/C-Dialect-Options.html says:
And based on testing a few targets at https://godbolt.org/z/vxvY34W8b, at least the ARM and RISC-V targets seem to have CHAR_UNSIGNED defined. AVR GCC actually does not have this defined for the thumb targets so we might need to double check those https://godbolt.org/z/rdroc9fe9 (@Patryk27).
To be clear, we can make followup changes to specific targets as needed, or if the fallout is especially bad in particular areas. |
thumb is thumb mode of 32-bit Arm ( AVR's c_char is signed by default as mentioned in the references in #129945.
Arm's c_char is not affected by whether it is in Arm or Thumb mode. |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#132975 (De-duplicate and improve definition of core::ffi::c_char) - rust-lang#133598 (Change `GetManyMutError` to match T-libs-api decision) - rust-lang#134148 (add comments in check_expr_field) - rust-lang#134163 (coverage: Rearrange the code for embedding per-function coverage metadata) - rust-lang#134165 (wasm(32|64): update alignment string) - rust-lang#134170 (Subtree update of `rust-analyzer`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#132975 - arichardson:ffi-c-char, r=tgross35 De-duplicate and improve definition of core::ffi::c_char Instead of having a list of unsigned char targets for each OS, follow the logic Clang uses and instead set the value based on architecture with a special case for Darwin and Windows operating systems. This makes it easier to support new operating systems targeting Arm/AArch64 without having to modify this config statement for each new OS. The new list does not quite match Clang since I noticed a few bugs in the Clang implementation (llvm/llvm-project#115957). Fixes rust-lang#129945 Closes rust-lang#131319
Instead of having a list of unsigned char targets for each OS, follow the logic Clang uses and instead set the value based on architecture with a special case for Darwin and Windows operating systems. This makes it easier to support new operating systems targeting Arm/AArch64 without having to modify this config statement for each new OS. The new list does not quite match Clang since I noticed a few bugs in the Clang implementation (llvm/llvm-project#115957).
Fixes #129945
Closes #131319