Skip to content
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

c_char on AIX should be u8 #122985

Closed
taiki-e opened this issue Mar 24, 2024 · 3 comments · Fixed by #122986
Closed

c_char on AIX should be u8 #122985

taiki-e opened this issue Mar 24, 2024 · 3 comments · Fixed by #122986
Labels
A-ABI Area: Concerning the application binary interface (ABI) C-bug Category: This is a bug. O-aix OS: Big Blue's Advanced Interactive eXecutive.. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@taiki-e
Copy link
Member

taiki-e commented Mar 24, 2024

Currently, core::ffi::c_char on AIX is i8, but AFAIK, the default of this platform is unsigned (u8).

XL C for AIX:

Defaults
-qchars=unsigned

Clang:

$ clang --version
Homebrew clang version 17.0.6

$ clang -E -dM -x c /dev/null -target powerpc64-ibm-aix | grep __CHAR_        
#define __CHAR_BIT__ 8
#define __CHAR_UNSIGNED__ 1

Rust:

$ tail -2 src/lib.rs 

const C: core::ffi::c_char = 0u8;

$ cargo check -Zbuild-std=core --target powerpc64-ibm-aix
error[E0308]: mismatched types
    --> src/lib.rs:3972:30
     |
3972 | const C: core::ffi::c_char = 0u8;
     |                              ^^^ expected `i8`, found `u8`
     |
help: change the type of the numeric literal from `u8` to `i8`
     |
3972 | const C: core::ffi::c_char = 0i8;
     |                               ~~

cc @ecnelises @bzEq (target maintainers)

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (2f090c30d 2024-03-23)
binary: rustc
commit-hash: 2f090c30ddd6b3bbe5c81c087579a5166e7c7278
commit-date: 2024-03-23
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.2
@taiki-e taiki-e added the C-bug Category: This is a bug. label Mar 24, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Mar 24, 2024
taiki-e added a commit to taiki-e/rust that referenced this issue Mar 24, 2024
taiki-e added a commit to taiki-e/libc that referenced this issue Mar 24, 2024
This was referenced Mar 24, 2024
@taiki-e
Copy link
Member Author

taiki-e commented Mar 24, 2024

I opened rust-lang/libc#3631 and #122986 as drafts to fix this, but I want feedback from the target maintainers before undrafting/merging them.

@taiki-e
Copy link
Member Author

taiki-e commented Mar 24, 2024

Ideally, we could detect such a problem in CI by checking the Clang's default. However, AFAIK, most tier3 targets are not checked at all in CI at this time (#109099), so that would need to be fixed first.

@bjorn3 bjorn3 added A-ABI Area: Concerning the application binary interface (ABI) O-aix OS: Big Blue's Advanced Interactive eXecutive.. labels Mar 24, 2024
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 24, 2024
@bzEq
Copy link
Contributor

bzEq commented Mar 25, 2024

Yes, we should follow clang on AIX's behavior.

taiki-e added a commit to taiki-e/libc that referenced this issue Apr 18, 2024
taiki-e added a commit to taiki-e/libc that referenced this issue Apr 18, 2024
JohnTitor pushed a commit to taiki-e/libc that referenced this issue Apr 27, 2024
moodyhunter pushed a commit to moodyhunter/mos-rust-libc that referenced this issue May 16, 2024
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this issue May 25, 2024
@bors bors closed this as completed in 2a1b632 May 26, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 26, 2024
Rollup merge of rust-lang#122986 - taiki-e:aix-c-char, r=Mark-Simulacrum

Fix c_char on AIX

Closes rust-lang#122985
stlankes pushed a commit to hermit-os/libc that referenced this issue May 27, 2024
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ABI Area: Concerning the application binary interface (ABI) C-bug Category: This is a bug. O-aix OS: Big Blue's Advanced Interactive eXecutive.. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@bzEq @bjorn3 @jieyouxu @taiki-e @rustbot and others