rustc_codegen_cranelift icon indicating copy to clipboard operation
rustc_codegen_cranelift copied to clipboard

Implement platform specific symbol mangling suppression using \x01

Open bjorn3 opened this issue 2 years ago • 3 comments

Many platforms have some symbol mangling even for "unmangled" C symbols. For example adding a leading _ or trailing @argcount. LLVM supports suppressing this by prefixing the symbol name with \x01. cg_clif will need to implement this too to support building with -Cpanic=unwind on Windows: https://github.com/rust-lang/rust/blob/2d8651a92761421b0437ffb44ba5670bea5ee1df/library/panic_unwind/src/seh.rs#L213

bjorn3 avatar Dec 22 '22 16:12 bjorn3

Removed from the rustup component milestone as that will use a panic_unwind compiled using cg_llvm.

bjorn3 avatar Oct 18 '23 14:10 bjorn3

Perhaps the lang team ought to consider whether Rust wants to expose LLVM's \x01 escape code or provide some other means of escaping link names?

Even if the decision is to stick with (and, I guess, document) the \x01 escape, it'd be perfectly reasonable to detect that escape in rustc and lower in some other way to cranelift.

eggyal avatar Oct 19 '23 03:10 eggyal

Documenting it or providing another mean of escaping link names are both fine with me. It doesn't help with implementing this in cg_clif though. cranelift_module and cranelift_object currently don't expose any way to implement it. Once they do, an implementation in cg_clif should be trivial no matter how it is implemented.

bjorn3 avatar Oct 19 '23 11:10 bjorn3