Skip to content

cc-test: add loongarch64 assembly shim - #1855

Merged
NobodyXu merged 1 commit into
rust-lang:mainfrom
tangaac:loongarch64
Aug 14, 2026
Merged

cc-test: add loongarch64 assembly shim#1855
NobodyXu merged 1 commit into
rust-lang:mainfrom
tangaac:loongarch64

Conversation

@tangaac

@tangaac tangaac commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Problem

dev-tools/cc-test's build.rs compiles src/<arch>.S based on the target architecture. aarch64.S, armv7.S, i686.S, riscv64gc.S, and x86_64.S are all present, but there is no loongarch64.S. On loongarch64-unknown-linux-gnu (stable Rust target since 1.75) this fails with:

cc1: fatal error: src/loongarch64.S: No such file or directory

The cc crate itself already declares support for LoongArch64 (loongarch64-unknown-linux-gnu => loongarch64-linux-gnu in src/lib.rs), so this is purely a missing dev-tool shim.

Fix

Add dev-tools/cc-test/src/loongarch64.S, modeled on riscv64gc.S, exporting both asm and _asm symbols. Verified on real LoongArch64 hardware: cargo build succeeds and cargo test passes 9/9 — the asm_here test asserts the shim returns 7.

@NobodyXu NobodyXu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Would you like to add a CI job to compile the test on loongarch?

It's ok if you don't want to and I can get this merged

@tangaac

tangaac commented Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

I dropped the check-loongarch64 CI job — cross-linking the test suite on an x86_64 runner hits an unrelated problem. build.rs has a cfg(target_os = "linux") block (for the static-libstdc++ link test) that runs the host g++ --print-file-name=libstdc++.a and symlinks the host libstdc++.a into OUT_DIR. On an x86_64 runner that is an x86_64 archive, and rustc embeds its objects (e.g. del_ops.o) into the test rlib, so the loongarch64 linker fails with Relocations in generic ELF (EM: 62). This only surfaces on a linux cross target — the existing cross jobs are Apple/Windows, so this path was never exercised.

So this PR is just the shim for now. It is verified on a real LoongArch64 machine: the assembly compiles and asm_here passes.

@NobodyXu
NobodyXu merged commit 951c5f5 into rust-lang:main Aug 14, 2026
162 of 164 checks passed
@NobodyXu

Copy link
Copy Markdown
Contributor

Thanks, merged

@github-actions github-actions Bot mentioned this pull request Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants