Name mangling in language libraries

Hello,

I have compiled my own version of the compiler with the Rust name mangling through the command RUSTFLAGS=" -Csymbol-mangling-version=v0" ./x.py build. Nevertheless, when I compile a project with the generated compiler (and mangling the names as well), the standard library functions have the old name mangling scheme (e.g., _ZN4core3fmt3num50_$LT$impl$u20$core..fmt..Debug$u20$for$u20$u32$GT$3fmt17h750beae22ecffe4cE). What is the way to use the standard library generated by my own compiler build? I don't know if don't get the right names due to how I build the standard library, or if the language libraries that rust generates (core, std...) have the mangled names but is not used when compiling the project.

My .cargo/config file for the project looks like the next one:

[build]
rustc = "<RUSTC_PATH>/build/x86_64-unknown-linux-gnu/stage1/bin/rustc"
rustflags = ["-Csymbol-mangling-version=v0"]

Thanks, in advance

You can use cargo build -Zbuild-std=std --target x86_64-unknown-linux-gnu on nightly to tell cargo to rebuild the standard library before compiling your program, which will then apply all RUSTFLAGS you pass to the standard library too. Or you can set https://github.com/rust-lang/rust/blob/c2ef35161fc7477b38f2e556be2fd6d85d9f4905/config.example.toml#L693 to true when compiling rustc.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.