-
-
Notifications
You must be signed in to change notification settings - Fork 683
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
Go Toolchain Based On Target Configuration #1120
Comments
To answer your specific question, you can select the Go toolchain with More broadly though, we don't support cross-compiling cgo yet. It's something we'd like to support in the future, but cross-compiling C/C++ with Bazel is difficult. I'll close this as a duplicate of #1020, which is the main issue tracking cross-compilng cgo. |
I think this is a different problem than cross-compiling. Currently, from what I can tell, cgo always ends up using the "host" Bazel configuration's C/C++ toolchain, instead of the "target" one. This can sometimes mean selecting a different toolchain, potentially from a different CROSSTOOL, with different flags. The result doesn't always link correctly with target-configuration cc_library rules, even if they are the same --cpu. It also makes selecting a different compiler with --compiler impossible if you specify --host_crosstool_top, because when --host_crosstool_top is specified the host compiler is always the CROSSTOOL-specified default one; --compiler only affects the target compiler in that situation. I work with @nathantchan, and we worked around this locally by switching back to pulling C/C++ information from ctx.fragments.cpp instead of go_toolchain. That correctly uses the target C/C++ toolchain for target-configuration rules. It's possible this is a fundamental limitation of Bazel's toolchain support too, but it seems worth raising it here before filing a bug with Bazel itself. |
It's the same problem, just a different symptom. We call anything where target != host cross compiling, and in this case you are causing that to be true, even though the target os and architecture are the same, because the crosstool is not. |
Right now, the go_toolchain uses the host's configuration. This creates issues in cgo when the C code is compiled according to a target configuration that is different from the hosts. Will there be support for the go_toolchain using differing target configurations?
The text was updated successfully, but these errors were encountered: