Skip to content

Commit

Permalink
Set clang compiler options for the compiler that has "clang" in the p…
Browse files Browse the repository at this point in the history
…ath.

`cc.endswith("clang")` ddidn't work for the cases when the clang compiler path is like `/usr/bin/clang-18`.

This change addresses [Github issue](jax-ml/jax#23689).

PiperOrigin-RevId: 694536448
  • Loading branch information
tensorflower-gardener authored and copybara-github committed Nov 8, 2024
1 parent 9f195c2 commit dab6f0a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions third_party/gpus/cuda/hermetic/cuda_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,13 @@ def _setup_toolchains(repository_ctx, cc, cuda_version):
})

cuda_defines["%{builtin_sysroot}"] = tf_sysroot
is_clang_compiler = "clang" in cc
if not enable_cuda(repository_ctx):
cuda_defines["%{cuda_toolkit_path}"] = ""
cuda_defines["%{cuda_nvcc_files}"] = "[]"
nvcc_relative_path = ""
else:
if cc.endswith("clang"):
if is_clang_compiler:
cuda_defines["%{cuda_toolkit_path}"] = repository_ctx.attr.nvcc_binary.workspace_root
else:
cuda_defines["%{cuda_toolkit_path}"] = ""
Expand All @@ -306,7 +307,7 @@ def _setup_toolchains(repository_ctx, cc, cuda_version):
repository_ctx.attr.nvcc_binary.workspace_root,
repository_ctx.attr.nvcc_binary.name,
)
if cc.endswith("clang"):
if is_clang_compiler:
cuda_defines["%{compiler}"] = "clang"
cuda_defines["%{extra_no_canonical_prefixes_flags}"] = ""
cuda_defines["%{cxx_builtin_include_directories}"] = to_list_of_strings(
Expand Down Expand Up @@ -348,7 +349,7 @@ def _setup_toolchains(repository_ctx, cc, cuda_version):
"%{cuda_version}": cuda_version,
"%{nvcc_path}": nvcc_relative_path,
"%{host_compiler_path}": str(cc),
"%{use_clang_compiler}": str(cc.endswith("clang")),
"%{use_clang_compiler}": str(is_clang_compiler),
"%{tmpdir}": get_host_environ(
repository_ctx,
_TMPDIR,
Expand Down Expand Up @@ -454,7 +455,7 @@ def _create_local_cuda_repository(repository_ctx):
"%{cuda_is_configured}": "True",
"%{cuda_extra_copts}": _compute_cuda_extra_copts(
cuda_config.compute_capabilities,
cc.endswith("clang"),
"clang" in cc,
),
"%{cuda_gpu_architectures}": str(cuda_config.compute_capabilities),
"%{cuda_version}": cuda_config.cuda_version,
Expand Down

0 comments on commit dab6f0a

Please sign in to comment.