Select on host platform and execution platform
See original GitHub issueFirst of all, I apologize if I missed this info in the documentation.
I have a use case where I want my code-generator program to be compiled slightly differently for target platform, host platform, and execution platform by setting different defines.
This is a simplified example of what I’m trying to do. My target is aarch64, so that’s straight forward. My host and execution platforms are the same x86 machine but the CODEGEN_TARGET
define value depends on whether it’s building for host or execution platform.
config_setting(
name = "is_aarch64",
constraint_values = [
"@platforms//cpu:aarch64",
"@platforms//os:linux",
],
)
config_setting(
name = "is_x86_host",
constraint_values = [ <---------------------------------+
"@platforms//cpu:x86", |
"@platforms//os:linux", |
# How to define a host platform ? |
], +---- How to make the distinction between host platform and execution platform?
) |
|
config_setting( |
name = "is_x86_execution", |
constraint_values = [ <---------------------------------+
"@platforms//cpu:x86",
"@platforms//os:linux",
# How to define an execution platform ?
],
)
cc_library(
name = "codeGen",
hdrs = [
"include/codeGen.h",
],
defines = select({
":is_aarch64": ["CODEGEN_TARGET=aarch64"],
":is_x86_execution": ["CODEGEN_TARGET=aarch64"], # <----------------- how do I write a rule that applies to execution platform only?
":is_x86_host": ["CODEGEN_TARGET=x86"],
}),
includes = ["include"],
src = [
"codeGen.cc",
],
)
I’m probably approaching it the wrong way. Any guidance would be appreciated.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Platforms | Bazel
Cross-compilation builds - host and execution platforms are the same, ... Use select() in combination with @platforms//:incompatible to ...
Read more >Please allow remote execution to have its own Platform ...
Bazel currently has the execution platform, which is intended to represent both remote and local execution. You can specify the available ...
Read more >How do I `select` over execution target? - bazel - Stack Overflow
I have the following rule but it isn't working because the select is evaluating target platform instead of host platform or execution ......
Read more >Chapter 3. Configuring and Setting Up Remote Jobs
In the Satellite web UI, navigate to Hosts > All Hosts and select the target host on which you want to execute a...
Read more >Controlling playbook execution: strategies and more
The order keyword controls the order in which hosts are run. Possible values for order are: inventory: (default) The order provided by the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sgowroji The question is how do I write a rule that applies to execution platform only, and another rule for host platform only? Just to clarify, bazel outputs the execution platform binaries to
bazel-out/k8-opt-exec
directory, whereas the host platform binaries go tobazel-out/host
directory.In my pseudo code above, in the
cc_library
section, I want thedefines
toselect
different C macro based on what platform (host or execution) it is compiling it for. The problem that I’m facing is, I can’t make the host/execution distinction in their respectiveconfig_setting
.Closing this pending more information, feel free to re-open or re-file with more details.