Skip to content

gcc: locate codegen-backends via host_tuple()#159753

Draft
xobs wants to merge 1 commit into
rust-lang:mainfrom
xobs:gcc-backend-via-host-tuple
Draft

gcc: locate codegen-backends via host_tuple()#159753
xobs wants to merge 1 commit into
rust-lang:mainfrom
xobs:gcc-backend-via-host-tuple

Conversation

@xobs

@xobs xobs commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

file_path builds the lib/rustlib/<host>/codegen-backends path used to load the codegen backend. It passed &sess.host.llvm_target, but that is the host's LLVM target string, not its rustc target tuple. The two can differ (e.g. arm64-apple-macosx vs aarch64-apple-darwin), so the lookup can miss the directory that actually holds the backend. Use rustc_session::config::host_tuple() instead.

This fixes an issue when building custom toolchains. In particular, I'm using the gcc backend to build a custom SH4 compiler. Without this patch, this command fails to find the backend:

$ BOOTSTRAP_SKIP_TARGET_SANITY=1 python3 x.py install library --target sh4-dreamcast-none-elf

`file_path` builds the `lib/rustlib/<host>/codegen-backends` path used to
load the codegen backend. It passed `&sess.host.llvm_target`, but that is
the host's LLVM target string, not its rustc target tuple.  The two can
differ (e.g. `arm64-apple-macosx` vs `aarch64-apple-darwin`), so the
lookup can miss the directory that actually holds the backend. Use
`rustc_session::config::host_tuple()` instead.
@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 23, 2026
@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

r? @mejrs

rustbot has assigned @mejrs.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 20 candidates

@xobs

xobs commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing to send the PR to rustc_codegen_gcc instead

@xobs xobs closed this Jul 23, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2026
@xobs xobs reopened this Jul 23, 2026
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2026
@xobs
xobs marked this pull request as draft July 23, 2026 12:23
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants