Fix builds on machines without gcc installed
With the new bazel upgrade, I got this error on my laptop where I
don't have gcc installed:
$ bazel build --config=arm64 //aos:aos_dump
INFO: Build options --crosstool_top, --host_crosstool_top, --platform_suffix, and 1 more have changed, discarding analysis cache.
INFO: Repository local_config_cc instantiated at:
/DEFAULT.WORKSPACE.SUFFIX:487:13: in <toplevel>
/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/external/bazel_tools/tools/cpp/cc_configure.bzl:184:16: in cc_configure
Repository rule cc_autoconf defined at:
/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/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 "/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/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 "/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/external/bazel_tools/tools/cpp/unix_cc_configure.bzl", line 344, column 17, in configure_unix_toolchain
cc = find_cc(repository_ctx, overriden_tools)
File "/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/external/bazel_tools/tools/cpp/unix_cc_configure.bzl", line 310, column 23, in find_cc
cc = _find_generic(repository_ctx, "gcc", "CC", overriden_tools)
File "/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/external/bazel_tools/tools/cpp/unix_cc_configure.bzl", line 306, column 32, in _find_generic
auto_configure_fail(msg)
File "/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/external/bazel_tools/tools/cpp/lib_cc_configure.bzl", line 112, column 9, in auto_configure_fail
fail("
%sAuto-Configuration Error:%s %s
" % (red, no_color, msg))
Error in fail:
Auto-Configuration Error: Cannot find gcc or CC; either correct your path or set the CC environment variable
ERROR: /DEFAULT.WORKSPACE.SUFFIX:487:13: fetching cc_autoconf rule //external:local_config_cc: Traceback (most recent call last):
File "/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/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 "/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/external/bazel_tools/tools/cpp/unix_cc_configure.bzl", line 344, column 17, in configure_unix_toolchain
cc = find_cc(repository_ctx, overriden_tools)
File "/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/external/bazel_tools/tools/cpp/unix_cc_configure.bzl", line 310, column 23, in find_cc
cc = _find_generic(repository_ctx, "gcc", "CC", overriden_tools)
File "/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/external/bazel_tools/tools/cpp/unix_cc_configure.bzl", line 306, column 32, in _find_generic
auto_configure_fail(msg)
File "/home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/external/bazel_tools/tools/cpp/lib_cc_configure.bzl", line 112, column 9, in auto_configure_fail
fail("
%sAuto-Configuration Error:%s %s
" % (red, no_color, msg))
Error in fail:
Auto-Configuration Error: Cannot find gcc or CC; either correct your path or set the CC environment variable
ERROR: /home/phil/.cache/bazel/_bazel_phil/f1328168c8ac7d35b10d44d44011b547/external/bazel_tools/tools/cpp/BUILD:92:6: @bazel_tools//tools/cpp:toolchain depends on @local_config_cc//:toolchain in repository @local_config_cc which failed to fetch. no such package '@local_config_cc//':
Auto-Configuration Error: Cannot find gcc or CC; either correct your path or set the CC environment variable
ERROR: Analysis of target '//aos:aos_dump' failed; build aborted:
INFO: Elapsed time: 1.877s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (6 packages loaded, 2048 targets configured)
This can be disabled with the `BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN`
environment variable. We don't want bazel to detect this anyway, so
this should be safe to set for everyone.
Change-Id: I4a82e52b3e9267401aebd3931c1c7288788ea8cc
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
diff --git a/tools/bazel b/tools/bazel
index da9008b..edb1aca 100755
--- a/tools/bazel
+++ b/tools/bazel
@@ -103,6 +103,7 @@
ENVIRONMENT_VARIABLES+=(HOME="${HOME}")
ENVIRONMENT_VARIABLES+=(TERM="${TERM}")
ENVIRONMENT_VARIABLES+=(LANG="${LANG:-C}")
+ENVIRONMENT_VARIABLES+=(BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1)
if [[ ! -z "${DISPLAY+x}" ]]; then
ENVIRONMENT_VARIABLES+=(DISPLAY="${DISPLAY}")