Skip to content

Fix cc rs flag if supported#158169

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

Fix cc rs flag if supported#158169
Kobzol wants to merge 3 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

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. CC @madsmtm or @NobodyXu in case you have thoughts on that :)

r? @bjorn3

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

Copy link
Copy Markdown
Collaborator

The job dist-various-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] gimli test:false 4.980
[RUSTC-TIMING] object test:false 5.597
error: linking with `rust-lld` failed: exit status: 1
  |
  = note:  "rust-lld" "-flavor" "gnu" "--version-script=<sysroot>-std/x86_64-unknown-fuchsia/dist/deps/rustcXNjUCX/list" "--no-undefined-version" "--build-id" "--hash-style=gnu" "-z" "max-page-size=4096" "-z" "now" "-z" "start-stop-visibility=hidden" "-z" "rodynamic" "-z" "separate-loadable-segments" "-z" "rel" "--pack-dyn-relocs=relr" "<sysroot>-std/x86_64-unknown-fuchsia/dist/deps/rustcXNjUCX/symbols.o" "<1 object files omitted>" "<sysroot>-std/x86_64-unknown-fuchsia/dist/deps/rustcXNjUCX/rmeta.o" "<1 object files omitted>" "--as-needed" "-Bdynamic" "-lzircon" "-lfdio" "-lzircon" "-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-fuchsia/dist/deps/{libpanic_unwind-417f7c4656763808,libaddr2line-921ac66b5bf3d0d2,libgimli-9d9a783454891b12,libcfg_if-a4e68cb521965acf,libobject-636d5dbf6958baf9,libmemchr-dd2b00b4863e493e,librustc_demangle-104c0bb3c5349d29,libstd_detect-d8dda86d8d03dfaf,libhashbrown-14a49224ea05c02f,librustc_std_workspace_alloc-7db94a9d0457fcfc,libminiz_oxide-bac93a2793c027e7,libadler2-be784218a0c195f9,libunwind-272440eb5552bb3a}.rlib" "-lunwind" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-fuchsia/dist/deps/{liblibc-7362514cf8f5457e,librustc_std_workspace_core-09b73d79dacb536a,liballoc-b42f5928c0c535c8,libcore-c34ffc106f1167b3,libcompiler_builtins-c42c07b16414db0d}.rlib" "-Bdynamic" "-lc" "-lfdio" "-L" "<sysroot>-std/x86_64-unknown-fuchsia/dist/deps/rustcXNjUCX/raw-dylibs" "--eh-frame-hdr" "-z" "noexecstack" "-L" "/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot/lib" "-L" "/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/lib" "-L" "<sysroot>-std/x86_64-unknown-fuchsia/dist/build/compiler_builtins-421932536528bcee/out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-fuchsia/lib" "-o" "<sysroot>-std/x86_64-unknown-fuchsia/dist/deps/libstd-4e7987ff6682ad78.so" "-shared" "-soname=libstd-4e7987ff6682ad78.so" "-O1" "-gz" "--sysroot=/usr/local/core-linux-amd64-fuchsia-sdk/arch/x64/sysroot"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: rust-lld: error: unknown argument '-gz'
          

[RUSTC-TIMING] std test:false 17.271

@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 b417acf failed: CI. Failed job:

@Kobzol

Kobzol commented Jun 20, 2026

Copy link
Copy Markdown
Member Author

Sigh, now we have to fix the fallout of whoever knows how long the flags weren't applied by mistake 😆

@bjorn3

bjorn3 commented Jun 20, 2026

Copy link
Copy Markdown
Member

I think the probe needs to be done with the C compiled told to use rust-lld if we will use rust-lld for the actual build. Separately to actually get compressed debuginfo as intended, we have to install zlib in all containers.

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

6 participants