Upgrade bazel to 4.0.0rc2
A few things of note here:
- I disabled a few incompatible flags in order to minimize the number
of changes we have to deal with.
- I had to upgrade the typescript rules because the old ones didn't
work with new bazel anymore. That brought a typescript compiler
upgrade along. This in turn required me to turn off strict mode.
Otherwise, there are a _ton_ of errors in our typescript files. The
vast majority of them are related to `null` checking.
- The `default_python_version` attribute on Python rules doesn't exist
anymore. It's now replaced by `python_version`.
- I removed the CROSSTOOL in favour of a Starlark-equivalent
configuration function. See `tools/cpp/toolchain_config.bzl` for
more details. This new file is auto-generated using the migration
tools from `rules_cc`. I have made no attempt to beautify this file.
Relatedly, all CROSSTOOL-related files/functionality are gone as well.
- The `config_setting` targets to detect the compiler names had to
change. This is perhaps not surprising. Thanks to Austin for
pointing this out to me.
- The `cc_toolchain` targets all required `ar_files` and `as_files`
attributes where they didn't before. Not really sure what changed,
but the compilations appears to work with these changes.
Change-Id: I2317e5160fa3f8d87f94106b0c3b328918d0c42c
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index fd41261..d370750 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -1,5 +1,14 @@
+load(":toolchain_config.bzl", "cc_toolchain_config")
+
package(default_visibility = ["//visibility:public"])
+[cc_toolchain_config(
+ name = "{}_toolchain_config".format(cpu),
+ cpu = cpu,
+) for cpu in
+ ["armeabi-v7a", "armhf-debian", "cortex-m4f", "cortex-m4f-k22", "k8", "roborio"]
+]
+
cc_library(
name = "empty_main",
srcs = ["empty_main.c"],
@@ -29,11 +38,11 @@
cc_toolchain_suite(
name = "toolchain",
toolchains = {
- "k8|clang": ":cc-compiler-k8",
- "roborio|gcc": ":cc-compiler-roborio",
- "armhf-debian|clang": "cc-compiler-armhf-debian",
- "cortex-m4f|gcc": "cc-compiler-cortex-m4f",
- "cortex-m4f-k22|gcc": "cc-compiler-cortex-m4f-k22",
+ "k8": ":cc-compiler-k8",
+ "roborio": ":cc-compiler-roborio",
+ "armhf-debian": "cc-compiler-armhf-debian",
+ "cortex-m4f": "cc-compiler-cortex-m4f",
+ "cortex-m4f-k22": "cc-compiler-cortex-m4f-k22",
},
)
@@ -62,6 +71,14 @@
)
filegroup(
+ name = "clang_6p0_ar_files",
+ srcs = [
+ "//tools/cpp/clang_6p0:ar",
+ "@clang_6p0_repo//:compiler_pieces",
+ ],
+)
+
+filegroup(
name = "clang_6p0_linker_files",
srcs = [
"//tools/cpp/clang_6p0:ar",
@@ -95,15 +112,15 @@
name = "cc-compiler-k8",
all_files = ":clang_6p0_all_files",
compiler_files = ":clang_6p0_compiler_files",
- cpu = "k8",
dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
linker_files = ":clang_6p0_linker_files",
+ ar_files = ":clang_6p0_ar_files",
+ as_files = ":clang_6p0_compiler_files",
objcopy_files = "//tools/cpp/clang_6p0:objcopy",
- static_runtime_libs = [":empty"],
strip_files = ":clang_6p0_strip_files",
supports_param_files = 1,
toolchain_identifier = "k8_linux",
+ toolchain_config = ":k8_toolchain_config",
)
filegroup(
@@ -128,6 +145,14 @@
)
filegroup(
+ name = "roborio_ar_files",
+ srcs = [
+ "//tools/cpp/arm-frc-linux-gnueabi:ar",
+ "@arm_frc_linux_gnueabi_repo//:compiler_pieces",
+ ],
+)
+
+filegroup(
name = "roborio_compiler_files",
srcs = [
"//tools/cpp/arm-frc-linux-gnueabi:gcc",
@@ -149,15 +174,15 @@
name = "cc-compiler-roborio",
all_files = ":roborio-compiler-files",
compiler_files = ":roborio_compiler_files",
- cpu = "roborio",
dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
linker_files = ":roborio_linker_files",
+ ar_files = ":roborio_ar_files",
+ as_files = ":roborio_compiler_files",
objcopy_files = "//tools/cpp/arm-frc-linux-gnueabi:objcopy",
- static_runtime_libs = [":empty"],
strip_files = ":roborio_strip_files",
supports_param_files = 1,
toolchain_identifier = "roborio_linux",
+ toolchain_config = ":roborio_toolchain_config",
)
filegroup(
@@ -185,6 +210,14 @@
)
filegroup(
+ name = "linaro_linux_ar_files",
+ srcs = [
+ "//tools/cpp/linaro_linux_gcc:ar",
+ "@linaro_linux_gcc_repo//:compiler_pieces",
+ ],
+)
+
+filegroup(
name = "linaro_linux_compiler_files",
srcs = [
":clang_6p0_compiler_files",
@@ -208,15 +241,15 @@
name = "cc-compiler-armhf-debian",
all_files = ":linaro-gcc-files",
compiler_files = ":linaro_linux_compiler_files",
- cpu = "armhf",
dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
linker_files = ":linaro_linux_linker_files",
+ ar_files = "linaro_linux_ar_files",
+ as_files = "linaro_linux_compiler_files",
objcopy_files = "//tools/cpp/linaro_linux_gcc:objcopy",
- static_runtime_libs = [":empty"],
strip_files = ":linaro_linux_strip_files",
supports_param_files = 1,
toolchain_identifier = "clang_linux_armhf",
+ toolchain_config = ":armhf-debian_toolchain_config",
)
filegroup(
@@ -233,6 +266,7 @@
"//tools/cpp/gcc_arm_none_eabi:as",
"//tools/cpp/gcc_arm_none_eabi:gcc",
"//tools/cpp/gcc_arm_none_eabi:ld",
+ "@gcc_arm_none_eabi//:compiler_pieces",
],
)
@@ -247,41 +281,37 @@
],
)
+filegroup(
+ name = "gcc_arm_none_eabi_ar_files",
+ srcs = [
+ "//tools/cpp/gcc_arm_none_eabi:ar",
+ "@gcc_arm_none_eabi//:compiler_pieces",
+ ],
+)
+
cc_toolchain(
name = "cc-compiler-cortex-m4f",
all_files = ":gcc_arm_none_eabi_none_files",
compiler_files = ":gcc_arm_none_eabi_compiler_files",
- cpu = "cortex-m4f",
dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
linker_files = ":gcc_arm_none_eabi_linker_files",
+ ar_files = ":gcc_arm_none_eabi_ar_files",
objcopy_files = "//tools/cpp/gcc_arm_none_eabi:objcopy",
- static_runtime_libs = [":empty"],
strip_files = "//tools/cpp/gcc_arm_none_eabi:strip",
supports_param_files = 1,
toolchain_identifier = "cortex-m4f",
+ toolchain_config = ":cortex-m4f_toolchain_config",
)
cc_toolchain(
name = "cc-compiler-cortex-m4f-k22",
all_files = ":gcc_arm_none_eabi_none_files",
compiler_files = ":gcc_arm_none_eabi_compiler_files",
- cpu = "cortex-m4f-k22",
dwp_files = ":empty",
- dynamic_runtime_libs = [":empty"],
linker_files = ":gcc_arm_none_eabi_linker_files",
objcopy_files = ":empty",
- static_runtime_libs = [":empty"],
strip_files = ":empty",
supports_param_files = 1,
toolchain_identifier = "cortex-m4f-k22",
-)
-
-py_binary(
- name = "gen_crosstool",
- srcs = ["gen_crosstool.py"],
- main = "gen_crosstool.py",
- deps = [
- "//third_party/bazel:crosstool_config_proto_py",
- ],
+ toolchain_config = ":cortex-m4f-k22_toolchain_config",
)