Skip to content

Fix debuginfo compression in bootstrap#158169

Open
Kobzol wants to merge 6 commits into
rust-lang:mainfrom
Kobzol:fix-cc-rs-flag-if-supported
Open

Fix debuginfo compression in bootstrap#158169
Kobzol wants to merge 6 commits into
rust-lang:mainfrom
Kobzol:fix-cc-rs-flag-if-supported

Conversation

@Kobzol

@Kobzol Kobzol commented Jun 20, 2026

Copy link
Copy Markdown
Member

View all comments

Found through https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/weird.20code.20in.20fill_target_compiler/with/604588655.

This PR solves a few issues with debuginfo compression in bootstrap.

The main issue was that debuginfo compression through the -gz flag wasn't enabled, by mistake.

When cc-rs checks if a compiler flag is supported, it tries to read out_dir to generate the source file in. However, when this option is not set, then the check silently fails and the flag is considered to be unsupported. Since we didn't set out_dir, all such added flags were simply ignored.

Normally, it reads OUT_DIR, which is fine if cc-rs is used within a build script. But if it is used elsewhere, then this is a pretty gnarly footgun in cc-rs, because the failure is completely silent. CC @madsmtm or @NobodyXu in case you have thoughts on that :)

After that was fixed, I had to change the used compression flag from -gz to --compress-debug-sections, to support both BFD and LLD linkers.

And to solve it properly, and allow dist CI jobs to configure debuginfo compression for all targets that they build, I added a new bootstrap option to configure debuginfo compression.

I wanted the flag to be configurable both globally and per target. At the same time, the flag applies both to C/C++ and Rust. We currently don't have such config area in bootstrap.toml, and [build] didn't seem like the right place, so I shoved it into [rust] (while documenting that it also applies to C/C++).

r? @bjorn3

try-job: dist-x86_64-msvc
try-job: dist-x86_64-apple
try-job: dist-x86_64-linux

@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 Jun 20, 2026
@bjorn3

bjorn3 commented Jun 20, 2026

Copy link
Copy Markdown
Member

Thanks!

@bors r+

@rust-bors

rust-bors Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 1bc29dc has been approved by bjorn3

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Jun 20, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 20, 2026
Fix cc rs flag if supported

Found in https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/weird.20code.20in.20fill_target_compiler/with/604588655.

When `cc-rs` checks if a compiler flag is supported, it tries to read `out_dir` to generate the source file in. However, when this option is not set, then the check silently fails and the flag is considered to be unsupported. Since we didn't set `out_dir`, all such added flags were simply ignored.

Normally, it reads `OUT_DIR`, which is fine if `cc-rs` is used within a build script. But if it is used elsewhere, then this is a pretty gnarly footgun in `cc-rs`, because the failure is [completely silent](https://github.com/rust-lang/cc-rs/blob/main/src/lib.rs#L1483).  CC @madsmtm or @NobodyXu in case you have thoughts on that :)

r? @bjorn3
@rust-log-analyzer

This comment has been minimized.

@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 20, 2026
@rust-bors

rust-bors Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

💔 Test for b946733 failed: CI. Failed job:

@rust-bors rust-bors Bot 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 Jun 20, 2026
@rustbot rustbot added A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Jun 20, 2026
@Kobzol

Kobzol commented Jun 20, 2026

Copy link
Copy Markdown
Member Author

@bors try jobs=x86_64-gnu-distcheck

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 20, 2026
Fix cc rs flag if supported


try-job: x86_64-gnu-distcheck
@NobodyXu

Copy link
Copy Markdown
Contributor

Thanks, I've opened an issue #1765, I think this is something we should fix.

We could use a tempfile instead for it

@ChrisDenton

Copy link
Copy Markdown
Member

Thanks, I've opened an issue #1765

I think you meant rust-lang/cc-rs#1765 😉

@rust-bors

rust-bors Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: d269546 (d269546b8320f5f3255b5c7e6268def1a4808374)
Base parent: 4008bbd (4008bbdf34b583ce44a467043aae3703afc0a76f)

@Kobzol

Kobzol commented Jun 20, 2026

Copy link
Copy Markdown
Member Author

@bors r=bjorn3

Let's try again.

@rust-bors

rust-bors Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d59253e has been approved by bjorn3

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Jun 20, 2026
@rust-bors

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 30, 2026
Fix debuginfo compression in bootstrap


try-job: dist-x86_64-msvc
@rust-bors rust-bors Bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 30, 2026
@rust-bors

rust-bors Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

💔 Test for c03a808 failed: CI. Failed job:

@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@bors r-

@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 30, 2026
@rust-bors

rust-bors Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#158584), which was unapproved.

View changes since this unapproval

@Mark-Simulacrum

Copy link
Copy Markdown
Member

@bors r-

Seems like this grows the command line a bit too long for at least rustc_abi on Windows (I guess we were already very close to the edge).

Not sure what the best solution for that is, maybe we just don't do debuginfo compression on Windows to start? I forget if rustc supports response files, if yes, then we could implement/add support for those in Cargo and/or sccache.

@rust-bors

rust-bors Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

This pull request was not previously approved.

@Kobzol

Kobzol commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@bors try

Testing if it also happens without sccache.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 30, 2026
Fix debuginfo compression in bootstrap

try-job: dist-x86_64-msvc
@rust-bors

rust-bors Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

💔 Test for e103f50 failed: CI. Failed job:

@rust-log-analyzer

This comment has been minimized.

@Kobzol

Kobzol commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 30, 2026
Fix debuginfo compression in bootstrap

try-job: dist-x86_64-msvc
try-job: dist-x86_64-apple
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 4c6d7d3 failed: CI. Failed job:

@Kobzol Kobzol force-pushed the fix-cc-rs-flag-if-supported branch from 1271947 to 4f747ca Compare June 30, 2026 13:21
@Kobzol

Kobzol commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@bors try

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jun 30, 2026
Fix debuginfo compression in bootstrap

try-job: dist-x86_64-msvc
try-job: dist-x86_64-apple
try-job: dist-x86_64-linux
@rust-bors

rust-bors Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 573394b (573394b0c5a21ed70e1369c5784c24b4e7593812)
Base parent: 5165714 (51657149e91586571ff1c463bc58239daa1a88d2)

@Kobzol Kobzol force-pushed the fix-cc-rs-flag-if-supported branch from 4f747ca to 9f7569b Compare June 30, 2026 17:38
@Kobzol

Kobzol commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

@bors try

@rust-bors

rust-bors Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

⌛ Trying commit 9f7569b with merge f2dc3ea

To cancel the try build, run the command @bors try cancel.

Workflow: https://github.com/rust-lang/rust/actions/runs/28464072089

rust-bors Bot pushed a commit that referenced this pull request Jun 30, 2026
Fix debuginfo compression in bootstrap

try-job: dist-x86_64-msvc
try-job: dist-x86_64-apple
try-job: dist-x86_64-linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants