question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Select on host platform and execution platform

See original GitHub issue

First 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:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jasawcommented, Aug 5, 2022

@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 to bazel-out/host directory.

In my pseudo code above, in the cc_library section, I want the defines to select 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 respective config_setting.

0reactions
katrecommented, Sep 19, 2022

Closing this pending more information, feel free to re-open or re-file with more details.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found