小编Fed*_*Fed的帖子

如何在不配置新工具链的情况下告诉 Bazel 使用哪个编译器

我想强制 Bazel 使用新的编译器来构建我的项目。据我了解,我可以配置新的工具链或使用一些命令行选项。我尝试了以下选项:

-CC=clang bazel build //main:hello-world
-export CC=C:\cygwin64\bin\clang++
- bazel build //main:hello-world  --client_env=CC=clang
Run Code Online (Sandbox Code Playgroud)

我认为这些不起作用,因为如果我使用以下命令编译相同的 hello-world.cc 文件

clang hello-world.cc 
Run Code Online (Sandbox Code Playgroud)

我收到错误:

clang-8: error: linker command failed with exit code 1 (use -v to see invocation)

Run Code Online (Sandbox Code Playgroud)

但与

CC=clang bazel build //main:hello-world 
or
bazel build //main:hello-world  --client_env=CC=clang
Run Code Online (Sandbox Code Playgroud)

构建成功。

知道为什么结果不同,以及如何解决这个问题吗?我在哪里可以检查 Bazel 使用的是哪个编译器?

编辑:

这里的输出:

CC=C:\cygwin64\bin\clang bazel build -s //main:hello-world

Starting local Bazel server and connecting to it...
Loading: 
Loading: 0 packages loaded
Analyzing: target //main:hello-world (1 packages loaded, 0 targets configured)
Analyzing: target //main:hello-world …
Run Code Online (Sandbox Code Playgroud)

c++ toolchain bazel

6
推荐指数
1
解决办法
5796
查看次数

Bazel 的 Mingw-w64 工具链 (Ubuntu 20.04.1 )

我正在尝试使用 Bazel 在 Ubuntu 上为 mingw-w64 创建工具链。我正在关注本教程:https://docs.bazel.build/versions/master/tutorial/cc-toolchain-config.html。但是,当我尝试将编译器的路径调整为 mingw64 安装的路径时,出现以下错误:

bazel build --config=mingw_config -s //main:hello-world --verbose_failures
Starting local Bazel server and connecting to it...
INFO: Analyzed target //main:hello-world (16 packages loaded, 46 targets configured).
INFO: Found 1 target...
SUBCOMMAND: # //main:hello-world [action 'Compiling main/hello-world.cc', configuration: a79594d39f0782b210e102e89b8a67dda26e295f95805aa9c0140f6281fdd3f5, execution platform: @local_config_platform//:host]
(cd /home/federica/.cache/bazel/_bazel_federica/fb36143429cca4c38e61a5e83150e333/execroot/__main__ && \
  exec env - \
    PATH=/home/federica/.cache/bazelisk/downloads/bazelbuild/bazel-3.5.0-linux-x86_64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
    PWD=/proc/self/cwd \
  /usr/bin/x86_64-w64-mingw32-gcc -MD -MF bazel-out/k8-fastbuild/bin/main/_objs/hello-world/hello-world.d '-frandom-seed=bazel-out/k8-fastbuild/bin/main/_objs/hello-world/hello-world.o' -iquote . -iquote bazel-out/k8-fastbuild/bin -iquote external/bazel_tools -iquote bazel-out/k8-fastbuild/bin/external/bazel_tools -c main/hello-world.cc -o bazel-out/k8-fastbuild/bin/main/_objs/hello-world/hello-world.o)
SUBCOMMAND: …
Run Code Online (Sandbox Code Playgroud)

c++ ubuntu mingw-w64 bazel

2
推荐指数
1
解决办法
1559
查看次数

使用 Bazel 将编译和链接操作分开

我想知道是否有一种方法可以在单独的步骤中使用 Bazel 执行编译和链接操作。如果我执行命令

bazel build -s //main:hello-world
Run Code Online (Sandbox Code Playgroud)

所有 bazel 子命令都会被打印。我知道可以从命令行执行这些子命令,但我想知道如何使用 Bazel 仅执行编译操作,并且仅在单独的步骤中执行链接操作。预先感谢您的任何帮助!

c++ linker compilation bazel

2
推荐指数
1
解决办法
1314
查看次数

标签 统计

bazel ×3

c++ ×3

compilation ×1

linker ×1

mingw-w64 ×1

toolchain ×1

ubuntu ×1