-
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
toolchain tool_paths should accept labels #8438
Comments
This is not a configuration issue, it is part of cc toolchain definition. |
Note: It should also provide a way to reference directories (for include paths for example). |
CC @scentini |
May I add to this issue that a lot of rule have |
You should file that as a separate issue, so that it can be separately triaged and tracked. |
@katre done. Considering that I've opened this issue 6 months and that nobody seems interested to at least discuss it, I'm wondering if I may not be doing something totally wrong. If we stay on the topic of setting Right now I'm cheating this way:
This is painful because I need to ensure that the first step is reproducible by myself, a job I'd like bazel to do for me. |
I'm sorry this got missed and wasn't handled. I actually don't know the details of how to specify cc toolchains, so I've re-marked this as "untriaged" to get the attention of the CPP rules team. Sorry this has been frustrating. You might consider asking on bazel-discuss@ how other users have handled this problem. |
@guibou Did you find out how other users handle this problem? We have the same problem. For one of our toolchains, we want to download the SDK and use the compiler and linker paths in the toolchain definition. We know the labels to these tools, but how do we convert them to paths? |
This seems at least somewhat related to #7746. The source code says that tool_path is deprecated, and instead action_config / tool should be used. tool() of course has the same issue, but it's quite a bit easier to modify the tool/ToolInfo and the underlying java code to accept a File/Artifact object. I played around with this a little the last day or so and I have something working that works for me to accept labels in action_config/tool settings. It needs some work to play nicely with the protobuf serialization/deserialization, but it's something at least. Hoping to get some guidance in #7746 and then I'll submit a pull request. |
There are two possible partial workarounds to @emusand 's problem as of now. They only work for files in the repo so they are not solutions for the original issue.
|
I believe the first workaround breaks the configure_make rule: https://github.com/bazelbuild/rules_foreign_cc/blob/master/tools/build_defs/configure.bzl configure is not invoked from execroot, as I see it's invoked from a temp directory under /tmp/. |
This change adds an optional field to the C++ crosstool proto that allows configuring the origin tool_path is relative to. For now, the origin can be one of the following: - CROSSTOOL_PACKAGE: If tool_path is a relative path, it's assumed to be relative to the package of the crosstool top. - FILESYSTEM_ROOT: tool_path is an absolute path. This is checked by Bazel. - WORKSPACE_ROOT: tool_path must be a relative path and is assumed to be relative to the exec-root of the workspace (similar to other executables). Updates bazelbuild#8438
This change adds an optional field to the C++ crosstool proto that allows configuring the origin tool_path is relative to. For now, the origin can be one of the following: - CROSSTOOL_PACKAGE: If tool_path is a relative path, it's assumed to be relative to the package of the crosstool top. - FILESYSTEM_ROOT: tool_path is an absolute path. This is checked by Bazel. - WORKSPACE_ROOT: tool_path must be a relative path and is assumed to be relative to the exec-root of the workspace (similar to other executables). Updates bazelbuild#8438
This change adds an optional field to the C++ crosstool proto that allows configuring the origin tool_path is relative to. For now, the origin can be one of the following: - CROSSTOOL_PACKAGE: If tool_path is a relative path, it's assumed to be relative to the package of the crosstool top. - FILESYSTEM_ROOT: tool_path is an absolute path. This is checked by Bazel. - WORKSPACE_ROOT: tool_path must be a relative path and is assumed to be relative to the exec-root of the workspace (similar to other executables). Updates bazelbuild#8438
This change adds an optional field to the C++ crosstool proto that allows configuring the origin tool_path is relative to. For now, the origin can be one of the following: - CROSSTOOL_PACKAGE: If tool_path is a relative path, it's assumed to be relative to the package of the crosstool top. - FILESYSTEM_ROOT: tool_path is an absolute path. This is checked by Bazel. - WORKSPACE_ROOT: tool_path must be a relative path and is assumed to be relative to the exec-root of the workspace (similar to other executables). Updates bazelbuild/bazel#8438 Closes #10967. PiperOrigin-RevId: 310142352 Change-Id: If6316ffa5d7d2713b197840b4aafb2f0cdbb0b96
This change adds an optional field to the C++ crosstool proto that allows configuring the origin tool_path is relative to. For now, the origin can be one of the following: - CROSSTOOL_PACKAGE: If tool_path is a relative path, it's assumed to be relative to the package of the crosstool top. - FILESYSTEM_ROOT: tool_path is an absolute path. This is checked by Bazel. - WORKSPACE_ROOT: tool_path must be a relative path and is assumed to be relative to the exec-root of the workspace (similar to other executables). Updates #8438 Closes #10967. PiperOrigin-RevId: 310142352
@emusand there is a mapping between label and path for external rules. For example, if your |
@emusand and when it does not work because your package is not loaded in the sandbox, I'm writing the absolute path of my binary. I wrote a few automated process which are generating on the fly |
Is there a resolution for the "first workaround", i.e using wrappers around the tools. Indeed, when building
I can successfully build simple |
I hit the same error while building with rules_foreign_cc and my custom gcc toolchain. This example from https://github.com/grailbio/bazel-toolchain might help you. |
That can be converted to:
Please let me know if there is anything about that will make it not work for your use case. |
... so we can rely on actual File objects, not relative paths. This change allows the deletion of the kleaf/parent symlinks later. This change is in response to bazelbuild/bazel#8438 (comment) Test: TH Bug: bazelbuild/bazel#8438 Bug: 280012530 Change-Id: Ie9846847167e5a0c2b1cb1dde5a7c82a17cd3862
... so we can rely on actual File objects, not relative paths. This change allows the deletion of the kleaf/parent symlinks later. This change is in response to bazelbuild/bazel#8438 (comment) Test: TH Bug: bazelbuild/bazel#8438 Bug: 280012530 Change-Id: Ie9846847167e5a0c2b1cb1dde5a7c82a17cd3862
@oquenchil Also running into this issue trying to use an executable from a different external repository than the one my toolchain is configured in. And trying to follow your advice about using action_configs instead of tool_paths: I have a custom rule which uses the CcToolchainInfo to find various executables in the toolchain. But it seems like the only way to populate these values is by using Is there a way to access the Example custom rule:
|
Not sure I understand the problem completely. Have you seen get_tool_for_action? If you specify the right action config in the toolchain that method should give you the correct path. |
Thanks @oquenchil, |
Do you have a custom toolchain? The presence of the constant in action_names.bzl shouldn't matter since you can just use the string directly but the action_config needs to be configured in the toolchain so if you are using the default toolchain you are out of luck because it was introduced after the 6.0 cut, see here. If this is important to you, you can ask for that commit to be cherrypicked into 6.4.0. It won't break anything. |
That's correct, I'd expect this to work as long as the |
... so we can rely on actual File objects, not relative paths. This change allows the deletion of the kleaf/parent symlinks later. This change is in response to bazelbuild/bazel#8438 (comment) Test: TH Bug: bazelbuild/bazel#8438 Bug: 280012530 Change-Id: Ie9846847167e5a0c2b1cb1dde5a7c82a17cd3862
... so we can rely on actual File objects, not relative paths. This change allows the deletion of the kleaf/parent symlinks later. This change is in response to bazelbuild/bazel#8438 (comment) Test: TH Bug: bazelbuild/bazel#8438 Bug: 280012530 Change-Id: Ie9846847167e5a0c2b1cb1dde5a7c82a17cd3862
... so we can rely on actual File objects, not relative paths. This change allows the deletion of the kleaf/parent symlinks later. This change is in response to bazelbuild/bazel#8438 (comment) Test: TH Bug: bazelbuild/bazel#8438 Bug: 280012530 Change-Id: Ie9846847167e5a0c2b1cb1dde5a7c82a17cd3862
... so we can rely on actual File objects, not relative paths. This change allows the deletion of the kleaf/parent symlinks later. This change is in response to bazelbuild/bazel#8438 (comment) Test: TH Bug: bazelbuild/bazel#8438 Bug: 280012530 Change-Id: Ie9846847167e5a0c2b1cb1dde5a7c82a17cd3862
... so we can rely on actual File objects, not relative paths. This change allows the deletion of the kleaf/parent symlinks later. This change is in response to bazelbuild/bazel#8438 (comment) Test: TH Bug: bazelbuild/bazel#8438 Bug: 280012530 Change-Id: Ie9846847167e5a0c2b1cb1dde5a7c82a17cd3862
... so we can rely on actual File objects, not relative paths. This change allows the deletion of the kleaf/parent symlinks later. This change is in response to bazelbuild/bazel#8438 (comment) Test: TH Bug: bazelbuild/bazel#8438 Bug: 280012530 Change-Id: Ie9846847167e5a0c2b1cb1dde5a7c82a17cd3862
... so we can rely on actual File objects, not relative paths. This change allows the deletion of the kleaf/parent symlinks later. This change is in response to bazelbuild/bazel#8438 (comment) Test: TH Bug: bazelbuild/bazel#8438 Bug: 280012530 Change-Id: Ie9846847167e5a0c2b1cb1dde5a7c82a17cd3862
... so we can rely on actual File objects, not relative paths. This change allows the deletion of the kleaf/parent symlinks later. This change is in response to bazelbuild/bazel#8438 (comment) Test: TH Bug: bazelbuild/bazel#8438 Bug: 280012530 Change-Id: Ie9846847167e5a0c2b1cb1dde5a7c82a17cd3862
Description of the problem / feature request:
toolchain confiuration
cc_common.create_cc_toolchain_config_info
attributestool_paths
/path
should accept bazel labels.Feature requests: what underlying problem are you trying to solve with this feature?
The current status (in bazel 0.25) is that toolchain configuration info attributes for tool paths only accept local or absolute paths, but not bazel label.
That's not convenient if your tools comes from another (possibly repository) rule because you need to generate the path by yourself (I don't even know how bazel correctly knows it had to build the dependent rule before).
Example of what I'd like to do:
What operating system are you running Bazel on?
Linux
What's the output of
bazel info release
?release bazel-0.25-2
The text was updated successfully, but these errors were encountered: