Skip to content

Fix debuginfo compression in bootstrap#158169

Merged
rust-bors[bot] merged 8 commits into
rust-lang:mainfrom
Kobzol:fix-cc-rs-flag-if-supported
Jul 5, 2026
Merged

Fix debuginfo compression in bootstrap#158169
rust-bors[bot] merged 8 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
try-job: dist-various-1
try-job: dist-various-2

@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.

@Kobzol

Kobzol commented Jul 3, 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 Jul 3, 2026
Fix debuginfo compression in bootstrap

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

rust-bors Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 217ff87 (217ff875d701cb36dbe8f2cc525b968e4d2bda9c)
Base parent: c397dae (c397dae808f70caebab1fc4e11b3edf7e59f58c7)

@Kobzol

Kobzol commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Ok, makes sense.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 3, 2026
Comment thread src/bootstrap/src/core/builder/cargo.rs Outdated
@Kobzol Kobzol force-pushed the fix-cc-rs-flag-if-supported branch from f1e4ba5 to 6bd414f Compare July 3, 2026 09:01
@rustbot

rustbot commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/cargo

cc @ehuss

@rustbot

This comment has been minimized.

@Kobzol Kobzol force-pushed the fix-cc-rs-flag-if-supported branch from 6bd414f to 7c1d8b8 Compare July 3, 2026 09:05
@Kobzol

Kobzol commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

@bors r=bjorn3 rollup=never

Another attempt!

@rust-bors

rust-bors Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 7c1d8b8 has been approved by bjorn3

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 10. This pull request will be tested once the tree is reopened.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 3, 2026
@jhpratt

jhpratt commented Jul 5, 2026

Copy link
Copy Markdown
Member

Threading between rollups

@bors p=4

@rust-bors

This comment has been minimized.

@bjorn3

bjorn3 commented Jul 5, 2026

Copy link
Copy Markdown
Member

dist-x86_64-illumos has been running for 5 hours now.

@rust-bors

rust-bors Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: bjorn3
Duration: 5h 4m 42s
Pushing 7148b31 to main...

@Kobzol

Kobzol commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

It took way longer to compile LLVM and LLD in the Illumos job, hmm.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 4eb6253 (parent) -> 7148b31 (this PR)

Test differences

Show 3 test diffs

Stage 2

  • [run-make] tests/run-make/compressed-debuginfo-zstd: ignore (ignored if LLVM wasn't build with zstd for ELF section compression or LLVM is not the default codegen backend) -> pass (J0)

Additionally, 2 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 7148b31956911d5d5496900bf564ca5212bf199b --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-solaris: 1h 1m -> 3h 42m (+259.7%)
  2. dist-x86_64-illumos: 1h 46m -> 4h 59m (+179.8%)
  3. dist-sparcv9-solaris: 1h 33m -> 3h 58m (+154.8%)
  4. dist-apple-various: 1h 39m -> 3h 25m (+107.1%)
  5. dist-aarch64-apple: 1h 25m -> 2h 53m (+102.1%)
  6. dist-x86_64-musl: 2h 19m -> 4h 36m (+97.6%)
  7. dist-x86_64-freebsd: 1h 22m -> 2h 41m (+95.4%)
  8. dist-arm-linux-musl: 1h 43m -> 2h 55m (+70.7%)
  9. dist-loongarch64-musl: 1h 30m -> 2h 34m (+69.8%)
  10. dist-ohos-armv7: 1h 16m -> 2h 7m (+65.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (7148b31): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary -0.1%, secondary 1.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.1% [2.0%, 2.4%] 4
Regressions ❌
(secondary)
3.0% [1.9%, 4.2%] 6
Improvements ✅
(primary)
-1.9% [-5.6%, -0.5%] 5
Improvements ✅
(secondary)
-2.2% [-2.3%, -2.1%] 2
All ❌✅ (primary) -0.1% [-5.6%, 2.4%] 9

Cycles

This perf run didn't have relevant results for this metric.

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 489.956s -> 489.438s (-0.11%)
Artifact size: 393.31 MiB -> 388.50 MiB (-1.22%)

@Kobzol

Kobzol commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

Let's see if the dist job duration increase stays in the next merged PR. If not, then probably we started passing different flags to the LLVM build, and sccache should catch up. If yes, then something is wrong.

@Kobzol

Kobzol commented Jul 5, 2026

Copy link
Copy Markdown
Member Author

It went back (#158740 (comment)), so it was just sccache. Still might be interesting to take a look at exactly what flags have changed.. probably because we now pass out_dir to cc.

@bjorn3

bjorn3 commented Jul 5, 2026

Copy link
Copy Markdown
Member

We now also pass the compression flag when building LLVM, don't we?

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 merged-by-bors This PR was explicitly merged by bors. 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.