Skip to content

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

Closed
@qinghon

Description

@qinghon

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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions