Skip to content

Honor user C and C++ compiler options in Cargo build scripts - #4264

Closed
dzbarsky wants to merge 1 commit into
bazelbuild:mainfrom
dzbarsky:fix/build-script-user-copts
Closed

dzbarsky wants to merge 1 commit into
bazelbuild:mainfrom
dzbarsky:fix/build-script-user-copts

Conversation

@dzbarsky

@dzbarsky dzbarsky commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Submitted to the intended repository in hermeticbuild#64. This PR is closed.

Include --copt, --conlyopt, and --cxxopt when deriving CFLAGS and CXXFLAGS for Cargo build scripts. These flags were omitted from the C/C++ toolchain variables, so native code compiled by a build script could use different defines and compiler options from Bazel C/C++ targets. Keep C-only and C++-only flags separate.

Added a regression for common and language-specific flags. It fails before the fix; all 32 tests in //cargo/tests/cargo_build_script/cc_args_and_env:all pass on Bazel 9 afterward.

Assisted by OpenAI Codex.

Include --copt with --conlyopt or --cxxopt in the C/C++ toolchain variables used to derive CFLAGS and CXXFLAGS. This makes build script native compilation honor Bazel compiler options while keeping language-specific flags separate.

Add an analysis regression for all three options. The regression fails before the fix; all 31 cc_args_and_env tests pass on Bazel 9 afterward.

Assisted-by: OpenAI Codex
@dzbarsky dzbarsky closed this Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant