bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
22.96k stars 4.02k forks source link

Wrong assembler selected for @local_config_cc//:cc-toolchain-x64_windows-clang-cl #23128

Closed michaelsiegrist closed 2 weeks ago

michaelsiegrist commented 1 month ago

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 selects clang-cl.exe as the executable. However, clang-cl is not intended to handle assembly; as with cl.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 uses clang-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":

>bazel query --output=build @local_config_cc//:msvc_x64
# C:/users/siegrist/_bazel_siegrist/njqmoezo/external/local_config_cc/BUILD:217:20
cc_toolchain_config(
  name = "msvc_x64",
  cpu = "x64_windows",
  compiler = "msvc-cl",
  toolchain_identifier = "msvc_x64",
  host_system_name = "local",
  target_system_name = "local",
  target_libc = "msvcrt",
  abi_version = "local",
  abi_libc_version = "local",
  tool_paths = {"ar": "C:/Tools/ms/vs/2022/17.4.11/VC/Tools/MSVC/14.34.31933/bin/HostX64/x64/lib.exe", "ml": "C:/Tools/ms/vs/2022/17.4.11/VC/Tools/MSVC/14.34.31933/bin/HostX64/x64/ml64.exe", "cpp": "C:/Tools/ms/vs/2022/17.4.11/VC/Tools/MSVC/14.34.31933/bin/HostX64/x64/cl.exe", "gcc": "C:/Tools/ms/vs/2022/17.4.11/VC/Tools/MSVC/14.34.31933/bin/HostX64/x64/cl.exe", "gcov": "wrapper/bin/msvc_nop.bat", "ld": "C:/Tools/ms/vs/2022/17.4.11/VC/Tools/MSVC/14.34.31933/bin/HostX64/x64/link.exe", "nm": "wrapper/bin/msvc_nop.bat", "objcopy": "wrapper/bin/msvc_nop.bat", "objdump": "wrapper/bin/msvc_nop.bat", "strip": "wrapper/bin/msvc_nop.bat"},
  cxx_builtin_include_directories = ["C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\include", "C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\ATLMFC\\include", "C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Auxiliary\\VS\\include", "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.22000.0\\ucrt", "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\um", "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\shared", "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\winrt", "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\cppwinrt", "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um"],
  archiver_flags = ["/MACHINE:X64"],
  default_link_flags = ["/MACHINE:X64"],
  msvc_env_tmp = "C:\\Users\\siegrist\\AppData\\Local\\Temp\\3",
  msvc_env_path = "C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX64\\x64;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\VC\\VCPackages;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer;C:\\Tools\\ms\\vs\\2022\\17.4.11\\MSBuild\\Current\\bin\\Roslyn;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Team Tools\\Performance Tools\\x64;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Team Tools\\Performance Tools;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\x64\\;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.22000.0\\\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\\\x64;C:\\Tools\\ms\\vs\\2022\\17.4.11\\\\MSBuild\\Current\\Bin\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\Tools\\;;C:\\Windows\\system32;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\Ninja;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\VC\\Linux\\bin\\ConnectionManagerExe",
  msvc_env_include = "C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\include;C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\ATLMFC\\include;C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Auxiliary\\VS\\include;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.22000.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\um;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\shared;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\winrt;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\cppwinrt;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um",
  msvc_env_lib = "C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\ATLMFC\\lib\\x64;C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\lib\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.22000.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\\\lib\\10.0.22000.0\\\\um\\x64",
  msvc_cl_path = "C:/Tools/ms/vs/2022/17.4.11/VC/Tools/MSVC/14.34.31933/bin/HostX64/x64/cl.exe",
  msvc_ml_path = "C:/Tools/ms/vs/2022/17.4.11/VC/Tools/MSVC/14.34.31933/bin/HostX64/x64/ml64.exe",
  msvc_link_path = "C:/Tools/ms/vs/2022/17.4.11/VC/Tools/MSVC/14.34.31933/bin/HostX64/x64/link.exe",
  msvc_lib_path = "C:/Tools/ms/vs/2022/17.4.11/VC/Tools/MSVC/14.34.31933/bin/HostX64/x64/lib.exe",
  dbg_mode_debug_flag = "/DEBUG:FULL",
  fastbuild_mode_debug_flag = "/DEBUG:FASTLINK",
  supports_parse_showincludes = True,
)
# Rule msvc_x64 instantiated at (most recent call last):
#   C:/users/siegrist/_bazel_siegrist/njqmoezo/external/local_config_cc/BUILD:217:20 in <toplevel>
# Rule cc_toolchain_config defined at (most recent call last):
#   C:/users/siegrist/_bazel_siegrist/njqmoezo/external/local_config_cc/windows_cc_toolchain_config.bzl:1414:27 in <toplevel>

Clang-cl toolchain, tool_paths["ml"] = "C:/Tools/llvm/16.0.2/bin/clang-cl.exe":

>bazel query --output=build @local_config_cc//:clang_cl_x64
# C:/users/siegrist/_bazel_siegrist/njqmoezo/external/local_config_cc/BUILD:501:20
cc_toolchain_config(
  name = "clang_cl_x64",
  cpu = "x64_windows",
  compiler = "clang-cl",
  toolchain_identifier = "clang_cl_x64",
  host_system_name = "local",
  target_system_name = "local",
  target_libc = "msvcrt",
  abi_version = "local",
  abi_libc_version = "local",
  tool_paths = {"ar": "C:/Tools/llvm/16.0.2/bin/llvm-lib.exe", "ml": "C:/Tools/llvm/16.0.2/bin/clang-cl.exe", "cpp": "C:/Tools/llvm/16.0.2/bin/clang-cl.exe", "gcc": "C:/Tools/llvm/16.0.2/bin/clang-cl.exe", "gcov": "wrapper/bin/msvc_nop.bat", "ld": "C:/Tools/llvm/16.0.2/bin/lld-link.exe", "nm": "wrapper/bin/msvc_nop.bat", "objcopy": "wrapper/bin/msvc_nop.bat", "objdump": "wrapper/bin/msvc_nop.bat", "strip": "wrapper/bin/msvc_nop.bat"},
  cxx_builtin_include_directories = ["C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\include", "C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\ATLMFC\\include", "C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Auxiliary\\VS\\include", "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.22000.0\\ucrt", "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\um", "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\shared", "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\winrt", "C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\cppwinrt", "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um", "C:\\Tools\\llvm\\16.0.2\\lib\\clang\\16\\include"],
  archiver_flags = ["/MACHINE:X64"],
  default_link_flags = ["/MACHINE:X64"],
  msvc_env_tmp = "C:\\Users\\siegrist\\AppData\\Local\\Temp\\3",
  msvc_env_path = "C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX64\\x64;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\VC\\VCPackages;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\CommonExtensions\\Microsoft\\TestWindow;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer;C:\\Tools\\ms\\vs\\2022\\17.4.11\\MSBuild\\Current\\bin\\Roslyn;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Team Tools\\Performance Tools\\x64;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Team Tools\\Performance Tools;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v10.0A\\bin\\NETFX 4.8 Tools\\x64\\;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.22000.0\\\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\\\x64;C:\\Tools\\ms\\vs\\2022\\17.4.11\\\\MSBuild\\Current\\Bin\\amd64;C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\Tools\\;;C:\\Windows\\system32;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\Ninja;C:\\Tools\\ms\\vs\\2022\\17.4.11\\Common7\\IDE\\VC\\Linux\\bin\\ConnectionManagerExe",
  msvc_env_include = "C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\include;C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\ATLMFC\\include;C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Auxiliary\\VS\\include;C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.22000.0\\ucrt;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\um;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\shared;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\winrt;C:\\Program Files (x86)\\Windows Kits\\10\\\\include\\10.0.22000.0\\\\cppwinrt;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\include\\um;C:\\Tools\\llvm\\16.0.2\\lib\\clang\\16\\include",
  msvc_env_lib = "C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\ATLMFC\\lib\\x64;C:\\Tools\\ms\\vs\\2022\\17.4.11\\VC\\Tools\\MSVC\\14.34.31933\\lib\\x64;C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.8\\lib\\um\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.22000.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\\\lib\\10.0.22000.0\\\\um\\x64;C:\\Tools\\llvm\\16.0.2\\lib\\clang\\16\\lib\\windows",
  msvc_cl_path = "C:/Tools/llvm/16.0.2/bin/clang-cl.exe",
  msvc_ml_path = "C:/Tools/llvm/16.0.2/bin/clang-cl.exe",
  msvc_link_path = "C:/Tools/llvm/16.0.2/bin/lld-link.exe",
  msvc_lib_path = "C:/Tools/llvm/16.0.2/bin/llvm-lib.exe",
  dbg_mode_debug_flag = "/DEBUG",
  fastbuild_mode_debug_flag = "/DEBUG",
  supports_parse_showincludes = True,
)
# Rule clang_cl_x64 instantiated at (most recent call last):
#   C:/users/siegrist/_bazel_siegrist/njqmoezo/external/local_config_cc/BUILD:501:20 in <toplevel>
# Rule cc_toolchain_config defined at (most recent call last):
#   C:/users/siegrist/_bazel_siegrist/njqmoezo/external/local_config_cc/windows_cc_toolchain_config.bzl:1414:27 in <toplevel>

