-
-
Notifications
You must be signed in to change notification settings - Fork 220
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
extra_targets
, user configurable toolchains, and wasm support
#85
extra_targets
, user configurable toolchains, and wasm support
#85
Conversation
…_tools (See bazel-contrib#23). Since `@bazel_tools//tools/cpp:unix_cc_toolchain_config.bzl:cc_toolchain_config` is a rule, our `cc_toolchain_config` needs to become a macro instead of a rule. Luckily we actually can do this without introducing any breaking changes. Other than the discrepancies listed within (the things marked with `## NOTE:` — make vars and framework paths) everything seemed to just fall into place. So far it seems to _just work_ 🤞.
It's true that modern versions of ld.lld support start and end groups but we don't use ld.lld on macOS (yet).
…tions in the execroot As the message within explains, `rules_foreign_cc` will use a different PWD than the execroot root for cmake targets which breaks the wrapper script. This commit has the wrapper script search alongside itself for `clang` when it isn't in the usual places.
Bazel complains about this; see: https://stackoverflow.com/questions/62451307/specify-sysroot-for-bazel-toolchain for Linux the default default sysroot is "" so we hit this error
…chains for extra targets doesn't actually change the sysroot/`--target` flag, etc. as needed yet; just wires things up on the bazel side lightly tested
this will let us avoid grabbing/loading into the sandbox all the sysroots when using any of the toolchains
…n `cc_toolchain_config` the intention is that this can be used both by `configure.bzl` in processing `extra_targets` and by users of this repo who wish to set up their own toolchains that are slightly different from the provided ones *without* needed for patch this repo or recreate all the logic in it this will also enable people to prototype setting up toolchains for other targets quickly (which they can then easily make a PR for to add support for using the target via `extra_targets`)
…ch the compiler files live this is needed to allow users to create their own toolchains using our macros because rules.bzl is *not* autogenerated with `configure`, we have to explicitly pass in the repo where the compiler and friends live eventually – if this is an API we want to actually support – we should provide some wrapper functions that land in the generated repo and call the underlying functions for you and paper over some of the sharper edges an example usage is in the next commit
…set up to the README
we want to get the current version of `@platforms`, not just the version bundled with the current Bazel version being used this way we don't have to adjust the constraints produced for a particular toolchain to match the version of `@platforms` used by the current Bazel version
563ec76
to
a0f0eb4
Compare
6c86168
to
a89ddef
Compare
see WebAssembly/wasi-sdk#173 for more details
0c894e7
to
94a4975
Compare
81edc53
to
8cb5c40
Compare
8cb5c40
to
99ed2f7
Compare
d5e622c
to
55211fe
Compare
@rrbutani Any chance you are still interested in pursuing this? wasm support would be really nice |
@dzbarsky I'm still interested but I think the approach I took was pretty general; I'm not sure if it aligns with the goals of this project. Are you interested in just wasm support or also in the extra targets/configuration bits as well? |
I suspect a lot of users end up applying small patches to twiddle some of the options that you expose as extra configuration, so I'm not sure if its worth the complexity. For me the main benefit would be to have a way to target wasm using a |
I won't speak for the active maintainers of this project but I'd guess that unconditionally registering wasm/wasi toolchains (and fetching the wasi-sdk sysroot for the latter) probably isn't too controversial; there's probably no need to grow configuration options like Unfortunately I won't have the cycles to work on something like this for at least the next few weeks; I'm happy to answer questions though. |
My thinking was that existing users can go through https://github.com/grailbio/bazel-toolchain#supporting-new-target-platforms and submit PRs for their target platforms, including WASM. I am a little bit reluctant to also manage the mapping between LLVM versions and WASM SDK in this project, so maybe it can be left to the users to configure the right sysroot. Maybe just adding a test for WASM here can serve as an example. |
If this is not an active topic anymore, should we close it? |
(this PR builds on #75; that PR should be reviewed/merged before this one)
This PR is not ready for merging yet but I thought I'd open the PR anyways to get some feedback and see if this is a use case the maintainers are interested in.
This PR adds support for
extra_toolchains
, an attribute onconfigure
that lets users register additional toolchains for different target triples:The toolchains registered with
extra_targets
have the appropriate constraint values so that Bazel will use them as necessary through toolchain resolution.In extending the internals of this repo to support
extra_targets
,cc_toolchain_config
and other internal macros were made a fair bit more general. This PR also tweaks these macros to be usable externally, allowing users to make small modifications to the configured toolchains without needing to modify this repo:The interface is currently extremely rough and is just intended to be a way to prototype support for other targets without needing to modify this repo. If there's interest, there's lots that can be done to turn this into a user-friendly API.
Currently, only the
wasm32-unknown-wasi
target triple is tested and actually working. However this PR lays the foundation for support for other targets; it should just be a matter of adding sysroot and compiler_rt locations for other targets and fine-tuning the LLVM target triple to Bazel constraint value mappings.As an aside, even in adding support for just a single additional (not-hosted) target the ways in which using
unix_cc_toolchain_config.bzl
(#75) limit us becomes apparent (we would like to have the toolchain for wasm targets not support the dynamic linking actions since they just error; instead we're forced to use--features=-supports_dynamic_linker
on the command line or transitions/select
s or other such workarounds).So far this has been manageable but this definitely casts some doubt on whether #75 is the way to go.
Another thing to consider is whether upstream Bazel would be willing to make
unix_cc_toolchain_config.bzl
slightly more general/whether or not our use case aligns with its intended purpose.