Skip to content

Install libgccjit into the compiler's sysroot when cg_gcc is enabled #145341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 13, 2025

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented Aug 13, 2025

This PR installs the libgccjit.so library (which is essentially GCC) into the rustc sysroot (stageN/lib on Linux) when the GCC codegen backend is enabled. This allows using the GCC codegen backend "out of the box" with the resulting rustc. It would be nice to get rid of the libgccjit.so.0 alias (https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Forcing.20unversioned.20dylib.20dependencies.20on.20Linux/with/534180740), but it's not blocking for this change.

You can try running x build std --set 'rust.codegen-backends=["llvm", "gcc"]' and then compiling a hello world with rustc +stage1 -Zcodegen-backend=gcc main.rs.

It is now also possible to build stage2 rustc when the GCC is configured to be the default codegen backend, without any further LD_LIBRARY_PATH hacks: ./x build compiler --stage 2 --set 'rust.codegen-backends=["gcc"]'.

After this change, it should be pretty simple to add a dist/rustup step for actually shipping cg_gcc to end users.

CC @GuillaumeGomez

r? @jieyouxu

@rustbot
Copy link
Collaborator

rustbot commented Aug 13, 2025

jieyouxu is currently at their maximum review capacity.
They may take a while to respond.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Aug 13, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 13, 2025

This PR changes how GCC is built. Consider updating src/bootstrap/download-ci-gcc-stamp.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks

@jieyouxu
Copy link
Member

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Aug 13, 2025

📌 Commit f40a784 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 13, 2025
@Kobzol
Copy link
Member Author

Kobzol commented Aug 13, 2025

I don't think this needs rollup=never, tbh, as this code shouldn't even be exercised on CI, perhaps outside of one PR CI job (famous last words?).

@bors r+ rollup

@bors

This comment was marked as outdated.

@bors

This comment was marked as outdated.

@Kobzol

This comment was marked as outdated.

@bors

This comment was marked as outdated.

@bors

This comment was marked as outdated.

@Kobzol

This comment was marked as outdated.

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 13, 2025
@bors
Copy link
Collaborator

bors commented Aug 13, 2025

📌 Commit f40a784 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 13, 2025
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Aug 13, 2025
…ouxu

Install libgccjit into the compiler's sysroot when cg_gcc is enabled

This PR installs the `libgccjit.so` library (which is essentially GCC) into the rustc sysroot (`stageN/lib` on Linux) when the GCC codegen backend is enabled. This allows using the GCC codegen backend "out of the box" with the resulting rustc. It would be nice to get rid of the `libgccjit.so.0` alias (https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Forcing.20unversioned.20dylib.20dependencies.20on.20Linux/with/534180740), but it's not blocking for this change.

You can try running `x build std --set 'rust.codegen-backends=["llvm", "gcc"]'` and then compiling a hello world with `rustc +stage1 -Zcodegen-backend=gcc main.rs`.

It is now also possible to build stage2 rustc when the GCC is configured to be the default codegen backend, without any further `LD_LIBRARY_PATH` hacks: `./x build compiler --stage 2 --set 'rust.codegen-backends=["gcc"]'`.

After this change, it should be pretty simple to add a dist/rustup step for actually shipping cg_gcc to end users.

CC ``@GuillaumeGomez``

r? ``@jieyouxu``
bors added a commit that referenced this pull request Aug 13, 2025
Rollup of 9 pull requests

Successful merges:

 - #144761 (aarch64: Make `outline-atomics` a known target feature)
 - #144949 (More `Printer` cleanups)
 - #144955 (search graph: lazily update parent goals)
 - #144962 (Add aarch64_be-unknown-none-softfloat target)
 - #145153 (Handle macros with multiple kinds, and improve errors)
 - #145241 ([AVR] Changed data_layout)
 - #145341 (Install libgccjit into the compiler's sysroot when cg_gcc is enabled)
 - #145349 (Correctly handle when there are no unstable items in the documented crate)
 - #145356 (Add another example for escaped `#` character in doctest in rustdoc book)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6f0746d into rust-lang:master Aug 13, 2025
10 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 13, 2025
rust-timer added a commit that referenced this pull request Aug 13, 2025
Rollup merge of #145341 - Kobzol:codegen-backend-gcc, r=jieyouxu

Install libgccjit into the compiler's sysroot when cg_gcc is enabled

This PR installs the `libgccjit.so` library (which is essentially GCC) into the rustc sysroot (`stageN/lib` on Linux) when the GCC codegen backend is enabled. This allows using the GCC codegen backend "out of the box" with the resulting rustc. It would be nice to get rid of the `libgccjit.so.0` alias (https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Forcing.20unversioned.20dylib.20dependencies.20on.20Linux/with/534180740), but it's not blocking for this change.

You can try running `x build std --set 'rust.codegen-backends=["llvm", "gcc"]'` and then compiling a hello world with `rustc +stage1 -Zcodegen-backend=gcc main.rs`.

It is now also possible to build stage2 rustc when the GCC is configured to be the default codegen backend, without any further `LD_LIBRARY_PATH` hacks: `./x build compiler --stage 2 --set 'rust.codegen-backends=["gcc"]'`.

After this change, it should be pretty simple to add a dist/rustup step for actually shipping cg_gcc to end users.

CC ```@GuillaumeGomez```

r? ```@jieyouxu```
@Kobzol Kobzol deleted the codegen-backend-gcc branch August 14, 2025 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants