From 6fad14b203093e7a19301c4ef51a87fce71e38cb Mon Sep 17 00:00:00 2001 From: Alexandre Lissy Date: Wed, 5 Aug 2020 17:51:00 +0200 Subject: [PATCH] Mozilla TensorFlow r2.3 --- .bazelrc | 18 + WORKSPACE | 12 + native_client | 1 + tensorflow/core/kernels/BUILD | 44 +- tensorflow/core/kernels/constant_op.cc | 1 + tensorflow/lite/tools/evaluation/BUILD | 1 - tensorflow/workspace.bzl | 20 + ...m_google_absl_fix_mac_and_nvcc_build.patch | 12 +- third_party/icu/BUILD.bazel | 5 +- third_party/py/BUILD.tpl | 1 - third_party/py/python_configure.bzl | 16 +- third_party/repo.bzl | 2 + .../embedded/linaro-gcc72-aarch64/BUILD | 67 +++ .../embedded/linaro-gcc72-aarch64/gcc/BUILD | 79 +++ .../gcc/aarch64-linux-gnu-ar | 5 + .../gcc/aarch64-linux-gnu-as | 5 + .../gcc/aarch64-linux-gnu-cpp | 5 + .../gcc/aarch64-linux-gnu-gcc | 6 + .../gcc/aarch64-linux-gnu-gcov | 5 + .../gcc/aarch64-linux-gnu-ld | 5 + .../gcc/aarch64-linux-gnu-nm | 5 + .../gcc/aarch64-linux-gnu-objcopy | 5 + .../gcc/aarch64-linux-gnu-objdump | 5 + .../gcc/aarch64-linux-gnu-strip | 5 + .../linaro-gcc72-aarch64.BUILD | 81 +++ .../linaro_toolchain_config.bzl | 484 ++++++++++++++++++ .../embedded/linaro-gcc72-armeabi/BUILD | 67 +++ .../embedded/linaro-gcc72-armeabi/gcc/BUILD | 79 +++ .../gcc/arm-linux-gnueabihf-ar | 5 + .../gcc/arm-linux-gnueabihf-as | 5 + .../gcc/arm-linux-gnueabihf-cpp | 5 + .../gcc/arm-linux-gnueabihf-gcc | 6 + .../gcc/arm-linux-gnueabihf-gcov | 5 + .../gcc/arm-linux-gnueabihf-ld | 5 + .../gcc/arm-linux-gnueabihf-nm | 5 + .../gcc/arm-linux-gnueabihf-objcopy | 5 + .../gcc/arm-linux-gnueabihf-objdump | 5 + .../gcc/arm-linux-gnueabihf-strip | 5 + .../linaro-gcc72-armeabi.BUILD | 81 +++ .../linaro_toolchain_config.bzl | 484 ++++++++++++++++++ 40 files changed, 1633 insertions(+), 24 deletions(-) create mode 120000 native_client create mode 100644 third_party/toolchains/embedded/linaro-gcc72-aarch64/BUILD create mode 100644 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/BUILD create mode 100755 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-ar create mode 100755 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-as create mode 100755 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-cpp create mode 100755 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-gcc create mode 100755 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-gcov create mode 100755 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-ld create mode 100755 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-nm create mode 100755 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-objcopy create mode 100755 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-objdump create mode 100755 third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-strip create mode 100644 third_party/toolchains/embedded/linaro-gcc72-aarch64/linaro-gcc72-aarch64.BUILD create mode 100644 third_party/toolchains/embedded/linaro-gcc72-aarch64/linaro_toolchain_config.bzl create mode 100644 third_party/toolchains/embedded/linaro-gcc72-armeabi/BUILD create mode 100644 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/BUILD create mode 100755 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-ar create mode 100755 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-as create mode 100755 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-cpp create mode 100755 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-gcc create mode 100755 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-gcov create mode 100755 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-ld create mode 100755 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-nm create mode 100755 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-objcopy create mode 100755 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-objdump create mode 100755 third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-strip create mode 100644 third_party/toolchains/embedded/linaro-gcc72-armeabi/linaro-gcc72-armeabi.BUILD create mode 100644 third_party/toolchains/embedded/linaro-gcc72-armeabi/linaro_toolchain_config.bzl diff --git a/.bazelrc b/.bazelrc index f11c376df65..1209adccd2b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -202,6 +202,24 @@ build:sycl_asan --copt -fno-omit-frame-pointer --copt -fsanitize-coverage=3 --co build:sycl_nodouble --config=sycl build:sycl_trisycl --define=using_trisycl=true +build --copt=-DTFLITE_WITH_RUY_GEMV + +build:rpi3 --host_crosstool_top=@bazel_tools//tools/cpp:toolchain +build:rpi3 --crosstool_top=//third_party/toolchains/embedded/linaro-gcc72-armeabi:toolchain +build:rpi3 --cpu=armv7a --define=target_system=rpi3 +build:rpi3 --copt=-march=armv7-a --copt=-mtune=cortex-a53 --copt=-mfloat-abi=hard --copt=-mfpu=neon-fp-armv8 --copt=-DRASPBERRY_PI --copt=-D_GLIBCXX_USE_CXX11_ABI=0 --copt=-std=gnu99 --copt=-mno-unaligned-access +build:rpi3 --define=tensorflow_mkldnn_contraction_kernel=0 +build:rpi3 --define=runtime=tflite +build:rpi3_opt --copt=-funsafe-math-optimizations --copt=-ftree-vectorize --copt=-pipe + +build:rpi3-armv8 --host_crosstool_top=@bazel_tools//tools/cpp:toolchain +build:rpi3-armv8 --crosstool_top=//third_party/toolchains/embedded/linaro-gcc72-aarch64:toolchain +build:rpi3-armv8 --cpu=aarch64 --define=target_system=rpi3-armv8 +build:rpi3-armv8 --copt=-march=armv8-a --copt=-mtune=cortex-a53 --copt=-DRASPBERRY_PI --copt=-D_GLIBCXX_USE_CXX11_ABI=0 --copt=-std=gnu99 +build:rpi3-armv8 --define=tensorflow_mkldnn_contraction_kernel=0 +build:rpi3-armv8 --define=runtime=tflite +build:rpi3-armv8_opt --copt=-funsafe-math-optimizations --copt=-ftree-vectorize --copt=-pipe + # Options extracted from configure script build:ngraph --define=with_ngraph_support=true build:numa --define=with_numa_support=true diff --git a/WORKSPACE b/WORKSPACE index ea741c31c7f..522ea54ac76 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -18,6 +18,18 @@ load("//tensorflow:workspace.bzl", "tf_repositories") # Please add all new TensorFlow dependencies in workspace.bzl. tf_repositories() +load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") + +git_repository( + name = "com_github_nelhage_rules_boost", + commit = "1e3a69bf2d5cd10c34b74f066054cd335d033d71", + remote = "https://github.com/nelhage/rules_boost", + shallow_since = "1591047380 -0700", +) + +load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps") +boost_deps() + register_toolchains("@local_config_python//:py_toolchain") load("@io_bazel_rules_closure//closure:defs.bzl", "closure_repositories") diff --git a/native_client b/native_client new file mode 120000 index 00000000000..192d4a2e1a3 --- /dev/null +++ b/native_client @@ -0,0 +1 @@ +../native_client \ No newline at end of file diff --git a/tensorflow/core/kernels/BUILD b/tensorflow/core/kernels/BUILD index 7da864a6027..8546525e0dd 100644 --- a/tensorflow/core/kernels/BUILD +++ b/tensorflow/core/kernels/BUILD @@ -5864,15 +5864,15 @@ cc_library( ":string_format_op", ":string_join_op", ":string_length_op", - ":string_lower_op", + # ":string_lower_op", ":string_ngrams_op", ":string_split_op", ":string_strip_op", ":string_to_hash_bucket_op", - ":string_upper_op", + # ":string_upper_op", ":substr_op", - ":unicode_ops", - ":unicode_script_op", + # ":unicode_ops", + # ":unicode_script_op", ":unsorted_segment_join_op", ], ) @@ -5885,7 +5885,7 @@ cc_library( "//tensorflow/core:framework", "//tensorflow/core:lib", "//tensorflow/core:protos_all_cc", - "@icu//:common", + # "@icu//:common", ], ) @@ -6041,7 +6041,7 @@ tf_kernel_library( prefix = "string_lower_op", deps = STRING_DEPS + [ "@com_google_absl//absl/strings", - "@icu//:common", + # "@icu//:common", ], ) @@ -6050,7 +6050,7 @@ tf_kernel_library( prefix = "string_upper_op", deps = STRING_DEPS + [ "@com_google_absl//absl/strings", - "@icu//:common", + # "@icu//:common", ], ) @@ -6096,7 +6096,7 @@ tf_kernel_library( "//tensorflow/core:lib_internal", "//third_party/eigen3", "//third_party/icu/data:conversion_data", - "@icu//:common", + # "@icu//:common", ], ) @@ -7125,10 +7125,10 @@ filegroup( "mutex_ops.*", "batch_kernels.*", "regex_replace_op.cc", - "string_lower_op.cc", # Requires ICU for unicode. - "string_upper_op.cc", # Requires ICU for unicode. + # "string_lower_op.cc", # Requires ICU for unicode. + # "string_upper_op.cc", # Requires ICU for unicode. "unicode_ops.cc", - "unicode_script_op.cc", + # "unicode_script_op.cc", # Ops that are inherently incompatible with Android (e.g. tied to x86 platform). "mkl_*", "xsmm_*", @@ -8620,7 +8620,7 @@ tf_kernel_library( srcs = ["unicode_script_op.cc"], deps = [ "//tensorflow/core:framework", - "@icu//:common", + # "@icu//:common", ], ) @@ -8652,6 +8652,26 @@ cc_library( ], ) +tf_kernel_library( + name = "deepspeech_cwise_ops", + srcs = [ + "cwise_op_less.cc", + "cwise_op_minimum.cc", + "cwise_op_mul_1.cc", + ], + gpu_srcs = [ + "cwise_op_gpu_less.cu.cc", + "cwise_op_gpu_minimum.cu.cc", + "cwise_op_gpu_mul.cu.cc", + ], + deps = [ + ":cwise_lib", + "//tensorflow/core:framework", + "//tensorflow/core:lib", + "//third_party/eigen3", + ], +) + # Header-only version of cwise_lib for clients that want to use the cwise_ops # functionality in their own custom ops. cc_header_only_library( diff --git a/tensorflow/core/kernels/constant_op.cc b/tensorflow/core/kernels/constant_op.cc index 4bcbc076446..17005b76d48 100644 --- a/tensorflow/core/kernels/constant_op.cc +++ b/tensorflow/core/kernels/constant_op.cc @@ -116,6 +116,7 @@ REGISTER_KERNEL(GPU, int16); REGISTER_KERNEL(GPU, qint16); REGISTER_KERNEL(GPU, quint16); REGISTER_KERNEL(GPU, uint32); +REGISTER_KERNEL(GPU, int32); REGISTER_KERNEL(GPU, qint32); REGISTER_KERNEL(GPU, int64); REGISTER_KERNEL(GPU, uint64); diff --git a/tensorflow/lite/tools/evaluation/BUILD b/tensorflow/lite/tools/evaluation/BUILD index 85dfb183254..3d329a38cd0 100644 --- a/tensorflow/lite/tools/evaluation/BUILD +++ b/tensorflow/lite/tools/evaluation/BUILD @@ -57,7 +57,6 @@ cc_library( "//conditions:default": [], }) + select({ "//tensorflow:fuchsia": [], - "//tensorflow:windows": [], "//conditions:default": [ "//tensorflow/lite/delegates/xnnpack:xnnpack_delegate", ], diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl index 24446d846cf..3a8c2e579b5 100755 --- a/tensorflow/workspace.bzl +++ b/tensorflow/workspace.bzl @@ -292,6 +292,26 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""): ], ) + tf_http_archive( + name = "LinaroArmGcc72", + build_file = clean_dep("//third_party/toolchains/embedded/linaro-gcc72-armeabi:linaro-gcc72-armeabi.BUILD"), + strip_prefix = "gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/", + urls = [ + "https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabihf/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf.tar.xz", + ], + sha256 = "cee0087b1f1205b73996651b99acd3a926d136e71047048f1758ffcec69b1ca2", + ) + + tf_http_archive( + name = "LinaroAarch64Gcc72", + build_file = clean_dep("//third_party/toolchains/embedded/linaro-gcc72-aarch64:linaro-gcc72-aarch64.BUILD"), + strip_prefix = "gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu/", + urls = [ + "https://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/aarch64-linux-gnu/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz", + ], + sha256 = "20181f828e1075f1a493947ff91e82dd578ce9f8638fbdfc39e24b62857d8f8d", + ) + tf_http_archive( name = "libxsmm_archive", build_file = clean_dep("//third_party:libxsmm.BUILD"), diff --git a/third_party/com_google_absl_fix_mac_and_nvcc_build.patch b/third_party/com_google_absl_fix_mac_and_nvcc_build.patch index 271e941bfe8..81c8e5d84b6 100644 --- a/third_party/com_google_absl_fix_mac_and_nvcc_build.patch +++ b/third_party/com_google_absl_fix_mac_and_nvcc_build.patch @@ -1,3 +1,14 @@ +--- ./absl/time/internal/cctz/include/cctz/civil_time_detail.h 2020-08-06 01:33:56.005757145 +0200 ++++ ./absl/time/internal/cctz/include/cctz/civil_time_detail.h 2020-08-06 01:33:35.460579387 +0200 +@@ -23,7 +23,7 @@ + #include "absl/base/config.h" + + // Disable constexpr support unless we are in C++14 mode. +-#if __cpp_constexpr >= 201304 || (defined(_MSC_VER) && _MSC_VER >= 1910) ++#if (!defined(NO_CONSTEXPR_FOR_YOU) && __cpp_constexpr >= 201304) || (defined(_MSC_VER) && _MSC_VER >= 1910) + #define CONSTEXPR_D constexpr // data + #define CONSTEXPR_F constexpr // function + #define CONSTEXPR_M constexpr // member --- ./absl/time/internal/cctz/BUILD.bazel 2019-09-23 13:20:52.000000000 -0700 +++ ./absl/time/internal/cctz/BUILD.bazel.fixed 2019-09-23 13:20:48.000000000 -0700 @@ -74,15 +74,6 @@ @@ -301,4 +312,3 @@ + .internal_compressed_tuple::template Storage::get(); } }; - diff --git a/third_party/icu/BUILD.bazel b/third_party/icu/BUILD.bazel index 14cadffc841..2d54eecddcc 100644 --- a/third_party/icu/BUILD.bazel +++ b/third_party/icu/BUILD.bazel @@ -1,5 +1,8 @@ +# We make everything here private to make any dependencies on ICU become a build +# failure and easier/faster to track down, as it's not needed for DeepSpeech and +# causes linking problems on Windows. package( - default_visibility = ["//visibility:public"], + default_visibility = ["//visibility:private"], ) licenses(["notice"]) # Apache 2.0 diff --git a/third_party/py/BUILD.tpl b/third_party/py/BUILD.tpl index 08ba167a998..500eae400e8 100644 --- a/third_party/py/BUILD.tpl +++ b/third_party/py/BUILD.tpl @@ -67,5 +67,4 @@ config_setting( ) %{PYTHON_INCLUDE_GENRULE} -%{NUMPY_INCLUDE_GENRULE} %{PYTHON_IMPORT_LIB_GENRULE} diff --git a/third_party/py/python_configure.bzl b/third_party/py/python_configure.bzl index 2f75262ea9f..7cf384bf7fa 100644 --- a/third_party/py/python_configure.bzl +++ b/third_party/py/python_configure.bzl @@ -210,7 +210,7 @@ def _create_local_python_repository(repository_ctx): python_lib = _get_python_lib(repository_ctx, python_bin) _check_python_lib(repository_ctx, python_lib) python_include = _get_python_include(repository_ctx, python_bin) - numpy_include = _get_numpy_include(repository_ctx, python_bin) + "/numpy" +# numpy_include = _get_numpy_include(repository_ctx, python_bin) + "/numpy" python_include_rule = _symlink_genrule_for_dir( repository_ctx, python_include, @@ -233,12 +233,12 @@ def _create_local_python_repository(repository_ctx): [python_import_lib_src], [python_import_lib_name], ) - numpy_include_rule = _symlink_genrule_for_dir( - repository_ctx, - numpy_include, - "numpy_include/numpy", - "numpy_include", - ) + #numpy_include_rule = _symlink_genrule_for_dir( + # repository_ctx, + # numpy_include, + # "numpy_include/numpy", + # "numpy_include", + #) platform_constraint = "" if repository_ctx.attr.platform_constraint: @@ -247,7 +247,7 @@ def _create_local_python_repository(repository_ctx): "%{PYTHON_BIN_PATH}": python_bin, "%{PYTHON_INCLUDE_GENRULE}": python_include_rule, "%{PYTHON_IMPORT_LIB_GENRULE}": python_import_lib_genrule, - "%{NUMPY_INCLUDE_GENRULE}": numpy_include_rule, + #"%{NUMPY_INCLUDE_GENRULE}": numpy_include_rule, "%{PLATFORM_CONSTRAINT}": platform_constraint, }) diff --git a/third_party/repo.bzl b/third_party/repo.bzl index a4d2b899f80..86db64e58c0 100644 --- a/third_party/repo.bzl +++ b/third_party/repo.bzl @@ -16,6 +16,8 @@ _SINGLE_URL_WHITELIST = depset([ "arm_compiler", + "LinaroArmGcc72", + "LinaroAarch64Gcc72", ]) def _is_windows(ctx): diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/BUILD b/third_party/toolchains/embedded/linaro-gcc72-aarch64/BUILD new file mode 100644 index 00000000000..3fb89fd7b48 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/BUILD @@ -0,0 +1,67 @@ +# This is the entry point for --crosstool_top. +# +# The cc_toolchain rule used is found by: +# +# 1. Finding the appropriate toolchain in the CROSSTOOL file based on the --cpu +# and --compiler command line flags (if they exist, otherwise using the +# "default_target_cpu" / "default_toolchain" fields in the CROSSTOOL file) +# 2. Concatenating the "target_cpu" and "compiler" fields of the toolchain in +# use and using that as a key in the map in the "toolchains" attribute +package(default_visibility = ["//visibility:public"]) + +load(":linaro_toolchain_config.bzl", "linaro_toolchain_config") + +cc_toolchain_suite( + name = "toolchain", + toolchains = { + "aarch64": ":cc-compiler-aarch64", + }, +) + +filegroup( + name = "empty", + srcs = [], +) + +filegroup( + name = "gcc_linux_all_files", + srcs = [ + "//third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc:tool-wrappers", + "@LinaroAarch64Gcc72//:compiler_pieces", + ], +) + +filegroup( + name = "gcc_linux_linker_files", + srcs = [ + "//third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc:ld", + "//third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc:ar", + "@LinaroAarch64Gcc72//:compiler_pieces", + ], +) + +filegroup( + name = "gcc_linux_compiler_files", + srcs = [ + "//third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc:gcc", + "//third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc:as", + ], +) + +linaro_toolchain_config(name = "linaro_aarch64") + +cc_toolchain( + name = "cc-compiler-aarch64", + all_files = ":gcc_linux_all_files", + compiler_files = ":gcc_linux_compiler_files", + toolchain_identifier = "gcc72_linaro_aarch64", + toolchain_config = ":linaro_aarch64", + dwp_files = ":empty", + dynamic_runtime_lib = ":empty", + linker_files = ":gcc_linux_linker_files", + objcopy_files = "//third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc:objcopy", + static_runtime_lib = ":empty", + strip_files = "//third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc:strip", + supports_param_files = 1, + visibility = ["//visibility:public"], +) diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/BUILD b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/BUILD new file mode 100644 index 00000000000..4bd4bd64216 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/BUILD @@ -0,0 +1,79 @@ +package(default_visibility = ['//third_party/toolchains/embedded/linaro-gcc72-aarch64:__pkg__']) + +filegroup( + name = 'gcc', + srcs = [ + '@LinaroAarch64Gcc72//:gcc', + 'aarch64-linux-gnu-gcc', + ], +) + +filegroup( + name = 'ar', + srcs = [ + '@LinaroAarch64Gcc72//:ar', + 'aarch64-linux-gnu-ar', + ], +) + +filegroup( + name = 'ld', + srcs = [ + '@LinaroAarch64Gcc72//:ld', + 'aarch64-linux-gnu-ld', + ], +) + +filegroup( + name = 'nm', + srcs = [ + '@LinaroAarch64Gcc72//:nm', + 'aarch64-linux-gnu-nm', + ], +) + +filegroup( + name = 'objcopy', + srcs = [ + '@LinaroAarch64Gcc72//:objcopy', + 'aarch64-linux-gnu-objcopy', + ], +) + +filegroup( + name = 'objdump', + srcs = [ + '@LinaroAarch64Gcc72//:objdump', + 'aarch64-linux-gnu-objdump', + ], +) + +filegroup( + name = 'strip', + srcs = [ + '@LinaroAarch64Gcc72//:strip', + 'aarch64-linux-gnu-strip', + ], +) + +filegroup( + name = 'as', + srcs = [ + '@LinaroAarch64Gcc72//:as', + 'aarch64-linux-gnu-as', + ], +) + +filegroup( + name = 'tool-wrappers', + srcs = [ + ':gcc', + ':ar', + ':ld', + ':nm', + ':objcopy', + ':objdump', + ':strip', + ':as', + ], +) diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-ar b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-ar new file mode 100755 index 00000000000..7370e72324f --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-ar @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a aarch64-linux-gnu-ar \ + external/LinaroAarch64Gcc72/bin/aarch64-linux-gnu-ar \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-as b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-as new file mode 100755 index 00000000000..beb6799becc --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-as @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a aarch64-linux-gnu-as \ + external/LinaroAarch64Gcc72/bin/aarch64-linux-gnu-as \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-cpp b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-cpp new file mode 100755 index 00000000000..e72c461f4d8 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-cpp @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a aarch64-linux-gnu-cpp \ + external/LinaroAarch64Gcc72/bin/aarch64-linux-gnu-cpp \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-gcc b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-gcc new file mode 100755 index 00000000000..f72848c1d23 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-gcc @@ -0,0 +1,6 @@ +#!/bin/bash --norc + +PATH="external/LinaroAarch64Gcc72/libexec/gcc/aarch64-linux-gnu/7.2.1/:$PATH" \ + exec \ + external/LinaroAarch64Gcc72/bin/aarch64-linux-gnu-gcc \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-gcov b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-gcov new file mode 100755 index 00000000000..a996b93fc61 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-gcov @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a aarch64-linux-gnu-gcov \ + external/LinaroAarch64Gcc72/bin/aarch64-linux-gnu-gcov \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-ld b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-ld new file mode 100755 index 00000000000..2e135da14a1 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-ld @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a aarch64-linux-gnu-ld \ + external/LinaroAarch64Gcc72/bin/aarch64-linux-gnu-ld \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-nm b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-nm new file mode 100755 index 00000000000..221c24d1b8d --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-nm @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a aarch64-linux-gnu-nm \ + external/LinaroAarch64Gcc72/bin/aarch64-linux-gnu-nm \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-objcopy b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-objcopy new file mode 100755 index 00000000000..70f06d4384c --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-objcopy @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a aarch64-linux-gnu-objcopy \ + external/LinaroAarch64Gcc72/bin/aarch64-linux-gnu-objcopy \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-objdump b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-objdump new file mode 100755 index 00000000000..2c853a8e278 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-objdump @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a aarch64-linux-gnu-objdump \ + external/LinaroAarch64Gcc72/bin/aarch64-linux-gnu-objdump \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-strip b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-strip new file mode 100755 index 00000000000..deba91a6b75 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/gcc/aarch64-linux-gnu-strip @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a aarch64-linux-gnu-strip \ + external/LinaroAarch64Gcc72/bin/aarch64-linux-gnu-strip \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/linaro-gcc72-aarch64.BUILD b/third_party/toolchains/embedded/linaro-gcc72-aarch64/linaro-gcc72-aarch64.BUILD new file mode 100644 index 00000000000..6df0735b151 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/linaro-gcc72-aarch64.BUILD @@ -0,0 +1,81 @@ +package(default_visibility = ['//visibility:public']) + +filegroup( + name = 'gcc', + srcs = [ + 'bin/aarch64-linux-gnu-gcc', + ], +) + +filegroup( + name = 'ar', + srcs = [ + 'bin/aarch64-linux-gnu-ar', + ], +) + +filegroup( + name = 'ld', + srcs = [ + 'bin/aarch64-linux-gnu-ld', + ], +) + +filegroup( + name = 'nm', + srcs = [ + 'bin/aarch64-linux-gnu-nm', + ], +) + +filegroup( + name = 'objcopy', + srcs = [ + 'bin/aarch64-linux-gnu-objcopy', + ], +) + +filegroup( + name = 'objdump', + srcs = [ + 'bin/aarch64-linux-gnu-objdump', + ], +) + +filegroup( + name = 'strip', + srcs = [ + 'bin/aarch64-linux-gnu-strip', + ], +) + +filegroup( + name = 'as', + srcs = [ + 'bin/aarch64-linux-gnu-as', + ], +) + +filegroup( + name = 'compiler_pieces', + srcs = glob([ + 'aarch64-linux-gnu/**', + 'libexec/**', + 'lib/gcc/aarch64-linux-gnu/**', + 'include/**', + ]), +) + +filegroup( + name = 'compiler_components', + srcs = [ + ':gcc', + ':ar', + ':ld', + ':nm', + ':objcopy', + ':objdump', + ':strip', + ':as', + ], +) diff --git a/third_party/toolchains/embedded/linaro-gcc72-aarch64/linaro_toolchain_config.bzl b/third_party/toolchains/embedded/linaro-gcc72-aarch64/linaro_toolchain_config.bzl new file mode 100644 index 00000000000..938e1fb976a --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-aarch64/linaro_toolchain_config.bzl @@ -0,0 +1,484 @@ +# Copyright 2019 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""A Starlark cc_toolchain configuration rule""" + +load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", + "action_config", + "artifact_name_pattern", + "env_entry", + "env_set", + "feature", + "feature_set", + "flag_group", + "flag_set", + "make_variable", + "tool", + "tool_path", + "variable_with_value", + "with_feature_set", +) + +load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") + +all_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, + ACTION_NAMES.lto_backend, +] + +all_cpp_compile_actions = [ + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, +] + +preprocessor_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, +] + +codegen_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, +] + +all_link_actions = [ + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, +] + +def _impl(ctx): + + abi_version = "aarch64" + abi_libc_version = "glibc_2.24" + builtin_sysroot = None + compiler = "gcc" + host_system_name = "aarch64" + needs_pic = True + supports_gold_linker = False + supports_incremental_linker = False + supports_fission = False + supports_interface_shared_objects = False + supports_normalizing_ar = False + supports_start_end_lib = False + supports_thin_archives = False + target_libc = "glibc_2.24" + target_cpu = "armv8" + target_system_name = "armv8" + toolchain_identifier = "gcc72_linaro_aarch64" + cc_target_os = None + + action_configs = [] + + supports_pic_feature = feature(name = "supports_pic", enabled = True) + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + + user_compile_flags_feature = feature( + name = "user_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = ["%{user_compile_flags}"], + iterate_over = "user_compile_flags", + expand_if_available = "user_compile_flags", + ), + ], + ), + ], + ) + + user_link_flags_feature = feature( + name = "user_link_flags", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["%{user_link_flags}"], + iterate_over = "user_link_flags", + expand_if_available = "user_link_flags", + ), + ], + ), + ], + ) + + shared_flag_feature = feature( + name = "shared_flag", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.lto_index_for_dynamic_library, + ACTION_NAMES.lto_index_for_nodeps_dynamic_library, + ], + flag_groups = [flag_group(flags = ["-shared"])], + ), + ], + ) + + sysroot_feature = feature( + name = "sysroot", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = ["--sysroot=%{sysroot}"], + expand_if_available = "sysroot", + ), + ], + ), + ], + ) + + objcopy_embed_flags_feature = feature( + name = "objcopy_embed_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = ["objcopy_embed_data"], + flag_groups = [flag_group(flags = ["-I", "binary"])], + ), + ], + ) + + unfiltered_compile_flags_feature = feature( + name = "unfiltered_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + # Make C++ compilation deterministic. Use linkstamping instead of these + # compiler symbols. + "-Wno-builtin-macro-redefined", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + # This makes GCC and Clang do what we want when called through symlinks. + "-no-canonical-prefixes", + ], + ), + ], + ), + ], + ) + + default_compile_flags_feature = feature( + name = "default_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "-U_FORTIFY_SOURCE", + "-D_FORTIFY_SOURCE=1", + "-fstack-protector", + ], + ), + ], + ), + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [flag_group(flags = ["-g"])], + with_features = [with_feature_set(features = ["dbg"])], + ), + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "-g0", + "-O2", + "-DNDEBUG", + "-ffunction-sections", + "-fdata-sections", + ], + ), + ], + with_features = [with_feature_set(features = ["opt"])], + ), + flag_set( + actions = [ + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "-std=c++11", + "--sysroot=external/LinaroAarch64Gcc72/aarch64-linux-gnu/libc", + "-pthread", + "-nostdinc", + "-isystem", + "external/LinaroAarch64Gcc72/aarch64-linux-gnu/include/c++/7.2.1/aarch64-linux-gnu", + "-isystem", + "external/LinaroAarch64Gcc72/aarch64-linux-gnu/include/c++/7.2.1", + "-isystem", + "external/LinaroAarch64Gcc72/lib/gcc/aarch64-linux-gnu/7.2.1/include", + "-isystem", + "external/LinaroAarch64Gcc72/aarch64-linux-gnu/libc/usr/include", + "-isystem", + "external/LinaroAarch64Gcc72/lib/gcc/aarch64-linux-gnu/7.2.1/include-fixed", + "-isystem", + "external/LinaroAarch64Gcc72/aarch64-linux-gnu/libc/usr/include", + "-isystem", + "external/LinaroAarch64Gcc72/aarch64-linux-gnu/libc/usr/include/aarch64-linux-gnu", + "-isystem", + "external/LinaroAarch64Gcc72/lib/gcc/aarch64-linux-gnu/7.2.1/include", + "-isystem", + "external/LinaroAarch64Gcc72/include/c++/7.2.1/aarch64-linux-gnu", + "-isystem", + "external/LinaroAarch64Gcc72/include/c++/7.2.1", + # Security hardening on by default. + "-fstack-protector", + "-fPIE", + # All warnings are enabled. Maybe enable -Werror as well? + "-Wall", + # Enable a few more warnings that aren't part of -Wall. + "-Wunused-but-set-parameter", + # But disable some that are problematic. + "-Wno-free-nonheap-object", # has false positives + # Keep stack frames for debugging, even in opt mode. + "-fno-omit-frame-pointer", + # Enable coloring even if there's no attached terminal. Bazel removes the + # escape sequences if --nocolor is specified. + "-fdiagnostics-color=always", + ], + ), + ], + ), + ], + ) + + default_link_flags_feature = feature( + name = "default_link_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = [ + # "-target", + # "aarch64-linux-gnu", + "--sysroot=external/LinaroAarch64Gcc72/aarch64-linux-gnu/libc", + "-pass-exit-codes", + "-pie", + "-lstdc++", + "-lm", + "-lpthread", + "-Wl,--dynamic-linker=/lib/ld-linux-aarch64.so.1", + "-Wl,-no-as-needed", + "-Wl,-z,relro,-z,now", + "-no-canonical-prefixes", + # Stamp the binary with a unique identifier. + "-Wl,--build-id=md5", + "-Wl,--hash-style=gnu", + "-Lexternal/LinaroAarch64Gcc72/aarch64-linux-gnu/lib", + "-Lexternal/LinaroAarch64Gcc72/aarch64-linux-gnu/libc/lib", + "-Lexternal/LinaroAarch64Gcc72/aarch64-linux-gnu/libc/usr/lib", + "-Bexternal/LinaroAarch64Gcc72/aarch64-linux-gnu/bin", + ], + ), + ], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + + opt_feature = feature(name = "opt") + + dbg_feature = feature(name = "dbg") + + features = [ + default_compile_flags_feature, + default_link_flags_feature, + supports_dynamic_linker_feature, + supports_pic_feature, + objcopy_embed_flags_feature, + opt_feature, + dbg_feature, + user_compile_flags_feature, + user_link_flags_feature, + shared_flag_feature, + sysroot_feature, + unfiltered_compile_flags_feature, + ] + + cxx_builtin_include_directories = [ + "%package(@LinaroAarch64Gcc72//include)%", + "%package(@LinaroAarch64Gcc72//aarch64-linux-gnu/libc/usr/include)%", + "%package(@LinaroAarch64Gcc72//aarch64-linux-gnu/libc/lib/gcc/aarch64-linux-gnu/7.2.1/include-fixed)%", + "%package(@LinaroAarch64Gcc72//include)%/c++/7.2.1", + "%package(@LinaroAarch64Gcc72//aarch64-linux-gnu/libc/lib/gcc/aarch64-linux-gnu/7.2.1/include)%", + "%package(@LinaroAarch64Gcc72//aarch64-linux-gnu/libc/lib/gcc/aarch64-linux-gnu/7.2.1/include-fixed)%", + "%package(@LinaroAarch64Gcc72//lib/gcc/aarch64-linux-gnu/7.2.1/include)%", + "%package(@LinaroAarch64Gcc72//lib/gcc/aarch64-linux-gnu/7.2.1/include-fixed)%", + "%package(@LinaroAarch64Gcc72//aarch64-linux-gnu/include)%/c++/7.2.1", + ] + + artifact_name_patterns = [] + make_variables = [] + + tool_paths = [ + tool_path(name = "ar", path = "gcc/aarch64-linux-gnu-ar"), + tool_path(name = "compat-ld", path = "gcc/aarch64-linux-gnu-ld"), + tool_path(name = "cpp", path = "gcc/aarch64-linux-gnu-cpp"), + tool_path(name = "dwp", path = "gcc/aarch64-linux-gnu-dwp"), + tool_path(name = "gcc", path = "gcc/aarch64-linux-gnu-gcc"), + tool_path(name = "gcov", path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-gcov-4.9"), + # C(++), compiles invoke the compiler (as that is the one knowing where + # to find libraries),, but we provide LD so other rules can invoke the linker. + tool_path(name = "ld", path = "gcc/aarch64-linux-gnu-ld"), + tool_path(name = "nm", path = "gcc/aarch64-linux-gnu-nm"), + tool_path(name = "objcopy", path = "gcc/aarch64-linux-gnu-objcopy"), + tool_path(name = "objdump", path = "gcc/aarch64-linux-gnu-objdump"), + tool_path(name = "strip", path = "gcc/aarch64-linux-gnu-strip"), + ] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = toolchain_identifier, + host_system_name = host_system_name, + target_system_name = target_system_name, + target_cpu = target_cpu, +target_libc = target_libc, +compiler = compiler, + abi_version = abi_version, + abi_libc_version = abi_libc_version, + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = builtin_sysroot, + cc_target_os = cc_target_os, + ) + +linaro_toolchain_config = rule( + implementation = _impl, + attrs = {}, + provides = [CcToolchainConfigInfo], +) diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/BUILD b/third_party/toolchains/embedded/linaro-gcc72-armeabi/BUILD new file mode 100644 index 00000000000..94cc9773000 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/BUILD @@ -0,0 +1,67 @@ +# This is the entry point for --crosstool_top. +# +# The cc_toolchain rule used is found by: +# +# 1. Finding the appropriate toolchain in the CROSSTOOL file based on the --cpu +# and --compiler command line flags (if they exist, otherwise using the +# "default_target_cpu" / "default_toolchain" fields in the CROSSTOOL file) +# 2. Concatenating the "target_cpu" and "compiler" fields of the toolchain in +# use and using that as a key in the map in the "toolchains" attribute +package(default_visibility = ["//visibility:public"]) + +load(":linaro_toolchain_config.bzl", "linaro_toolchain_config") + +cc_toolchain_suite( + name = "toolchain", + toolchains = { + "armv7a": ":cc-compiler-armv7a", + }, +) + +filegroup( + name = "empty", + srcs = [], +) + +filegroup( + name = "gcc_linux_all_files", + srcs = [ + "//third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc:tool-wrappers", + "@LinaroArmGcc72//:compiler_pieces", + ], +) + +filegroup( + name = "gcc_linux_linker_files", + srcs = [ + "//third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc:ld", + "//third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc:ar", + "@LinaroArmGcc72//:compiler_pieces", + ], +) + +filegroup( + name = "gcc_linux_compiler_files", + srcs = [ + "//third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc:gcc", + "//third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc:as", + ], +) + +linaro_toolchain_config(name = "linaro_armeabi-v7a") + +cc_toolchain( + name = "cc-compiler-armv7a", + all_files = ":gcc_linux_all_files", + compiler_files = ":gcc_linux_compiler_files", + toolchain_identifier = "gcc72_linaro_armhf", + toolchain_config = ":linaro_armeabi-v7a", + dwp_files = ":empty", + dynamic_runtime_lib = ":empty", + linker_files = ":gcc_linux_linker_files", + objcopy_files = "//third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc:objcopy", + static_runtime_lib = ":empty", + strip_files = "//third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc:strip", + supports_param_files = 0, + visibility = ["//visibility:public"], +) diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/BUILD b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/BUILD new file mode 100644 index 00000000000..d78c7cab00a --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/BUILD @@ -0,0 +1,79 @@ +package(default_visibility = ['//third_party/toolchains/embedded/linaro-gcc72-armeabi:__pkg__']) + +filegroup( + name = 'gcc', + srcs = [ + '@LinaroArmGcc72//:gcc', + 'arm-linux-gnueabihf-gcc', + ], +) + +filegroup( + name = 'ar', + srcs = [ + '@LinaroArmGcc72//:ar', + 'arm-linux-gnueabihf-ar', + ], +) + +filegroup( + name = 'ld', + srcs = [ + '@LinaroArmGcc72//:ld', + 'arm-linux-gnueabihf-ld', + ], +) + +filegroup( + name = 'nm', + srcs = [ + '@LinaroArmGcc72//:nm', + 'arm-linux-gnueabihf-nm', + ], +) + +filegroup( + name = 'objcopy', + srcs = [ + '@LinaroArmGcc72//:objcopy', + 'arm-linux-gnueabihf-objcopy', + ], +) + +filegroup( + name = 'objdump', + srcs = [ + '@LinaroArmGcc72//:objdump', + 'arm-linux-gnueabihf-objdump', + ], +) + +filegroup( + name = 'strip', + srcs = [ + '@LinaroArmGcc72//:strip', + 'arm-linux-gnueabihf-strip', + ], +) + +filegroup( + name = 'as', + srcs = [ + '@LinaroArmGcc72//:as', + 'arm-linux-gnueabihf-as', + ], +) + +filegroup( + name = 'tool-wrappers', + srcs = [ + ':gcc', + ':ar', + ':ld', + ':nm', + ':objcopy', + ':objdump', + ':strip', + ':as', + ], +) diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-ar b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-ar new file mode 100755 index 00000000000..8e47c75b2dd --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-ar @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a arm-linux-gnueabihf-ar \ + external/LinaroArmGcc72/bin/arm-linux-gnueabihf-ar \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-as b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-as new file mode 100755 index 00000000000..19d7dabed2c --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-as @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a arm-linux-gnueabihf-as \ + external/LinaroArmGcc72/bin/arm-linux-gnueabihf-as \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-cpp b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-cpp new file mode 100755 index 00000000000..18b715ffe77 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-cpp @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a arm-linux-gnueabihf-cpp \ + external/LinaroArmGcc72/bin/arm-linux-gnueabihf-cpp \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-gcc b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-gcc new file mode 100755 index 00000000000..50781f25ac9 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-gcc @@ -0,0 +1,6 @@ +#!/bin/bash --norc + +PATH="external/LinaroArmGcc72/libexec/gcc/arm-linux-gnueabihf/7.2.1/:$PATH" \ + exec \ + external/LinaroArmGcc72/bin/arm-linux-gnueabihf-gcc \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-gcov b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-gcov new file mode 100755 index 00000000000..403d5378dd8 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-gcov @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a arm-linux-gnueabihf-gcov \ + external/LinaroArmGcc72/bin/arm-linux-gnueabihf-gcov \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-ld b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-ld new file mode 100755 index 00000000000..283ca085ba6 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-ld @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a arm-linux-gnueabihf-ld \ + external/LinaroArmGcc72/bin/arm-linux-gnueabihf-ld \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-nm b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-nm new file mode 100755 index 00000000000..d074cfdace8 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-nm @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a arm-linux-gnueabihf-nm \ + external/LinaroArmGcc72/bin/arm-linux-gnueabihf-nm \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-objcopy b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-objcopy new file mode 100755 index 00000000000..635dfd8f8a1 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-objcopy @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a arm-linux-gnueabihf-objcopy \ + external/LinaroArmGcc72/bin/arm-linux-gnueabihf-objcopy \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-objdump b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-objdump new file mode 100755 index 00000000000..1c3614c7893 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-objdump @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a arm-linux-gnueabihf-objdump \ + external/LinaroArmGcc72/bin/arm-linux-gnueabihf-objdump \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-strip b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-strip new file mode 100755 index 00000000000..2624106ab67 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/gcc/arm-linux-gnueabihf-strip @@ -0,0 +1,5 @@ +#!/bin/bash --norc + +exec -a arm-linux-gnueabihf-strip \ + external/LinaroArmGcc72/bin/arm-linux-gnueabihf-strip \ + "$@" diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/linaro-gcc72-armeabi.BUILD b/third_party/toolchains/embedded/linaro-gcc72-armeabi/linaro-gcc72-armeabi.BUILD new file mode 100644 index 00000000000..b231d0180e3 --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/linaro-gcc72-armeabi.BUILD @@ -0,0 +1,81 @@ +package(default_visibility = ['//visibility:public']) + +filegroup( + name = 'gcc', + srcs = [ + 'bin/arm-linux-gnueabihf-gcc', + ], +) + +filegroup( + name = 'ar', + srcs = [ + 'bin/arm-linux-gnueabihf-ar', + ], +) + +filegroup( + name = 'ld', + srcs = [ + 'bin/arm-linux-gnueabihf-ld', + ], +) + +filegroup( + name = 'nm', + srcs = [ + 'bin/arm-linux-gnueabihf-nm', + ], +) + +filegroup( + name = 'objcopy', + srcs = [ + 'bin/arm-linux-gnueabihf-objcopy', + ], +) + +filegroup( + name = 'objdump', + srcs = [ + 'bin/arm-linux-gnueabihf-objdump', + ], +) + +filegroup( + name = 'strip', + srcs = [ + 'bin/arm-linux-gnueabihf-strip', + ], +) + +filegroup( + name = 'as', + srcs = [ + 'bin/arm-linux-gnueabihf-as', + ], +) + +filegroup( + name = 'compiler_pieces', + srcs = glob([ + 'arm-linux-gnueabihf/**', + 'libexec/**', + 'lib/gcc/arm-linux-gnueabihf/**', + 'include/**', + ]), +) + +filegroup( + name = 'compiler_components', + srcs = [ + ':gcc', + ':ar', + ':ld', + ':nm', + ':objcopy', + ':objdump', + ':strip', + ':as', + ], +) diff --git a/third_party/toolchains/embedded/linaro-gcc72-armeabi/linaro_toolchain_config.bzl b/third_party/toolchains/embedded/linaro-gcc72-armeabi/linaro_toolchain_config.bzl new file mode 100644 index 00000000000..293cb1e5c8e --- /dev/null +++ b/third_party/toolchains/embedded/linaro-gcc72-armeabi/linaro_toolchain_config.bzl @@ -0,0 +1,484 @@ +# Copyright 2019 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""A Starlark cc_toolchain configuration rule""" + +load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", + "action_config", + "artifact_name_pattern", + "env_entry", + "env_set", + "feature", + "feature_set", + "flag_group", + "flag_set", + "make_variable", + "tool", + "tool_path", + "variable_with_value", + "with_feature_set", +) + +load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") + +all_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, + ACTION_NAMES.lto_backend, +] + +all_cpp_compile_actions = [ + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.clif_match, +] + +preprocessor_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.clif_match, +] + +codegen_compile_actions = [ + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, +] + +all_link_actions = [ + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, +] + +def _impl(ctx): + + abi_version = "armeabi" + abi_libc_version = "glibc_2.24" + builtin_sysroot = None + compiler = "gcc" + host_system_name = "armeabi" + needs_pic = True + supports_gold_linker = False + supports_incremental_linker = False + supports_fission = False + supports_interface_shared_objects = False + supports_normalizing_ar = False + supports_start_end_lib = False + supports_thin_archives = False + target_libc = "glibc_2.24" + target_cpu = "armv7" + target_system_name = "armeabi-v7a" + toolchain_identifier = "gcc72_linaro_armhf" + cc_target_os = None + + action_configs = [] + + supports_pic_feature = feature(name = "supports_pic", enabled = True) + supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True) + + user_compile_flags_feature = feature( + name = "user_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = ["%{user_compile_flags}"], + iterate_over = "user_compile_flags", + expand_if_available = "user_compile_flags", + ), + ], + ), + ], + ) + + user_link_flags_feature = feature( + name = "user_link_flags", + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = ["%{user_link_flags}"], + iterate_over = "user_link_flags", + expand_if_available = "user_link_flags", + ), + ], + ), + ], + ) + + shared_flag_feature = feature( + name = "shared_flag", + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ACTION_NAMES.lto_index_for_dynamic_library, + ACTION_NAMES.lto_index_for_nodeps_dynamic_library, + ], + flag_groups = [flag_group(flags = ["-shared"])], + ), + ], + ) + + sysroot_feature = feature( + name = "sysroot", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ACTION_NAMES.cpp_link_executable, + ACTION_NAMES.cpp_link_dynamic_library, + ACTION_NAMES.cpp_link_nodeps_dynamic_library, + ], + flag_groups = [ + flag_group( + flags = ["--sysroot=%{sysroot}"], + expand_if_available = "sysroot", + ), + ], + ), + ], + ) + + objcopy_embed_flags_feature = feature( + name = "objcopy_embed_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = ["objcopy_embed_data"], + flag_groups = [flag_group(flags = ["-I", "binary"])], + ), + ], + ) + + unfiltered_compile_flags_feature = feature( + name = "unfiltered_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + # Make C++ compilation deterministic. Use linkstamping instead of these + # compiler symbols. + "-Wno-builtin-macro-redefined", + "-D__DATE__=\"redacted\"", + "-D__TIMESTAMP__=\"redacted\"", + "-D__TIME__=\"redacted\"", + # This makes GCC and Clang do what we want when called through symlinks. + "-no-canonical-prefixes", + ], + ), + ], + ), + ], + ) + + default_compile_flags_feature = feature( + name = "default_compile_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "-U_FORTIFY_SOURCE", + "-D_FORTIFY_SOURCE=1", + "-fstack-protector", + ], + ), + ], + ), + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [flag_group(flags = ["-g"])], + with_features = [with_feature_set(features = ["dbg"])], + ), + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "-g0", + "-O2", + "-DNDEBUG", + "-ffunction-sections", + "-fdata-sections", + ], + ), + ], + with_features = [with_feature_set(features = ["opt"])], + ), + flag_set( + actions = [ + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ], + flag_groups = [ + flag_group( + flags = [ + "-std=c++11", + "--sysroot=external/LinaroArmGcc72/arm-linux-gnueabihf/libc", + "-pthread", + "-nostdinc", + "-isystem", + "external/LinaroArmGcc72/arm-linux-gnueabihf/include/c++/7.2.1/arm-linux-gnueabihf", + "-isystem", + "external/LinaroArmGcc72/arm-linux-gnueabihf/include/c++/7.2.1", + "-isystem", + "external/LinaroArmGcc72/lib/gcc/arm-linux-gnueabihf/7.2.1/include", + "-isystem", + "external/LinaroArmGcc72/arm-linux-gnueabihf/libc/usr/include", + "-isystem", + "external/LinaroArmGcc72/lib/gcc/arm-linux-gnueabihf/7.2.1/include-fixed", + "-isystem", + "external/LinaroArmGcc72/arm-linux-gnueabihf/libc/usr/include", + "-isystem", + "external/LinaroArmGcc72/arm-linux-gnueabihf/libc/usr/include/arm-linux-gnueabihf", + "-isystem", + "external/LinaroArmGcc72/lib/gcc/arm-linux-gnueabihf/7.2.1/include", + "-isystem", + "external/LinaroArmGcc72/include/c++/7.2.1/arm-linux-gnueabihf", + "-isystem", + "external/LinaroArmGcc72/include/c++/7.2.1", + # Security hardening on by default. + "-fstack-protector", + "-fPIE", + # All warnings are enabled. Maybe enable -Werror as well? + "-Wall", + # Enable a few more warnings that aren't part of -Wall. + "-Wunused-but-set-parameter", + # But disable some that are problematic. + "-Wno-free-nonheap-object", # has false positives + # Keep stack frames for debugging, even in opt mode. + "-fno-omit-frame-pointer", + # Enable coloring even if there's no attached terminal. Bazel removes the + # escape sequences if --nocolor is specified. + "-fdiagnostics-color=always", + ], + ), + ], + ), + ], + ) + + default_link_flags_feature = feature( + name = "default_link_flags", + enabled = True, + flag_sets = [ + flag_set( + actions = all_link_actions, + flag_groups = [ + flag_group( + flags = [ + # "-target", + # "arm-linux-gnueabihf", + "--sysroot=external/LinaroArmGcc72/arm-linux-gnueabihf/libc", + "-pass-exit-codes", + "-pie", + "-lstdc++", + "-lm", + "-lpthread", + "-Wl,--dynamic-linker=/lib/ld-linux-armhf.so.3", + "-Wl,-no-as-needed", + "-Wl,-z,relro,-z,now", + "-no-canonical-prefixes", + # Stamp the binary with a unique identifier. + "-Wl,--build-id=md5", + "-Wl,--hash-style=gnu", + "-Lexternal/LinaroArmGcc72/arm-linux-gnueabihf/lib", + "-Lexternal/LinaroArmGcc72/arm-linux-gnueabihf/libc/lib", + "-Lexternal/LinaroArmGcc72/arm-linux-gnueabihf/libc/usr/lib", + "-Bexternal/LinaroArmGcc72/arm-linux-gnueabihf/bin", + ], + ), + ], + ), + flag_set( + actions = all_link_actions, + flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])], + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + + opt_feature = feature(name = "opt") + + dbg_feature = feature(name = "dbg") + + features = [ + default_compile_flags_feature, + default_link_flags_feature, + supports_dynamic_linker_feature, + supports_pic_feature, + objcopy_embed_flags_feature, + opt_feature, + dbg_feature, + user_compile_flags_feature, + user_link_flags_feature, + shared_flag_feature, + sysroot_feature, + unfiltered_compile_flags_feature, + ] + + cxx_builtin_include_directories = [ + "%package(@LinaroArmGcc72//include)%", + "%package(@LinaroArmGcc72//arm-linux-gnueabihf/libc/usr/include)%", + "%package(@LinaroArmGcc72//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/7.2.1/include-fixed)%", + "%package(@LinaroArmGcc72//include)%/c++/7.2.1", + "%package(@LinaroArmGcc72//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/7.2.1/include)%", + "%package(@LinaroArmGcc72//arm-linux-gnueabihf/libc/lib/gcc/arm-linux-gnueabihf/7.2.1/include-fixed)%", + "%package(@LinaroArmGcc72//lib/gcc/arm-linux-gnueabihf/7.2.1/include)%", + "%package(@LinaroArmGcc72//lib/gcc/arm-linux-gnueabihf/7.2.1/include-fixed)%", + "%package(@LinaroArmGcc72//arm-linux-gnueabihf/include)%/c++/7.2.1", + ] + + artifact_name_patterns = [] + make_variables = [] + + tool_paths = [ + tool_path(name = "ar", path = "gcc/arm-linux-gnueabihf-ar"), + tool_path(name = "compat-ld", path = "gcc/arm-linux-gnueabihf-ld"), + tool_path(name = "cpp", path = "gcc/arm-linux-gnueabihf-cpp"), + tool_path(name = "dwp", path = "gcc/arm-linux-gnueabihf-dwp"), + tool_path(name = "gcc", path = "gcc/arm-linux-gnueabihf-gcc"), + tool_path(name = "gcov", path = "arm-frc-linux-gnueabi/arm-frc-linux-gnueabi-gcov-4.9"), + # C(++), compiles invoke the compiler (as that is the one knowing where + # to find libraries),, but we provide LD so other rules can invoke the linker. + tool_path(name = "ld", path = "gcc/arm-linux-gnueabihf-ld"), + tool_path(name = "nm", path = "gcc/arm-linux-gnueabihf-nm"), + tool_path(name = "objcopy", path = "gcc/arm-linux-gnueabihf-objcopy"), + tool_path(name = "objdump", path = "gcc/arm-linux-gnueabihf-objdump"), + tool_path(name = "strip", path = "gcc/arm-linux-gnueabihf-strip"), + ] + + return cc_common.create_cc_toolchain_config_info( + ctx = ctx, + features = features, + action_configs = action_configs, + artifact_name_patterns = artifact_name_patterns, + cxx_builtin_include_directories = cxx_builtin_include_directories, + toolchain_identifier = toolchain_identifier, + host_system_name = host_system_name, + target_system_name = target_system_name, + target_cpu = target_cpu, + target_libc = target_libc, + compiler = compiler, + abi_version = abi_version, + abi_libc_version = abi_libc_version, + tool_paths = tool_paths, + make_variables = make_variables, + builtin_sysroot = builtin_sysroot, + cc_target_os = cc_target_os, + ) + +linaro_toolchain_config = rule( + implementation = _impl, + attrs = {}, + provides = [CcToolchainConfigInfo], +)