Use more accurate ELF flags on MIPS by smrobtzz · Pull Request #140634 · rust-lang/rust (original) (raw)

Sorry, should've explained more. I'm using a custom target specification with this combination of options:

"arch": "mips64",
"cpu": "mips3",
"llvm-abiname": "n32",
"features": "+noabicalls",

With these options, Rust's metadata objects (not sure what they're called) are always ELF64 mips64r2 objects, whereas the code objects emitted by LLVM are ELF32 mips3 objects. So, linking an executable (or, making an rlib and trying to link that with something else) fails because the objects are obviously incompatible.

My changes are attempting to be "thorough" because the criteria for what the GNU and LLVM linkers consider compatible objects is pretty unclear. They can complain about nan2008 not matching, the ABI not matching, the CPU not matching, etc. So, I figured that it would be at better (resulting in the least amount of linker complaints for whatever custom or builtin targets people may be using) to at least put some effort into making sure the ELF files emitted are close to what LLVM outputs, rather than (for mips64 at least) defaulting to what mips64el-linux-gnuabi64-gcc foo.c -c did, and assuming that's fine.