Conversation
|
Thanks for the pull request, and welcome! The Rust Project has assigned @TaKO8Ki (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
|
@TaKO8Ki This is LLM assisted, not able to edit the label now. Logic is solid and verified. |
|
CI caught a bug in the test, not in the change — and in doing so confirmed the change works.
The useful part is what the failing assertion dumped for That is the metadata object carrying |
rustc synthesizes some object files with the `object` crate rather than with LLVM -- crate metadata, and the `symbols.o` handed to the linker -- so their MIPS ELF header flags are computed by hand. `EF_MIPS_CPIC` was set only when the relocation model was not `static`. LLVM, however, keys `EF_MIPS_CPIC` off abicalls, not off the relocation model: it sets the flag on every object it emits unless the target selects `+noabicalls`. A static target that leaves abicalls enabled -- `mipsel-sony-psp` and `mipsel-sony-psx` -- therefore ends up with LLVM objects marked CPIC and rustc's own objects not, and lld warns "linking abicalls code with non-abicalls code" once per object. That is exactly the "static object with dynamic calls" case the existing comment describes, so set CPIC (without PIC) for it and match LLVM.
Checks `lib.rmeta`, which is the archive member rustc builds itself with the `object` crate, on the two static MIPS targets that leave abicalls enabled and on `mipsel-unknown-none`, which does not, so that the new branch cannot fire where LLVM would not have set the flag either.
5bcab92 to
4bfb234
Compare
|
Let me know if you want any changes made @TaKO8Ki. |
|
Hi, I'm going to close this PR as it has several problems w.r.t. our LLM usage policy. You are welcome to open additional PRs as long as they follow our policy. Note in particular:
|
|
That's fair @hanna-kruppe. I'll clean it up later, make sure it complies with the LLM usage policy and create a new PR. |
rustc synthesizes some object files with the
objectcrate rather than with LLVM — crate metadata, and thesymbols.oit hands to the linker — so their MIPS ELF header flags are computed by hand inelf_e_flags.EF_MIPS_CPICwas set only when the relocation model was notstatic.LLVM keys
EF_MIPS_CPICoff abicalls, not off the relocation model: it sets the flag on every object it emits unless the target selects+noabicalls. So a static target that leaves abicalls enabled gets LLVM objects marked CPIC and rustc's own objects not, and lld warns once per object:Measured on
mipsel-sony-psp: every LLVM object is0x10001005(noreorder|cpic|o32|mips2) whilesymbols.oandlib.rmetaare0x10001000. A hello-world picks up 60 such warnings — now visible via thelinker_messageslint. Reported downstream as overdrivenpotato/rust-psp#203.This is precisely the "static object with dynamic calls" case the existing comment in this function describes, so the fix sets CPIC (without PIC) for it, matching LLVM.
Affected targets
Only static MIPS targets whose spec omits
+noabicalls:mipsel-sony-pspandmipsel-sony-psx. Targets that are not static are untouched, andmipsel-unknown-none(which sets+noabicalls) keeps getting no CPIC — the added test pins both directions.Verification
I have not built a patched compiler, so I verified the change by reproducing its exact effect: taking rustc's own
symbols.ofrom a real build, setting the CPIC bit, and re-running rustc's exactrust-lldinvocation.ci/tests)Combined with #161484, a
cargo pspbuild ofrust-psp's test suite goes from 130 linker warnings to 0, and the suite still passes on PPSSPP (47 pass / 0 fail,FINAL_SUCCESS).The new
tests/run-make/mips-cpic-e-flagscheckslib.rmetainside the rlib, which is the member rustc builds itself. I confirmed by hand that it is0x10001000today, i.e. the test does fail without the change. Note that the test itself has not been executed (I could not build the compiler locally), so please give therun_make_supportusage a careful look.