facebook / facebook/buck2

How to use multiple execution platforms

Open
#612 1 comment 0 reactions 0 assignees View on GitHub
documentation
Dominant language
Rust
Stars
4.4k
Forks
394
PR merge metrics
No merged PRs in 30d

Description

I have a project that can be built for either Linux or Windows, without any cross-compilation so Linux and Windows are also the two execution platforms. Since there is remote execution, I wanted to be able to build for Linux from my Windows machine using RE.

To keep this short I created a sample project: https://github.com/facebook/buck2/compare/main...Overhatted:buck2-strip-prefix:multiple_target_platforms
It takes inspiration from the following issue: #487
The project just runs some Linux commands which obviously doesn't make sense to do on Windows but it's just a sample for me to understand the execution platform resolution.

When running "buck2 build --target-platforms root//platforms:linux tests:tests" on Windows, I wanted it to select the Linux execution platform automatically (since it's the only one with the "config//os/constraints:linux" constraint) but it tries to run it on the Windows platform, presumably because it is the first one declared, so I don't think I'm using the constraints correctly.

To reproduce the project above:
1. Initialize the repository by running: `buck2 init --git`, `cd prelude` and then `git reset --hard 3b5706b425a88a8641aad8d8ffcc6cdf441b9db0`.
2. Fill the correct remote execution information in .buckconfig
3. Change the "container-image" value to point to a Windows and a Linux docker image available on the RE, depending on the value of platform_name.

Running the command, "buck2 build --target-platforms root//platforms:linux tests:tests", I wanted the genrule commands to be ran on Linux but instead they are ran on Windows, demonstrated by the error message I receive: 'Failed to start process: exec: "sh": executable file not found in %PATH%'

How can I add constraints to the execution platform so that Buck2 automatically selects the correct execution platform for the selected target platform?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.