rust-lang / rustc_codegen_cranelift

Cranelift based backend for rustc
Apache License 2.0
1.52k stars 94 forks source link

Implement platform specific symbol mangling suppression using \x01 #1332

Open bjorn3 opened 1 year ago

bjorn3 commented 1 year ago

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 commented 8 months ago

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

eggyal commented 8 months ago

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.

bjorn3 commented 8 months ago

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.