It seems that the clang-cl toolchain should also be using ml64.exe or perhaps llvm-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 its srcs. 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:

>bazel build -j 1 //...
INFO: Analyzed target //:test (0 packages loaded, 0 targets configured).
ERROR: C:/users/siegrist/_bazel_siegrist/njqmoezo/external/rules_boost~~non_module_dependencies~boost/BUILD.bazel:144:14: Compiling external/rules_boost~~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S failed: (Exit 1): clang-cl.exe failed: error executing CppCompile command (from target @@rules_boost~~non_module_dependencies~boost//:context) C:\Tools\llvm\16.0.2\bin\clang-cl.exe @bazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/_objs/context/make_x86_64_ms_pe_masm.obj.params
bazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S:2:20: error: unexpected token in argument list
; Copyright Oliver Kowalke 2009.
                   ^
bazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S:3:21: error: unexpected token in argument list
; Distributed under the Boost Software License, Version 1.0.
                    ^
bazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S:4:3: error: unexpected token at start of statement
; (See accompanying file LICENSE_1_0.txt or copy at
  ^
bazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S:7:3: error: unexpected token at start of statement
; ----------------------------------------------------------------------------------
  ^
bazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S:8:3: error: unexpected token at start of statement
; | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  ^

<.... snip ...>

bazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S:159:7: error: invalid instruction mnemonic 'exit'
    ; exit application
      ^~~~
bazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S:162:1: error: invalid instruction mnemonic 'make_fcontext'
make_fcontext ENDP
^~~~~~~~~~~~~
bazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S:163:1: error: invalid instruction mnemonic 'end'
END
^~~
Target //:test failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 4.117s, Critical Path: 1.64s
INFO: 3 processes: 2 internal, 1 local.
ERROR: Build did NOT complete successfully

Looking at the params file used for the compilation shows the following:

>type "bazel-out\x64_windows-fastbuild\bin\external\rules_boost~~non_module_dependencies~boost\_objs\context\make_x86_64_ms_pe_masm.obj.params"
/nologo
/DCOMPILER_MSVC
/DNOMINMAX
/D_WIN32_WINNT=0x0601
/D_CRT_SECURE_NO_DEPRECATE
/D_CRT_SECURE_NO_WARNINGS
/bigobj
/Zm500
/EHsc
/wd4351
/wd4291
/wd4250
/wd4996
/Iexternal/rules_boost~~non_module_dependencies~boost
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/context/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/context/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/assert/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/assert/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/current_function/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/current_function/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/config/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/config/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/cstdint/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/cstdint/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/limits/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/limits/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/detail/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/detail/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/winapi/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/winapi/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/smart_ptr/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/smart_ptr/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/align/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/align/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/core/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/core/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/predef/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/predef/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/scoped_array/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/scoped_array/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/checked_delete/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/checked_delete/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/scoped_ptr/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/scoped_ptr/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/shared_array/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/shared_array/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/shared_ptr/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/shared_ptr/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/throw_exception/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/throw_exception/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/utility/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/utility/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/container_hash/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/container_hash/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/describe/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/describe/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/mp11/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/mp11/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/integer/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/integer/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/static_assert/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/static_assert/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/type_traits/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/type_traits/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/mpl/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/mpl/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/move/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/move/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/preprocessor/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/preprocessor/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/io/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/io/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/swap/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/swap/include
/Iexternal/rules_boost~~non_module_dependencies~boost/libs/pool/include
/Ibazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/pool/include
/DBOOST_ALL_NO_LIB
/DBOOST_NO_CXX98_FUNCTION_BASE
/DBOOST_CONTEXT_EXPORT=
/showIncludes
/W0
/Fobazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/_objs/context/make_x86_64_ms_pe_masm.obj
/c
bazel-out/x64_windows-fastbuild/bin/external/rules_boost~~non_module_dependencies~boost/libs/context/src/asm/make_x86_64_ms_pe_masm.S

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 returns development 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

michaelsiegrist commented 1 month 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-test-working.zip

>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.

fmeum commented 1 month ago

Would you be interested in sending a PR?

michaelsiegrist commented 1 month ago

Sure, I'll try to have something up soon.