-
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
Let targets set what platforms they build for #6519
Comments
Prerequisite work is still happening, so marking as a P3 now. This means we're not actively working on this yet. Will upgrade priority once the prereqs are out of the way. |
April '19 update: Still blocked on prerequisites of basic platform & toolchain support. I'd still estimate a "second half of the year" time frame for starting to experiment with this, unless there's enough enthusiastic interest to jump on board even without concern about the scaling & caching concerns. Technically I think really interested users will be able to explore this in the next month or two by manually combining together platform/toolchain support and Starlark transitions. |
@gregestren Hi Greg, can you elaborate on how we can achieve multi-platform builds via transitions? I'm building a small kernel using Bazel as the build engine. The boot-loader is being written targeting UEFI, which uses a PE COFF toolchain (basically targeting Windows via CLang/LLVM), and I want the kernel executables itself to be in ELF format (x86_64-none-elf). At the moment, I have no clear path to go about it, was thinking more in the lines of having two separate Bazel build steps, and then combining the data into a boot disk, but if I could do everything inside Bazel it will be so much easier. |
Hey @wpieterse2825, Building in separate steps is indeed an option if it comes to that. A major inspiration of these new APIs is to not have to resort to that, so we're on the same page there. What BUILD rules are you using to represent the boot-loader and kernel executables and what flags are you using to switch the toolchain? I suspect we can get a clear path for your use case. |
@gregestren Thanks for the reply Greg. At the moment they are just plain I'm not doing anything fancy at the moment, just settings the Also, this is just a pet project to build a small "DOS" like operating system, nothing serious. |
Also, to add to the above, the Thinking of it, I’m using LLVM and LLD, maybe I should try playing with creating a macro wrapping the cc rules for the UEFI and Kernel parts, where the macro itselfs sets copts to specify what linker to use. |
@wpieterse2825: Have you taken a look at #7260? Once you write |
Hi @katre, thanks for mentioning it. I did try and do that, defining the various architectures and firmware targets. You can have a look here. But when I try and build only with platforms, without specifying the |
@katre I did what you suggested and it worked. Could finally remove the |
Excellent, I'm glad it's working, we're trying hard to get this ready enough to enable by default. |
As for the multiplatform part, @juliexxia is working on much more extensive documentation. But in the meantime check out https://github.com/gregestren/snippets/wiki/Configuring-a-cc_binary-differently-than-a-cc_test for an example of configuring I believe you can apply this to |
Alright, thanks @gregestren will try that thanks for all the help |
Would this allow one target to depend on the output of another target with a different platform? An example of this could be developing a piece of hardware with its own firmware and a companion app. The firmware and app target different platforms (say an ARM Cortex M0 microcontroller and windows x86_64) If the app wants to be able to bundle the firmware update, it needs to depend on the output of its compilation. |
That should automatically fall out of this, yes. |
That's super exciting. Thanks! |
Any chance this can bump to P2? Will it make it into bazel v1? |
Hi @prestonvanloon - this is sort of a meta-issue. Various other actively prioritized issues together will essentially fulfill this one. In my mind prioritizing this specific bug would involve prioritizing the API as suggested in the original description. But depending on your exact needs it should be possible to get a lot of this work already. So I think it's reasonable to expect this for Bazel 1.0 but the details depend on which languages you want support for and your exact API needs. All that said, what specifically do you want to do? |
My mission is to have a target that can generate a tar / zip archive which binaries for multiple platforms. Specifically, with golang with rules_go. Currently, we can manually specify each platform tool chain and build the target, but I would like to have some single target that can build the target for all four platforms. # //:main is a go_binary
# What we have today
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64_cgo //:main
bazel build --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64_cgo //:main
bazel build --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64_cgo //:main
bazel build --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64_cgo //:main
# What we want for bazel v1
bazel build //:distro_zip # genrule tar/zip with the outputs from the target/platforms above. |
I think this should be straightforward if you write a rule Also see https://github.com/gregestren/snippets/wiki/Configuring-a-cc_binary-differently-than-a-cc_test for similar example code (not quite the same use case but covers the same principle of making a rule build its deps differently) Starlark transitions even has support for split deps, which could offer more concise syntax (you're building the same dep each time). I'm not sure if that's 100% ready but it might be and I encourage exploration. :) If any of this sounds promising, I suggest a separate issue or bazel-discuss@ thread to back-and-forth on the details (I'm happy to continue offering guidance). If this all looks obviously straightforward, please share your results! It'd be awesome to know if this stuff is helping solve real meaningful use cases. |
This bug has become too broad, and isn't actionably relevant. Let's follow https://bazel.build/roadmaps/configuration.html for a finer-grained breakdown of priorities, and add more specialized bazel-discuss questions or issues as needed. |
Does that mean #10061 should be reopened then? It was closed because it would be tracked by this issue (#10061 (comment)) |
I see your point. Maybe we should keep this open, then. My concern is to keep it well-scoped, since "flagless" implies "no flags" and there are many kinds of flags in the most generic sense. We're really only focusing on I'll re-open and adjust the title some. |
Is this now almost possible because of the work done to support transitions, or is that a completely separate thing? |
Yes, this is close to being doable. I'm working on some high-level proposals now (since my last attempt wasn't workable for a lot of users). |
Hey folks, any update on support for multiple target platforms?
and the code for this warning points back to this issue. |
Trying to get Bazel to directly support multiple values for To that end, my concrete recommendations are:
|
I think I spied a regression in the The check is performed in |
Yes, there's a lot of confusion about the right way to handle this. |
Tracking issue on Bazel Configurability Roadmap
Goal:
This syntax is theoretical; it may not look exactly like this. The point is rules can embed which platforms they target and all the correct toolchains get linked in without having to specify anything at the command line.
Furthermore, different rules needing different toolchains (e.g.
$ bazel build //a:all
) will all independently do the right thing.This is v0 because it may have performance consequences. This also doesn't cover non-platform settings (like app version, enable/disable feature X), which will be covered elsewhere in the roadmap.
The text was updated successfully, but these errors were encountered: