Closed michaelsiegrist closed 2 weeks ago
It looks like this can indeed be fixed by changing the paths for both msvc_ml_path
and tool_paths["ml"]
to use the path to ml64.exe
from the MSVC installation. Since MSVC needs to be available anyway for the clang-cl toolchain to work, that seems like a doable change, I believe.
Here is a attached a modified version of the test, but this time with a modified version of @local_config_cc//:clang_cl_x64
with the paths updated, and it appears to work just fine now (note that the same warnings appear when using the MSVC toolchain, so they are orthogonal to this issue).
>bazel build //...
INFO: Analyzed 3 targets (79 packages loaded, 2890 targets configured).
INFO: From Compiling external/rules_boost~override~non_module_dependencies~boost/libs/context/src/asm/ontop_x86_64_ms_pe_masm.S:
MASM : warning A4018:invalid command-line option : /bigobj
MASM : warning A4018:invalid command-line option : /Zm500
MASM : warning A4018:invalid command-line option : /Z500
MASM : warning A4018:invalid command-line option : /Z00
MASM : warning A4018:invalid command-line option : /Z0
MASM : warning A4018:invalid command-line option : /EHsc
MASM : warning A4018:invalid command-line option : /wd4351
MASM : warning A4018:invalid command-line option : /wd4291
MASM : warning A4018:invalid command-line option : /wd4250
MASM : warning A4018:invalid command-line option : /wd4996
MASM : warning A4018:invalid command-line option : /showIncludes
Assembling: bazel-out/x64_windows-fastbuild/bin/external/rules_boost~override~non_module_dependencies~boost/libs/context/src/asm/ontop_x86_64_ms_pe_masm.S
INFO: From Compiling external/rules_boost~override~non_module_dependencies~boost/libs/context/src/asm/jump_x86_64_ms_pe_masm.S:
MASM : warning A4018:invalid command-line option : /bigobj
MASM : warning A4018:invalid command-line option : /Zm500
MASM : warning A4018:invalid command-line option : /Z500
MASM : warning A4018:invalid command-line option : /Z00
MASM : warning A4018:invalid command-line option : /Z0
MASM : warning A4018:invalid command-line option : /EHsc
MASM : warning A4018:invalid command-line option : /wd4351
MASM : warning A4018:invalid command-line option : /wd4291
MASM : warning A4018:invalid command-line option : /wd4250
MASM : warning A4018:invalid command-line option : /wd4996
MASM : warning A4018:invalid command-line option : /showIncludes
Assembling: bazel-out/x64_windows-fastbuild/bin/external/rules_boost~override~non_module_dependencies~boost/libs/context/src/asm/jump_x86_64_ms_pe_masm.S
INFO: From Compiling external/rules_boost~override~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S:
MASM : warning A4018:invalid command-line option : /bigobj
MASM : warning A4018:invalid command-line option : /Zm500
MASM : warning A4018:invalid command-line option : /Z500
MASM : warning A4018:invalid command-line option : /Z00
MASM : warning A4018:invalid command-line option : /Z0
MASM : warning A4018:invalid command-line option : /EHsc
MASM : warning A4018:invalid command-line option : /wd4351
MASM : warning A4018:invalid command-line option : /wd4291
MASM : warning A4018:invalid command-line option : /wd4250
MASM : warning A4018:invalid command-line option : /wd4996
MASM : warning A4018:invalid command-line option : /showIncludes
Assembling: bazel-out/x64_windows-fastbuild/bin/external/rules_boost~override~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S
INFO: Found 3 targets...
INFO: Elapsed time: 8.296s, Critical Path: 2.15s
INFO: 12 processes: 4 internal, 8 local.
INFO: Build completed successfully, 12 total actions
Note that my system has MSVC and LLVM installed into non-default locations, so the paths will likely need to be adjusted for other machines. However, the principle is the same.
Would you be interested in sending a PR?
Sure, I'll try to have something up soon.
Description of the bug:
When compiling a
cc_library
with assembly (.S
) files as input, the@local_config_cc//:cc-toolchain-x64_windows-clang-cl
toolchain selectsclang-cl.exe
as the executable. However,clang-cl
is not intended to handle assembly; as withcl.exe
from the MSVC toolchain, it only accepts C/C++ code as input.Comparing the Windows clang-cl and MSVC toolchains, it looks like the MSVC toolchain properly selects
ml64.exe
for assembly files, but the clang-cl toolchain usesclang-cl
.MSVC toolchain,
tool_paths["ml"] = "C:/Tools/ms/vs/2022/17.4.11/VC/Tools/MSVC/14.34.31933/bin/HostX64/x64/ml64.exe"
:Clang-cl toolchain,
tool_paths["ml"] = "C:/Tools/llvm/16.0.2/bin/clang-cl.exe"
:It seems that the clang-cl toolchain should also be using
ml64.exe
or perhapsllvm-as
to properly compile assembly files.Which category does this issue belong to?
C++ Rules
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
bazel-test.zip
The example contains a single
cc_library()
target//:test
that depends on@boost//:context
, which in turn has some pre-generated assembly files listed in itssrcs
. The project is configured to use the Windows clang-cl toolchain described in the Bazel Windows documentation. After setting%BAZEL_VC%
and%BAZEL_LLVM%
to the appropriate paths (MSVC version 17.4.11 and LLVM 16.0.2), I compile and get the following:Looking at the params file used for the compilation shows the following:
Which operating system are you running Bazel on?
Windows Server 2016
What is the output of
bazel info release
?release 7.0.0
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?No response
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
No response
Have you found anything relevant by searching the web?
According to this SO answer,
cl.exe
does not support compiling assembly;ml64.exe
is needed for that.Any other information, logs, or outputs that you want to share?
No response