Skip to content

Commit

Permalink
[7.4.0] Fix ml path for Windows clang-cl cc toolchain (bazelbuild#23406)
Browse files Browse the repository at this point in the history
Assembly files are not valid inputs for `clang-cl.exe`; the MSVC
`ml64.exe` must be used instead.

Fixes bazelbuild#23128.

Closes bazelbuild#23337.

PiperOrigin-RevId: 666406544
Change-Id: Ia7a5fc4702f08a5754145ca286c079d1a4f0e204

Commit
bazelbuild@e5a083d

---------

Co-authored-by: Michael Siegrist <[email protected]>
  • Loading branch information
iancha1992 and michaelsiegrist authored Aug 28, 2024
1 parent 7b10b8b commit cb1bc28
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 21 deletions.
75 changes: 55 additions & 20 deletions src/test/py/bazel/bazel_windows_cpp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,26 +775,61 @@ def testBuildWithClangClByToolchainResolution(self):
' "@local_config_cc//:cc-toolchain-x64_windows-clang-cl",',
')',
])
self.ScratchFile('BUILD', [
'platform(',
' name = "windows_clang",',
' constraint_values = [',
' "@platforms//cpu:x86_64",',
' "@platforms//os:windows",',
' "@bazel_tools//tools/cpp:clang-cl",',
' ]',
')',
'',
'cc_binary(',
' name = "main",',
' srcs = ["main.cc"],',
')',
])
self.ScratchFile('main.cc', [
'int main() {',
' return 0;',
'}',
])
self.ScratchFile(
'BUILD',
[
'platform(',
' name = "windows_clang",',
' constraint_values = [',
' "@platforms//cpu:x86_64",',
' "@platforms//os:windows",',
' "@bazel_tools//tools/cpp:clang-cl",',
' ]',
')',
'',
'cc_binary(',
' name = "main",',
' srcs = [ "main.cc",',
' "inc.asm",', # Test assemble action_config
' "dec.S",', # Test preprocess-assemble action_config
' ],',
')',
],
)
self.ScratchFile(
'main.cc',
[
'int main() {',
' return 0;',
'}',
],
)
self.ScratchFile(
'inc.asm',
[
'.code',
'PUBLIC increment',
'increment PROC x:WORD',
' xchg rcx,rax',
' inc rax',
' ret',
'increment EndP',
'END',
],
)
self.ScratchFile(
'dec.S',
[
'.code',
'PUBLIC decrement',
'decrement PROC x:WORD',
' xchg rcx,rax',
' dec rax',
' ret',
'decrement EndP',
'END',
],
)
exit_code, _, stderr = self.RunBazel([
'build', '-s', '--incompatible_enable_cc_toolchain_resolution=true',
'//:main'
Expand Down
3 changes: 2 additions & 1 deletion tools/cpp/windows_cc_configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,8 @@ def _get_clang_cl_vars(repository_ctx, paths, msvc_vars, target_arch):
"%{clang_cl_cl_path_" + target_arch + "}": clang_cl_path,
"%{clang_cl_link_path_" + target_arch + "}": lld_link_path,
"%{clang_cl_lib_path_" + target_arch + "}": llvm_lib_path,
"%{clang_cl_ml_path_" + target_arch + "}": clang_cl_path,
# clang-cl does not support assembly files as input.
"%{clang_cl_ml_path_" + target_arch + "}": msvc_vars["%{msvc_ml_path_" + target_arch + "}"],
# LLVM's lld-link.exe doesn't support /DEBUG:FASTLINK.
"%{clang_cl_dbg_mode_debug_flag_" + target_arch + "}": "/DEBUG",
"%{clang_cl_fastbuild_mode_debug_flag_" + target_arch + "}": "/DEBUG",
Expand Down

0 comments on commit cb1bc28

Please sign in to comment.