Skip to content

Commit

Permalink
[6.4.0] Wrong include path to Clang 16 on Windows (bazelbuild#19430)
Browse files Browse the repository at this point in the history
Clang install on Windows started using just the major version number in
the install path rather than the full version number.

Fixes bazelbuild#17863

Closes bazelbuild#19391.

Commit
bazelbuild@0377bad

PiperOrigin-RevId: 562480023
Change-Id: Iebd5d3cedff48739747fa8668d56ff8f1d9350b9

Co-authored-by: Orion Hodson <[email protected]>
  • Loading branch information
2 people authored and keith committed Sep 8, 2023
1 parent e511aa4 commit ac05837
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tools/cpp/windows_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,18 @@ def _get_clang_version(repository_ctx, clang_cl):
auto_configure_fail("Failed to get clang version by running \"%s -v\"" % clang_cl)
return first_line.split(" ")[-1]

def _get_clang_dir(repository_ctx, llvm_path, clang_version):
"""Get the clang installation directory."""

# The clang_version string format is "X.X.X"
clang_dir = llvm_path + "\\lib\\clang\\" + clang_version
if repository_ctx.path(clang_dir).exists:
return clang_dir

# Clang 16 changed the install path to use just the major number.
clang_major_version = clang_version.split(".")[0]
return llvm_path + "\\lib\\clang\\" + clang_major_version

def _get_msys_mingw_vars(repository_ctx):
"""Get the variables we need to populate the msys/mingw toolchains."""
tool_paths, tool_bin_path, inc_dir_msys = _get_escaped_windows_msys_starlark_content(repository_ctx)
Expand Down Expand Up @@ -658,7 +670,7 @@ def _get_msvc_vars(repository_ctx, paths, target_arch = "x64", msvc_vars_x64 = N
escaped_cxx_include_directories.append("\"%s\"" % path)
if llvm_path:
clang_version = _get_clang_version(repository_ctx, build_tools["CL"])
clang_dir = llvm_path + "\\lib\\clang\\" + clang_version
clang_dir = _get_clang_dir(repository_ctx, llvm_path, clang_version)
clang_include_path = (clang_dir + "\\include").replace("\\", "\\\\")
escaped_cxx_include_directories.append("\"%s\"" % clang_include_path)
clang_lib_path = (clang_dir + "\\lib\\windows").replace("\\", "\\\\")
Expand Down Expand Up @@ -734,7 +746,7 @@ def _get_clang_cl_vars(repository_ctx, paths, msvc_vars, target_arch):
llvm_lib_path = find_llvm_tool(repository_ctx, llvm_path, "llvm-lib.exe")

clang_version = _get_clang_version(repository_ctx, clang_cl_path)
clang_dir = llvm_path + "\\lib\\clang\\" + clang_version
clang_dir = _get_clang_dir(repository_ctx, llvm_path, clang_version)
clang_include_path = (clang_dir + "\\include").replace("\\", "\\\\")
clang_lib_path = (clang_dir + "\\lib\\windows").replace("\\", "\\\\")

Expand Down

0 comments on commit ac05837

Please sign in to comment.