Skip to content

[BUG] Compile fail on aarch64 musl when setting -Zfmt-debug=none #947

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

Closed
qinghon opened this issue Jun 10, 2025 · 2 comments · Fixed by #951
Closed

[BUG] Compile fail on aarch64 musl when setting -Zfmt-debug=none #947

qinghon opened this issue Jun 10, 2025 · 2 comments · Fixed by #951

Comments

@qinghon
Copy link
Contributor

qinghon commented Jun 10, 2025

env:
arch: aarch64
os: alpine 3.20
version: 0.1.160

code:

use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering;

static data: AtomicU32 = AtomicU32::new(1);

#[must_use]
fn read_data() -> u32 {
	data.load(Ordering::Relaxed)
}
fn write_data() -> u32 {
	data.fetch_add(1, Ordering::Relaxed)
}

fn main() {
    println!("Hello, world! {}", read_data());
}

build flag:

RUSTFLAGS="-Zfmt-debug=none " cargo +nightly build -Z build-std=std,panic_abort    -Z unstable-options 

build error log:

note: while trying to match meta-variable `$ordering:ident`
   --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/compiler_builtins-0.1.160/src/aarch64_linux.rs:260:6
    |
260 |     ($ordering:ident, $bytes:tt, $name:ident) => {
    |      ^^^^^^^^^^^^^^^
    = note: this error originates in the macro `foreach_ldset` (in Nightly builds, run with -Z macro-backtrace for more info)

error: no rules expected `,`
   --> /tmp/test_atomic/target/debug/build/compiler_builtins-f849036744b13993/out/outlined_atomics.rs:89:10
    |
89  | $macro!( , 8, __aarch64_ldset8_acq_rel );
    |          ^ no rules expected this token in macro call
    |
   ::: /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/compiler_builtins-0.1.160/src/aarch64_linux.rs:259:1
    |
259 | macro_rules! or {
    | --------------- when calling this macro
...
273 | foreach_ldset!(or);
    | ------------------ in this macro invocation
    |
note: while trying to match meta-variable `$ordering:ident`
   --> /root/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/compiler_builtins-0.1.160/src/aarch64_linux.rs:260:6
    |
260 |     ($ordering:ident, $bytes:tt, $name:ident) => {
    |      ^^^^^^^^^^^^^^^
    = note: this error originates in the macro `foreach_ldset` (in Nightly builds, run with -Z macro-backtrace for more info)

After some troubleshooting, it turns out that compiler_builtins depends on the Debug trait in the build.rs

writeln!(macro_, "$macro!( {ordering:?}, {size}, {name} );").unwrap();
}
}
let name = format!("__aarch64_cas16_{sym_ordering}");
writeln!(cas16, "$macro!( {ordering:?}, {name} );").unwrap();

@tgross35
Copy link
Contributor

It's really weird that config options gets applied to build scripts - that seems like a bug with build-std.

That being said, we may as well change the function since it's a hack anyway. Would you be open to putting up a PR? This part of the build script can be replaced by a macro in the actual source that uses ${concat(...)} since that now works and can create identifiers.

@qinghon
Copy link
Contributor Author

qinghon commented Jun 10, 2025

I tried to fix and turn on a PR, but not quite sure if it's the ${concat(...)} you hinted at way @tgross35

tgross35 pushed a commit to tgross35/compiler-builtins that referenced this issue Jun 13, 2025
Replace `build.rs` Rust generation with macros, using the unstable
`${concat(...)}`.

Fixes: rust-lang#947
tgross35 pushed a commit to tgross35/rust that referenced this issue Jun 14, 2025
Replace `build.rs` Rust generation with macros, using the unstable
`${concat(...)}`.

Fixes: rust-lang/compiler-builtins#947
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants