target: recognize sh4 architecture in parse_arch()#1712
Merged
NobodyXu merged 1 commit intorust-lang:mainfrom Apr 30, 2026
Merged
target: recognize sh4 architecture in parse_arch()#1712NobodyXu merged 1 commit intorust-lang:mainfrom
NobodyXu merged 1 commit intorust-lang:mainfrom
Conversation
1ec181e to
a494229
Compare
SH4 (SuperH) is a Rust target tier 3 — sh4-unknown-linux-gnu and
sh4-unknown-redox both exist in upstream rustc as of 1.79+ — but
parse_arch() in cc-rs's target parser doesn't recognise the `sh4`
prefix, so any C-touching crate compiled against an sh4-* target
fails at config time:
error occurred in cc-rs: target `sh4-unknown-redox` had an
unknown architecture
Adding the one-line arm here matches the existing convention for
similar small soft-float architectures (mips, loongarch, riscv, bpf).
SH4 has no architecture-specific compile-flag adjustments needed in
cc-rs (no -march or similar), so just normalising the arch name is
sufficient.
Tested by building rustx-sh4 toolchain (rust-src + LLVM-from-source
with SuperH target) end-to-end against the resulting `cc` 1.2.28+sh4;
output is a working `rustnav-broker` SH4 ELF (6.6 MB) running on
sh4-unknown-redox.
a494229 to
4b73b18
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SH4 (SuperH) is a real Rust target tier 3 — both
sh4-unknown-linux-gnuandsh4-unknown-redoxare in upstream rustc as of 1.79+ — butparse_arch()doesn't recognise thesh4prefix, so any C-touching crate compiled against an sh4-* target fails at config time:Adding the one-line arm here matches the existing convention for similar small soft-float architectures (mips, loongarch, riscv, bpf). SH4 has no architecture-specific compile-flag adjustments needed in cc-rs (no `-march` or similar), so normalising the arch name is sufficient.
Test plan
Tested via the navhack-org/RustXToolchain SH4 cross-compilation toolchain build (rust-src + LLVM-from-source with SuperH target enabled). End-to-end:
Without this arm, the bootstrap fails immediately during config-time target resolution with the error shown above. Historic mitigation in our build pipeline was to manually patch the cargo-registry copy of cc-rs's parser.rs after every fresh checkout — this PR retires that workaround.
Out of scope
No flag adjustments — SH4 is mostly a soft-float target (single-precision FPU only); the C compile flags from `gcc-sh4-*` are sufficient as-is. Any future SH4-specific tuning (e.g. `-m4-single-only`) can be added as a follow-up if needed.