-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
replace accesses to cc_toolchain.compiler_executable with calls to cc_toolchain.get_tool_for_action() #274
Changes from 11 commits
aa4802c
1a3a6bf
6baef98
33ad389
35d2090
d297ef0
6d31409
b50e8ad
4745c07
f16c4bd
14bb720
eb5d156
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") | ||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain") | ||
load("//cuda/private:actions/compile.bzl", "compile") | ||
load("//cuda/private:actions/dlink.bzl", "device_link") | ||
load("//cuda/private:cuda_helper.bzl", "cuda_helper") | ||
load("//cuda/private:providers.bzl", "CudaInfo") | ||
load("//cuda/private:rules/common.bzl", "ALLOW_CUDA_HDRS", "ALLOW_CUDA_SRCS") | ||
load("//cuda/private:toolchain.bzl", "find_cuda_toolchain", "use_cpp_toolchain", "use_cuda_toolchain") | ||
load("//cuda/private:toolchain.bzl", "find_cuda_toolchain", "use_cuda_toolchain") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. |
||
|
||
def _cuda_library_impl(ctx): | ||
"""cuda_library is a rule that perform device link. | ||
|
@@ -175,6 +175,6 @@ cuda_library = rule( | |
"_default_cuda_archs": attr.label(default = "//cuda:archs"), | ||
}, | ||
fragments = ["cpp"], | ||
toolchains = use_cpp_toolchain() + use_cuda_toolchain(), | ||
toolchains = use_cpp_toolchain(mandatory = True) + use_cuda_toolchain(), | ||
provides = [DefaultInfo, OutputGroupInfo, CcInfo, CudaInfo], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") | ||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I just now realized what you meant with your first review comment. Just to confirm: we need to use the There's no way I suppose to define this one conditionally on the Bazel version? Not that I necessarily think it would be better, mostly out of curiosity. |
||
load("//cuda/private:actions/compile.bzl", "compile") | ||
load("//cuda/private:cuda_helper.bzl", "cuda_helper") | ||
load("//cuda/private:providers.bzl", "CudaInfo") | ||
load("//cuda/private:rules/common.bzl", "ALLOW_CUDA_HDRS", "ALLOW_CUDA_SRCS") | ||
load("//cuda/private:toolchain.bzl", "find_cuda_toolchain", "use_cpp_toolchain", "use_cuda_toolchain") | ||
load("//cuda/private:toolchain.bzl", "find_cuda_toolchain", "use_cuda_toolchain") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. |
||
|
||
def _cuda_objects_impl(ctx): | ||
attr = ctx.attr | ||
|
@@ -110,6 +110,6 @@ code and device link time optimization source files.""", | |
"_default_cuda_archs": attr.label(default = "//cuda:archs"), | ||
}, | ||
fragments = ["cpp"], | ||
toolchains = use_cpp_toolchain() + use_cuda_toolchain(), | ||
toolchains = use_cpp_toolchain(mandatory = True) + use_cuda_toolchain(), | ||
provides = [DefaultInfo, OutputGroupInfo, CcInfo, CudaInfo], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
load("@bazel_skylib//lib:paths.bzl", "paths") | ||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") | ||
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", CC_ACTION_NAMES = "ACTION_NAMES") | ||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. |
||
load("//cuda/private:action_names.bzl", "ACTION_NAMES") | ||
load("//cuda/private:artifact_categories.bzl", "ARTIFACT_CATEGORIES") | ||
load("//cuda/private:providers.bzl", "CudaToolchainConfigInfo", "CudaToolkitInfo") | ||
load("//cuda/private:toolchain.bzl", "use_cpp_toolchain") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here |
||
load( | ||
"//cuda/private:toolchain_config_lib.bzl", | ||
"action_config", | ||
|
@@ -52,6 +52,13 @@ def _impl(ctx): | |
] | ||
|
||
cc_toolchain = find_cpp_toolchain(ctx) | ||
cc_feature_configuration = cc_common.configure_features( | ||
ctx = ctx, | ||
cc_toolchain = cc_toolchain, | ||
requested_features = ctx.features, | ||
unsupported_features = ctx.disabled_features, | ||
) | ||
host_compiler = cc_common.get_tool_for_action(feature_configuration = cc_feature_configuration, action_name = CC_ACTION_NAMES.cpp_compile) | ||
|
||
clang_compile_env_feature = feature( | ||
name = "clang_compile_env", | ||
|
@@ -64,7 +71,7 @@ def _impl(ctx): | |
], | ||
env_entries = [ | ||
env_entry("INCLUDE", ";".join(cc_toolchain.built_in_include_directories)), | ||
env_entry("PATH", paths.dirname(cc_toolchain.compiler_executable) + ";C:/Windows/system32"), | ||
env_entry("PATH", paths.dirname(host_compiler) + ";C:/Windows/system32"), | ||
], | ||
), | ||
], | ||
|
@@ -508,5 +515,6 @@ cuda_toolchain_config = rule( | |
"_cc_toolchain": attr.label(default = "@bazel_tools//tools/cpp:current_cc_toolchain"), # legacy behaviour | ||
}, | ||
provides = [CudaToolchainConfigInfo], | ||
toolchains = use_cpp_toolchain(), | ||
toolchains = use_cpp_toolchain(mandatory = True), | ||
fragments = ["cpp"], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
load("@bazel_skylib//lib:paths.bzl", "paths") | ||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") | ||
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", CC_ACTION_NAMES = "ACTION_NAMES") | ||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here |
||
load("//cuda/private:action_names.bzl", "ACTION_NAMES") | ||
load("//cuda/private:artifact_categories.bzl", "ARTIFACT_CATEGORIES") | ||
load("//cuda/private:providers.bzl", "CudaToolchainConfigInfo", "CudaToolkitInfo") | ||
load("//cuda/private:toolchain.bzl", "use_cpp_toolchain") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here |
||
load( | ||
"//cuda/private:toolchain_config_lib.bzl", | ||
"action_config", | ||
|
@@ -42,13 +42,20 @@ def _impl(ctx): | |
] | ||
|
||
cc_toolchain = find_cpp_toolchain(ctx) | ||
cc_feature_configuration = cc_common.configure_features( | ||
ctx = ctx, | ||
cc_toolchain = cc_toolchain, | ||
requested_features = ctx.features, | ||
unsupported_features = ctx.disabled_features, | ||
) | ||
host_compiler = cc_common.get_tool_for_action(feature_configuration = cc_feature_configuration, action_name = CC_ACTION_NAMES.cpp_compile) | ||
|
||
nvcc_compile_env_feature = feature( | ||
name = "nvcc_compile_env", | ||
env_sets = [ | ||
env_set( | ||
actions = [ACTION_NAMES.cuda_compile], | ||
env_entries = [env_entry("PATH", paths.dirname(cc_toolchain.compiler_executable))], | ||
env_entries = [env_entry("PATH", paths.dirname(host_compiler))], | ||
), | ||
], | ||
) | ||
|
@@ -58,7 +65,7 @@ def _impl(ctx): | |
env_sets = [ | ||
env_set( | ||
actions = [ACTION_NAMES.device_link], | ||
env_entries = [env_entry("PATH", paths.dirname(cc_toolchain.compiler_executable))], | ||
env_entries = [env_entry("PATH", paths.dirname(host_compiler))], | ||
), | ||
], | ||
) | ||
|
@@ -518,5 +525,6 @@ cuda_toolchain_config = rule( | |
"_cc_toolchain": attr.label(default = "@bazel_tools//tools/cpp:current_cc_toolchain"), # legacy behaviour | ||
}, | ||
provides = [CudaToolchainConfigInfo], | ||
toolchains = use_cpp_toolchain(), | ||
toolchains = use_cpp_toolchain(mandatory = True), | ||
fragments = ["cpp"], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
load("@bazel_skylib//lib:paths.bzl", "paths") | ||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") | ||
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", CC_ACTION_NAMES = "ACTION_NAMES") | ||
load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain", "use_cpp_toolchain") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here |
||
load("//cuda/private:action_names.bzl", "ACTION_NAMES") | ||
load("//cuda/private:artifact_categories.bzl", "ARTIFACT_CATEGORIES") | ||
load("//cuda/private:providers.bzl", "CudaToolchainConfigInfo", "CudaToolkitInfo") | ||
load("//cuda/private:toolchain.bzl", "use_cpp_toolchain") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here |
||
load( | ||
"//cuda/private:toolchain_config_lib.bzl", | ||
"action_config", | ||
|
@@ -43,6 +43,13 @@ def _impl(ctx): | |
] | ||
|
||
cc_toolchain = find_cpp_toolchain(ctx) | ||
cc_feature_configuration = cc_common.configure_features( | ||
ctx = ctx, | ||
cc_toolchain = cc_toolchain, | ||
requested_features = ctx.features, | ||
unsupported_features = ctx.disabled_features, | ||
) | ||
host_compiler = cc_common.get_tool_for_action(feature_configuration = cc_feature_configuration, action_name = CC_ACTION_NAMES.cpp_compile) | ||
|
||
nvcc_compile_env_feature = feature( | ||
name = "nvcc_compile_env", | ||
|
@@ -54,7 +61,7 @@ def _impl(ctx): | |
], | ||
env_entries = [ | ||
env_entry("INCLUDE", ";".join(cc_toolchain.built_in_include_directories)), | ||
env_entry("PATH", paths.dirname(cc_toolchain.compiler_executable) + ";C:/Windows/system32"), | ||
env_entry("PATH", paths.dirname(host_compiler) + ";C:/Windows/system32"), | ||
env_entry("TEMP", ctx.attr.msvc_env_tmp), | ||
env_entry("TMP", ctx.attr.msvc_env_tmp), | ||
], | ||
|
@@ -430,8 +437,6 @@ def _impl(ctx): | |
], | ||
) | ||
|
||
static_link_msvcrt_feature = feature(name = "static_link_msvcrt") | ||
|
||
static_link_msvcrt_debug_feature = feature( | ||
name = "static_link_msvcrt_debug", | ||
flag_sets = [ | ||
|
@@ -608,5 +613,6 @@ cuda_toolchain_config = rule( | |
"_cc_toolchain": attr.label(default = "@bazel_tools//tools/cpp:current_cc_toolchain"), # legacy behaviour | ||
}, | ||
provides = [CudaToolchainConfigInfo], | ||
toolchains = use_cpp_toolchain(), | ||
toolchains = use_cpp_toolchain(mandatory = True), | ||
fragments = ["cpp"], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot to revert these changes