Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ compiler is selected via a constraint #25128

Open
comius opened this issue Jan 29, 2025 · 2 comments
Open

C++ compiler is selected via a constraint #25128

comius opened this issue Jan 29, 2025 · 2 comments
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions team-Rules-CPP Issues for C++ rules type: bug

Comments

@comius
Copy link
Contributor

comius commented Jan 29, 2025

Description of the bug:

Bazel selects C++ compiler using a compiler constraint. Because of this, users need to create a new platform for each compiler. This doesn't really match the expectation of what a platform should describe.

The problem is most obvious on Windows, which has several C++ compilers.

Proposed solution

What should happen instead is that the compiler is selected by --compiler flag (that has arbitrary string value). This approach is well tested and works well at Google.

Caveat is that this is now an incompatible change. Compiler constraint was introduced very early, before Bazel team build up experience with platforms and toolchains.

@comius comius added team-Configurability platforms, toolchains, cquery, select(), config transitions team-Rules-CPP Issues for C++ rules and removed untriaged labels Jan 29, 2025
@comius
Copy link
Contributor Author

comius commented Jan 29, 2025

@comius comius changed the title C++ compiler is selected via a contraint C++ compiler is selected via a constraint Jan 29, 2025
@fmeum
Copy link
Collaborator

fmeum commented Jan 29, 2025

Bazel selects C++ compiler using a compiler constraint. Because of this, users need to create a new platform for each compiler. This doesn't really match the expectation of what a platform should describe.

I would say it depends. If the compiler is not hermetic, but rather discovered on the host and accessed from PATH, then it does make sense to select it via an exec constraint (never a target constraint) on a platform, with the constraint meaning "the execution platform needs to have gcc/clang/clang-cl available in PATH". As far as I know, this is the situation on Windows.

But if there are multiple hermetic toolchains available, required_settings seems more appropriate as the toolchains can be used on any exec platform supporting their general OS/arch constraints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions team-Rules-CPP Issues for C++ rules type: bug
Projects
None yet
Development

No branches or pull requests

5 participants