Мне нужно создать свою собственную цепочку инструментов с Bazel, и я хотел бы заставить Bazel использовать компилятор g ++ для mingw64. Я следую инструкциям в https://docs.bazel.build/versions/master/tutorial/cc-toolchain-config.html, пытаясь адаптировать их к моей машине Windows 10. Bazel может скомпилировать мой Hello-world.cc
и создать hello-world.exe
, и если я запускаю
bazel-bin/main/hello-world
, я получаю правильный результат. Тем не менее, Bazel выдает следующие ошибки:
bazel build --config=mingw64_config -s //main:hello-world --verbose_failures
Starting local Bazel server and connecting to it...
INFO: Analyzed target //main:hello-world (15 packages loaded, 47 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //main:hello-world [action 'Compiling main/hello-world.cc', configuration: e711ec75bfc5b6e1d77ea144cef912e655797b748714c6396a6b8cd3625eebee, execution platform: @local_config_platform//:host]
cd C:/users/_bazel_user/bcge3shs/execroot/__main__
SET PATH=c:\tools\msys64\usr\bin;c:\tools\msys64\bin;C:\WINDOWS;C:\WINDOWS\System32;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Haskell\bin;C:\Program Files\Haskell Platform\8.6.5\lib\extralibs\bin;C:\Program Files\Haskell Platform\8.6.5\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Haskell Platform\8.6.5\mingw\bin;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseSVN\bin;C:\Users\Documents\Bazel\bazel_binary;C:\mingw64\bin;C:\Users\AppData\Roaming\cabal\bin;C:\Users\AppData\Roaming\local\bin;C:\Users\AppData\Local\Microsoft\WindowsApps;C:\Program Files\LLVM\bin
SET PWD=/proc/self/cwd
SET RUNFILES_MANIFEST_ONLY=1
C:/mingw64/bin/g++ -MD -MF bazel-out/x64_windows-fastbuild/bin/main/_objs/hello-world/hello-world.d -frandom-seed=bazel-out/x64_windows-fastbuild/bin/main/_objs/hello-world/hello-world.o -iquote . -iquote bazel-out/x64_windows-fastbuild/bin -iquote external/bazel_tools -iquote bazel-out/x64_windows-fastbuild/bin/external/bazel_tools -c main/hello-world.cc -o bazel-out/x64_windows-fastbuild/bin/main/_objs/hello-world/hello-world.o
SUBCOMMAND: # //main:hello-world [action 'Linking main/hello-world', configuration: e711ec75bfc5b6e1d77ea144cef912e655797b748714c6396a6b8cd3625eebee, execution platform: @local_config_platform//:host]
cd C:/users/_bazel_user/bcge3shs/execroot/__main__
SET PATH=c:\tools\msys64\usr\bin;c:\tools\msys64\bin;C:\WINDOWS;C:\WINDOWS\System32;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\Haskell\bin;C:\Program Files\Haskell Platform\8.6.5\lib\extralibs\bin;C:\Program Files\Haskell Platform\8.6.5\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Haskell Platform\8.6.5\mingw\bin;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files\TortoiseSVN\bin;C:\Users\Documents\Bazel\bazel_binary;C:\mingw64\bin;C:\Users\AppData\Roaming\cabal\bin;C:\Users\AppData\Roaming\local\bin;C:\Users\AppData\Local\Microsoft\WindowsApps;C:\Program Files\LLVM\bin
SET PWD=/proc/self/cwd
SET RUNFILES_MANIFEST_ONLY=1
C:/mingw64/bin/g++ -o bazel-out/x64_windows-fastbuild/bin/main/hello-world bazel-out/x64_windows-fastbuild/bin/main/_objs/hello-world/hello-world.o -Wl,-S -lstdc++
ERROR: C:/users/documents/bazel/mingw64__compiler/main/BUILD:3:10: output 'main/hello-world' was not created
ERROR: C:/users/documents/bazel/mingw64__compiler/main/BUILD:3:10: not all outputs were created or valid
Target //main:hello-world failed to build
INFO: Elapsed time: 4.171s, Critical Path: 0.31s
INFO: 2 processes: 2 local.
FAILED: Build did NOT complete successfully
Ниже мой cc_toolchain_config.bzl
:
# NEW
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
# NEW
load(
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"feature",
"flag_group",
"flag_set",
"tool_path",
)
all_link_actions = [ # NEW
ACTION_NAMES.cpp_link_executable,
ACTION_NAMES.cpp_link_dynamic_library,
ACTION_NAMES.cpp_link_nodeps_dynamic_library,
]
def _impl(ctx):
tool_paths = [
tool_path(
name = "gcc",
path = "C:/mingw64/bin/g++",
),
tool_path(
name = "ld",
path = "C:/mingw64/bin/ld",
),
tool_path(
name = "ar",
path = "C:/mingw64/bin/ar",
),
tool_path(
name = "cpp",
path = "C:/mingw64/bin/cpp",
),
tool_path(
name = "gcov",
path = "C:/mingw64/bin/gcov",
),
tool_path(
name = "nm",
path = "C:/mingw64/bin/nm",
),
tool_path(
name = "objdump",
path = "C:/mingw64/bin/objdump",
),
tool_path(
name = "strip",
path = "C:/mingw64/bin/strip",
),
]
features = [ # NEW
feature(
name = "default_linker_flags",
enabled = True,
flag_sets = [
flag_set(
actions = all_link_actions,
flag_groups = ([
flag_group(
flags = [
"-lstdc++",
],
),
]),
),
],
),
]
return cc_common.create_cc_toolchain_config_info(
ctx = ctx,
features = features, # NEW
cxx_builtin_include_directories = [
"C:/mingw64/include",
"C:/mingw64/x86_64-w64-mingw32/include",
"C:/mingw64/lib/gcc/x86_64-w64-mingw32/5.1.0/include-fixed",
"C:/mingw64/lib/gcc/x86_64-w64-mingw32/5.1.0/include",
"C:/mingw64/lib/gcc/x86_64-w64-mingw32/5.1.0",
],
toolchain_identifier = "local",
host_system_name = "local",
target_system_name = "local",
target_cpu = "x64_windows",
target_libc = "unknown",
compiler = "g++",
abi_version = "unknown",
abi_libc_version = "unknown",
tool_paths = tool_paths,
)
cc_toolchain_config = rule(
implementation = _impl,
attrs = {},
provides = [CcToolchainConfigInfo],
Любые предложения по поводу того, в чем может быть проблема?