Avoid unused unwindlib flag in rustc links - #38
Conversation
Assisted-by: OpenAI Codex
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd9a6c651a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Assisted-by: OpenAI Codex
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e3b9f08d6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Assisted-by: OpenAI Codex
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a7d5db6a5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Assisted-by: OpenAI Codex
Summary
-unwindlib=none/--unwindlib=nonearguments throughrustcwhen rustc disables the linker's default librariesArgsor@response-filecontents leave the effective setting unknownRoot cause
rules_rustasks Bazel's C++ toolchain for its executable-link command line and forwards those arguments torustcas-C link-arg. Hermetic Clang toolchains can include an unwind-library selection in that command line.By default,
rustcinvokes a compiler driver with-nodefaultlibsand supplies the Rust runtime and unwind library explicitly. Clang therefore cannot act on-unwindlib=noneor--unwindlib=noneand correctly reports an unused-command-line warning.Rust 1.97's
linker_messageslint surfaces successful-link stderr as a Rust warning, so the redundant toolchain argument became visible across every Rust binary and test link. See rust-lang/rust#136096 for the linker-message behavior.Conditional behavior
Targets can opt back into compiler-driver defaults with bare
-Cdefault-linker-librariesor an affirmative value such as-Cdefault-linker-libraries=yes. In those modes Clang can use the unwind-library selection, so this change preserves it.Rustc uses the last occurrence of the option. The implementation therefore evaluates statically available flag sources in their real command-line order, including later disabling values such as
=no. OpaqueArgsand@response-filecontents are treated as unknown; the unwind selection is preserved unless a later static option establishes that default linker libraries are disabled.Why remove the arguments conditionally
Adding
-Wno-unused-command-line-argumentwould hide an accurate diagnostic and could conceal other genuinely stale linker-driver options. This change removes only the two accepted spellings of the known-inapplicable unwind option when rustc's effective behavior makes them unusable. All other toolchain arguments remain intact.Verbose-link inspection confirmed that removing these arguments in the default mode does not change the final LLD inputs:
rustcstill links the explicit unwind runtime.Validation
bazelisk test //test/unit/...— 404 tests passed, 24 skipped=nooverrides an earlier=yesand removes both spellings-nodefaultlibs, while both the bare and=yesforms omit it//services/oriel/pid-gen:pid-gen-testin the downstream monorepo using this checkout via--override_repository, with unused-command-line warnings explicitly re-enabled; the target built successfully without the warningmainAI assistance
OpenAI Codex assisted with diagnosis, implementation, and test construction. I reviewed the resulting code and validated it against both the upstream unit suite and the downstream reproducer.