-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Enable setting C/C++ standards as a toolchain feature #16551
Comments
@oquenchil Sorry don't know who else to ping. Any objections to this feature? Happy to do the remaining work if it can be accepted. My initial PR that implements this feature is here: #16552 |
My 2 cents,
ref: bazel/tools/cpp/unix_cc_configure.bzl Lines 409 to 421 in e97f62d
EDIT: b272cef only in preview 7 ref: https://www.gnu.org/software/make/manual/make.html#Implicit-Variables
|
At least for |
RTYI, @jsharpe. :) |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
I think this is still relevant. |
Description of the feature request:
Proposal to add a handful of new "features" to the default c++ toolchain that enables setting C/C++ standards (names tentative):
BAZEL_CXXOPTS
, default-std=c++0x
)I've got an initial implementation of this capability that currently works on linux & macos, and does not break backwards compatibility:
#16552
I'd like to get some feedback from the Bazel team on if it's possible to get this merged before doing whatever else is necessary to meet the contribution requirements (design docs, testing, etc...).
What underlying problem are you trying to solve with this feature?
The original issue I was trying to solve was to get some code to build with bazel that mixes C/C++ code in the same target:
It's currently not possible to build that target with Bazel. This is because there's no way to distinguish between C and C++ flags at the
cc_*
rules level. The compiler will issue a warning when-std=c++14
is passed while compiling the C file, and -Werror will cause that warning to be propagated as a build error.There are various alternatives but none of them are desirable:
I think that the most elegant solution to this problem is to just expose a new set of features in the default toolchain that allow setting the standard. The features API enables distinguishing between C/C++ actions and avoids the scope issues above. Every target can mix and match C/C++ and decide the standard for each.
The POC branch I've linked shows that it should be possible to do this without breaking backwards compatibility of existing behavior, assuming that the order of flags is not part of the API.
Which operating system are you running Bazel on?
Windows, Linux, and Mac
What is the output of
bazel info release
?5.3.2
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?No response
Have you found anything relevant by searching the web?
Lots of research, still prefer my suggestion above.
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: