bazel-toolchains
bazel-toolchains copied to clipboard
Unable to build cc toolchains using rbe_configs_gen
I'm trying to use rbe_configs_gen to create toolchains for ubuntu18.04 and bazel v4.1.0, but running into this error message that I'm having trouble figuring out - wouldn't gcc be auto-installed as part of the bazelisk installation?
Downloading https://releases.bazel.build/4.1.0/release/bazel-4.1.0-linux-x86_64...
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Loading:
Loading: 0 packages loaded
INFO: Repository local_config_cc instantiated at:
/DEFAULT.WORKSPACE.SUFFIX:368:13: in <toplevel>
/root/.cache/bazel/_bazel_root/7c1760e52541f6b33fa1f4793e4219f3/external/bazel_tools/tools/cpp/cc_configure.bzl:184:16: in cc_configure
Repository rule cc_autoconf defined at:
/root/.cache/bazel/_bazel_root/7c1760e52541f6b33fa1f4793e4219f3/external/bazel_tools/tools/cpp/cc_configure.bzl:145:30: in <toplevel>
ERROR: An error occurred during the fetch of repository 'local_config_cc':
Traceback (most recent call last):
File "/root/.cache/bazel/_bazel_root/7c1760e52541f6b33fa1f4793e4219f3/external/bazel_tools/tools/cpp/cc_configure.bzl", line 127, column 33, in cc_autoconf_impl
configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools)
File "/root/.cache/bazel/_bazel_root/7c1760e52541f6b33fa1f4793e4219f3/external/bazel_tools/tools/cpp/unix_cc_configure.bzl", line 340, column 23, in configure_unix_toolchain
cc = _find_generic(repository_ctx, "gcc", "CC", overriden_tools)
File "/root/.cache/bazel/_bazel_root/7c1760e52541f6b33fa1f4793e4219f3/external/bazel_tools/tools/cpp/unix_cc_configure.bzl", line 310, column 32, in _find_generic
auto_configure_fail(msg)
File "/root/.cache/bazel/_bazel_root/7c1760e52541f6b33fa1f4793e4219f3/external/bazel_tools/tools/cpp/lib_cc_configure.bzl", line 112, column 9, in auto_configure_fail
fail("\n%sAuto-Configuration Error:%s %s\n" % (red, no_color, msg))
Error in fail:
Auto-Configuration Error: Cannot find gcc or CC (clang); either correct your path or set the CC environment variable
If I understand correctly, it tries to pickup clang which might not be present in the docker image. I changed to use gcc by
CppGenEnv: map[string]string{
"ABI_LIBC_VERSION": "glibc_2.19",
"ABI_VERSION": "gcc",
"BAZEL_COMPILER": "gcc",
"BAZEL_HOST_SYSTEM": "i686-unknown-linux-gnu",
"BAZEL_TARGET_CPU": "k8",
"BAZEL_TARGET_LIBC": "glibc_2.19",
"BAZEL_TARGET_SYSTEM": "x86_64-unknown-linux-gnu",
"CC": "gcc",
"CC_TOOLCHAIN_NAME": "linux_gnu_x86",
},
And then ran rbe_config_gen and it succeeded.
Alternatively, you can set this in a json file and pass --cpp_env_json cpp-env.json. Easier and better than modifying the go code.
file: cpp-env.json (Change to your needs)
{
"ABI_LIBC_VERSION": "glibc_2.27",
"ABI_VERSION": "gcc",
"BAZEL_COMPILER": "gcc",
"BAZEL_HOST_SYSTEM": "i686-unknown-linux-gnu",
"BAZEL_TARGET_CPU": "k8",
"BAZEL_TARGET_LIBC": "glibc_2.27",
"BAZEL_TARGET_SYSTEM": "x86_64-unknown-linux-gnu",
"CC": "gcc",
"CC_TOOLCHAIN_NAME": "linux_gnu_x86"
}