-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Allow configuring different compilers for C and C++ #4644
Comments
Quick proof of concept of what I was thinking: snowp@0672499 Would love to hear if this is something that'd be useful. @damienmg mind taking a look? or delegating to someone more appropriate |
What's the problem with using always using |
While From what I understand it might be possible to configure |
Yes, the linking behavior is slightly different, but in a crosstool, there isn't really any harm in explicitly writing the |
The issue that envoy ran into boiled down to the fact that From what I can tell there's enough differences between the two of them that being able to define them separately doesn't seem too unreasonable. While I'm not gonna spend too much time trying to get this in, it was mostly a big surprise that bazel made this so difficult (coming from e.g. cmake where one has distinct CC and CXX are distinct options). Happy to drop this if it goes against the intent of the CC toolchain. |
To be clear: I'm arguing for giving people the option to specify a different C/C++ compiler, not claiming that it's necessary |
There is no guarantee that the behavior of Examples:
I can't think of any other case where compiler configuration for two different languages would be represented with the same variables merely because one particular implementation is busybox-ish. |
Yuck, the wrapper script in https://github.com/envoyproxy/envoy/pull/2631/files is awful. Compiling with a different binary looks doable, but what about linking? Is the rule that the C++ compiler should be used if there is at least one object file that was built from C++? |
(keeping this as P2 due to that wrapper script) |
This is the rule for GCC and probably for Clang. Note that a |
Has there been any progress on separating C and C++ compiler options? The Envoy wrapper script still exists, and is becoming quite complex. We'd really like to get rid of it, but can't until this bug is fixed. |
Not much, but #6926 is scheduled for this quarter, so maybe in the near future. |
What do you need from cc_import to solve the issue described here? |
Any updates? This is still a problem, see e.g.: #11122 |
bazel-contrib/rules_foreign_cc#931 is also affected by this one. In this case, the rule is using The problem here is that |
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 or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
I think this is still an existing issue, unless someone determines that this is not going to be supported. |
@bazelbuild/triage still relevant |
This has been fixed (assuming you use action_configs, and have configured them correctly, since without action configs you can't configure a seperate C and C++ tool). I got it working in bazelbuild/rules_rust@a92de54 |
@matts1 Do you have an example of a toolchain that has been configured with separate C and C++ tools? Looking at the |
I'm working on an example right now, if you look at the commits to rules_cc over the next few days. Tldr is to set one tool for the c_compile action and another for the other compile actions. |
Also, I'll be doing a presentation at bazelcon in ~2 weeks on defining C++ toolchains, which may help. |
Description of the problem / feature request:
Allow configuring separate compiler executables when targeting C and C ++respectively, and make this information accessible in Skylark (e.g. add it to the cpp fragment). Having them be declared by CC/CXX would be nice, but that might break a lot of stuff since CC is already used to configure the C++ compiler.
Feature requests: what underlying problem are you trying to solve with this feature?
From what I understand the cc_toolchain is supposed to configure both the C++ and C toolchain, but it only allows specifying one compiler executable. This means that in cases where one might want to use g++ as the C++ compiler, you will no longer be able to build C files (without providing a secondary toolchain? I'm a bit fuzzy here). This is a real problem, see for example envoyproxy/envoy#839. Envoy uses g++/clang++ instead of gcc/clang to work around #2840
Have you found anything relevant by searching the web?
Looked at the cpp fragment docs and asked around in IRC. Everything seems to assume that the compiler given to the cc_toolchain can handle both C++ and C.
If this seems like a reasonable idea I'm happy to attempt to get this working.
The text was updated successfully, but these errors were encountered: