mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-06 00:19:58 +01:00
Migrate the embedded and cpus toolchains to the GitHub toolchains directory here.
https://github.com/tensorflow/toolchains PiperOrigin-RevId: 381316817 Change-Id: I2e2c929a5f9aa1a1b8cda54e2051efb1da5778ce
This commit is contained in:
parent
c02de0b95f
commit
6a2808514d
|
|
@ -29,7 +29,7 @@ page available for this.
|
|||
|
||||
If you have a Bazel project or if you want to use TF ops, you'd better use Bazel
|
||||
build system. You'll use the integrated
|
||||
[ARM GCC 8.3 toolchains](https://github.com/tensorflow/tensorflow/tree/master/third_party/toolchains/embedded/arm-linux)
|
||||
[ARM GCC 8.3 toolchains](https://github.com/tensorflow/toolchains/tree/master/toolchains/embedded/arm-linux)
|
||||
with Bazel to build an ARM32/64 shared library.
|
||||
|
||||
| Target Architecture | Bazel Configuration | Compatible Devices |
|
||||
|
|
|
|||
|
|
@ -232,18 +232,6 @@ tensorflow/third_party/tflite_mobilenet_quant.BUILD
|
|||
tensorflow/third_party/tflite_ovic_testdata.BUILD
|
||||
tensorflow/third_party/tflite_smartreply.BUILD
|
||||
tensorflow/third_party/toolchains/BUILD
|
||||
tensorflow/third_party/toolchains/cpus/arm/BUILD
|
||||
tensorflow/third_party/toolchains/cpus/arm/arm_compiler_configure.bzl
|
||||
tensorflow/third_party/toolchains/cpus/arm/cc_config.bzl.tpl
|
||||
tensorflow/third_party/toolchains/cpus/py/BUILD
|
||||
tensorflow/third_party/toolchains/cpus/py3/BUILD
|
||||
tensorflow/third_party/toolchains/embedded/README.md
|
||||
tensorflow/third_party/toolchains/embedded/arm-linux/BUILD
|
||||
tensorflow/third_party/toolchains/embedded/arm-linux/README.md
|
||||
tensorflow/third_party/toolchains/embedded/arm-linux/aarch64-linux-toolchain.BUILD
|
||||
tensorflow/third_party/toolchains/embedded/arm-linux/arm_linux_toolchain_configure.bzl
|
||||
tensorflow/third_party/toolchains/embedded/arm-linux/armhf-linux-toolchain.BUILD
|
||||
tensorflow/third_party/toolchains/embedded/arm-linux/cc_config.bzl.tpl
|
||||
tensorflow/third_party/toolchains/preconfig/generate/BUILD
|
||||
tensorflow/third_party/toolchains/preconfig/generate/archives.bzl
|
||||
tensorflow/third_party/toolchains/preconfig/generate/generate.bzl
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ if [[ $1 == "PI_ONE" ]]; then
|
|||
# work, so pinning to the last know good version.
|
||||
git checkout 5a6a2bed9aff0ba8a18651d5514d029c8cae336a
|
||||
# If this path is changed, you'll also need to update
|
||||
# cxx_builtin_include_directory in third_party/toolchains/cpus/arm/CROSSTOOL.tpl
|
||||
# cxx_builtin_include_directory in https://github.com/tensorflow/toolchains/tree/master/toolchains/cpus/arm/CROSSTOOL.tpl
|
||||
OPENBLAS_INSTALL_PATH=/tmp/openblas_install/
|
||||
make CC=${CROSSTOOL_CC} FC=${CROSSTOOL_CC} HOSTCC=gcc TARGET=ARMV6
|
||||
make PREFIX=${OPENBLAS_INSTALL_PATH} install
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ load("//third_party/nccl:nccl_configure.bzl", "nccl_configure")
|
|||
load("//third_party/git:git_configure.bzl", "git_configure")
|
||||
load("//third_party/py:python_configure.bzl", "python_configure")
|
||||
load("//third_party/systemlibs:syslibs_configure.bzl", "syslibs_configure")
|
||||
load("//third_party/toolchains/cpus/arm:arm_compiler_configure.bzl", "arm_compiler_configure")
|
||||
load("//third_party/toolchains/embedded/arm-linux:arm_linux_toolchain_configure.bzl", "arm_linux_toolchain_configure")
|
||||
load("@tf_toolchains//toolchains/cpus/arm:arm_compiler_configure.bzl", "arm_compiler_configure")
|
||||
load("@tf_toolchains//toolchains/embedded/arm-linux:arm_linux_toolchain_configure.bzl", "arm_linux_toolchain_configure")
|
||||
load("//third_party:repo.bzl", "tf_http_archive")
|
||||
load("//third_party/clang_toolchain:cc_configure_clang.bzl", "cc_download_clang_toolchain")
|
||||
load("//tensorflow/tools/def_file_filter:def_file_filter_configure.bzl", "def_file_filter_configure")
|
||||
|
|
@ -103,7 +103,7 @@ def _tf_toolchains():
|
|||
# Point //external/local_config_arm_compiler to //external/arm_compiler
|
||||
arm_compiler_configure(
|
||||
name = "local_config_arm_compiler",
|
||||
build_file = "//third_party/toolchains/cpus/arm:BUILD",
|
||||
build_file = "@tf_toolchains//toolchains/cpus/arm:BUILD",
|
||||
remote_config_repo_arm = "../arm_compiler",
|
||||
remote_config_repo_aarch64 = "../aarch64_compiler",
|
||||
)
|
||||
|
|
@ -111,7 +111,7 @@ def _tf_toolchains():
|
|||
# TFLite crossbuild toolchain for embeddeds Linux
|
||||
arm_linux_toolchain_configure(
|
||||
name = "local_config_embedded_arm",
|
||||
build_file = "//third_party/toolchains/embedded/arm-linux:BUILD",
|
||||
build_file = "@tf_toolchains//toolchains/embedded/arm-linux:BUILD",
|
||||
aarch64_repo = "../aarch64_linux_toolchain",
|
||||
armhf_repo = "../armhf_linux_toolchain",
|
||||
)
|
||||
|
|
@ -239,7 +239,7 @@ def _tf_repositories():
|
|||
|
||||
tf_http_archive(
|
||||
name = "aarch64_linux_toolchain",
|
||||
build_file = "//third_party/toolchains/embedded/arm-linux:aarch64-linux-toolchain.BUILD",
|
||||
build_file = "@tf_toolchains//toolchains/embedded/arm-linux:aarch64-linux-toolchain.BUILD",
|
||||
sha256 = "8ce3e7688a47d8cd2d8e8323f147104ae1c8139520eca50ccf8a7fa933002731",
|
||||
strip_prefix = "gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu",
|
||||
urls = [
|
||||
|
|
@ -250,7 +250,7 @@ def _tf_repositories():
|
|||
|
||||
tf_http_archive(
|
||||
name = "armhf_linux_toolchain",
|
||||
build_file = "//third_party/toolchains/embedded/arm-linux:armhf-linux-toolchain.BUILD",
|
||||
build_file = "@tf_toolchains//toolchains/embedded/arm-linux:armhf-linux-toolchain.BUILD",
|
||||
sha256 = "d4f6480ecaa99e977e3833cc8a8e1263f9eecd1ce2d022bb548a24c4f32670f5",
|
||||
strip_prefix = "gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf",
|
||||
urls = [
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ def workspace():
|
|||
|
||||
http_archive(
|
||||
name = "tf_toolchains",
|
||||
sha256 = "df2b5df2f1ae68666083740a7e06b08323ab63b029865f84f120663d43384ead",
|
||||
strip_prefix = "toolchains-1.1.20",
|
||||
sha256 = "794ec13d2fdbc0a6fd66bcffad63cb967448e93e018151a58bbfac9808883770",
|
||||
strip_prefix = "toolchains-1.1.21",
|
||||
urls = [
|
||||
"http://mirror.tensorflow.org/github.com/tensorflow/toolchains/archive/v1.1.20.tar.gz",
|
||||
"https://github.com/tensorflow/toolchains/archive/v1.1.20.tar.gz",
|
||||
"http://mirror.tensorflow.org/github.com/tensorflow/toolchains/archive/v1.1.21.tar.gz",
|
||||
"https://github.com/tensorflow/toolchains/archive/v1.1.21.tar.gz",
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
|||
94
third_party/toolchains/cpus/arm/BUILD
vendored
94
third_party/toolchains/cpus/arm/BUILD
vendored
|
|
@ -1,94 +0,0 @@
|
|||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
# The following line is only here to make this project import into IDEs that embed
|
||||
# a Bazel toolchain.
|
||||
licenses(["notice"])
|
||||
|
||||
load(":cc_config.bzl", "cc_toolchain_config")
|
||||
|
||||
cc_toolchain_suite(
|
||||
name = "toolchain",
|
||||
toolchains = {
|
||||
"armeabi|compiler": ":cc-compiler-armeabi",
|
||||
"local|compiler": ":cc-compiler-local",
|
||||
"armeabi": ":cc-compiler-armeabi",
|
||||
"aarch64": ":cc-compiler-aarch64",
|
||||
"k8": ":cc-compiler-local",
|
||||
"piii": ":cc-compiler-local",
|
||||
"arm": ":cc-compiler-local",
|
||||
"s390x": ":cc-compiler-local",
|
||||
},
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "empty",
|
||||
srcs = [],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "arm_linux_all_files",
|
||||
srcs = [
|
||||
"@arm_compiler//:compiler_pieces",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "aarch64_linux_all_files",
|
||||
srcs = [
|
||||
"@aarch64_compiler//:aarch64_compiler_pieces",
|
||||
],
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "local_config",
|
||||
cpu = "local",
|
||||
)
|
||||
|
||||
cc_toolchain(
|
||||
name = "cc-compiler-local",
|
||||
all_files = ":empty",
|
||||
compiler_files = ":empty",
|
||||
dwp_files = ":empty",
|
||||
linker_files = ":empty",
|
||||
objcopy_files = ":empty",
|
||||
strip_files = ":empty",
|
||||
supports_param_files = 1,
|
||||
toolchain_config = ":local_config",
|
||||
toolchain_identifier = "local_linux",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "armeabi_config",
|
||||
cpu = "armeabi",
|
||||
)
|
||||
|
||||
cc_toolchain(
|
||||
name = "cc-compiler-armeabi",
|
||||
all_files = ":arm_linux_all_files",
|
||||
compiler_files = ":arm_linux_all_files",
|
||||
dwp_files = ":empty",
|
||||
linker_files = ":arm_linux_all_files",
|
||||
objcopy_files = "arm_linux_all_files",
|
||||
strip_files = "arm_linux_all_files",
|
||||
supports_param_files = 1,
|
||||
toolchain_config = ":armeabi_config",
|
||||
toolchain_identifier = "arm-linux-gnueabihf",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "aarch64_config",
|
||||
cpu = "aarch64",
|
||||
)
|
||||
|
||||
cc_toolchain(
|
||||
name = "cc-compiler-aarch64",
|
||||
all_files = ":aarch64_linux_all_files",
|
||||
compiler_files = ":aarch64_linux_all_files",
|
||||
dwp_files = ":empty",
|
||||
linker_files = ":aarch64_linux_all_files",
|
||||
objcopy_files = "aarch64_linux_all_files",
|
||||
strip_files = "aarch64_linux_all_files",
|
||||
supports_param_files = 1,
|
||||
toolchain_config = ":aarch64_config",
|
||||
toolchain_identifier = "aarch64-linux-gnu",
|
||||
)
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
"""Repository rule for arm compiler autoconfiguration."""
|
||||
|
||||
def _tpl(repository_ctx, tpl, substitutions = {}, out = None):
|
||||
if not out:
|
||||
out = tpl
|
||||
repository_ctx.template(
|
||||
out,
|
||||
Label("//third_party/toolchains/cpus/arm:%s.tpl" % tpl),
|
||||
substitutions,
|
||||
)
|
||||
|
||||
def _arm_compiler_configure_impl(repository_ctx):
|
||||
# We need to find a cross-compilation include directory for Python, so look
|
||||
# for an environment variable. Be warned, this crosstool template is only
|
||||
# regenerated on the first run of Bazel, so if you change the variable after
|
||||
# it may not be reflected in later builds. Doing a shutdown and clean of Bazel
|
||||
# doesn't fix this, you'll need to delete the generated file at something like:
|
||||
# external/local_config_arm_compiler/CROSSTOOL in your Bazel install.
|
||||
if "CROSSTOOL_PYTHON_INCLUDE_PATH" in repository_ctx.os.environ:
|
||||
python_include_path = repository_ctx.os.environ["CROSSTOOL_PYTHON_INCLUDE_PATH"]
|
||||
else:
|
||||
python_include_path = "/usr/include/python2.7"
|
||||
_tpl(repository_ctx, "cc_config.bzl", {
|
||||
"%{ARM_COMPILER_PATH}%": str(repository_ctx.path(
|
||||
repository_ctx.attr.remote_config_repo_arm,
|
||||
)),
|
||||
"%{AARCH64_COMPILER_PATH}%": str(repository_ctx.path(
|
||||
repository_ctx.attr.remote_config_repo_aarch64,
|
||||
)),
|
||||
"%{PYTHON_INCLUDE_PATH}%": python_include_path,
|
||||
})
|
||||
repository_ctx.symlink(Label(repository_ctx.attr.build_file), "BUILD")
|
||||
|
||||
arm_compiler_configure = repository_rule(
|
||||
implementation = _arm_compiler_configure_impl,
|
||||
attrs = {
|
||||
"remote_config_repo_arm": attr.string(mandatory = False, default = ""),
|
||||
"remote_config_repo_aarch64": attr.string(mandatory = False, default = ""),
|
||||
"build_file": attr.string(),
|
||||
},
|
||||
)
|
||||
845
third_party/toolchains/cpus/arm/cc_config.bzl.tpl
vendored
845
third_party/toolchains/cpus/arm/cc_config.bzl.tpl
vendored
|
|
@ -1,845 +0,0 @@
|
|||
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")
|
||||
|
||||
def _impl(ctx):
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
toolchain_identifier = "arm-linux-gnueabihf"
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
toolchain_identifier = "aarch64-linux-gnu"
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
toolchain_identifier = "local_linux"
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
host_system_name = "armeabi"
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
host_system_name = "aarch64"
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
host_system_name = "local"
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
target_system_name = "armeabi"
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
target_system_name = "aarch64"
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
target_system_name = "local"
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
target_cpu = "armeabi"
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
target_cpu = "aarch64"
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
target_cpu = "local"
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
target_libc = "armeabi"
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
target_libc = "aarch64"
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
target_libc = "local"
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
compiler = "compiler"
|
||||
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
abi_version = "armeabi"
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
abi_version = "aarch64"
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
abi_version = "local"
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
abi_libc_version = "armeabi"
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
abi_libc_version = "aarch64"
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
abi_libc_version = "local"
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
cc_target_os = None
|
||||
|
||||
builtin_sysroot = None
|
||||
|
||||
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,
|
||||
]
|
||||
|
||||
objcopy_embed_data_action = action_config(
|
||||
action_name = "objcopy_embed_data",
|
||||
enabled = True,
|
||||
tools = [tool(path = "/usr/bin/objcopy")],
|
||||
)
|
||||
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
action_configs = []
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
action_configs = []
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
action_configs = [objcopy_embed_data_action]
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
opt_feature = feature(name = "opt")
|
||||
|
||||
dbg_feature = feature(name = "dbg")
|
||||
|
||||
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",
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
if (ctx.attr.cpu == "armeabi" or ctx.attr.cpu == "aarch64"):
|
||||
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 = [
|
||||
"-Wno-builtin-macro-redefined",
|
||||
"-D__DATE__=\"redacted\"",
|
||||
"-D__TIMESTAMP__=\"redacted\"",
|
||||
"-D__TIME__=\"redacted\"",
|
||||
"-no-canonical-prefixes",
|
||||
"-fno-canonical-system-headers",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
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 = [
|
||||
"-no-canonical-prefixes",
|
||||
"-fno-canonical-system-headers",
|
||||
"-Wno-builtin-macro-redefined",
|
||||
"-D__DATE__=\"redacted\"",
|
||||
"-D__TIMESTAMP__=\"redacted\"",
|
||||
"-D__TIME__=\"redacted\"",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
else:
|
||||
unfiltered_compile_flags_feature = None
|
||||
|
||||
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"])],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
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",
|
||||
"-DRASPBERRY_PI",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
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",
|
||||
"-isystem",
|
||||
"%{ARM_COMPILER_PATH}%/lib/gcc/arm-rpi-linux-gnueabihf/6.5.0/include",
|
||||
"-isystem",
|
||||
"%{ARM_COMPILER_PATH}%/lib/gcc/arm-rpi-linux-gnueabihf/6.5.0/include-fixed",
|
||||
"-isystem",
|
||||
"%{ARM_COMPILER_PATH}%/arm-rpi-linux-gnueabihf/include/c++/6.5.0/",
|
||||
"-isystem",
|
||||
"%{ARM_COMPILER_PATH}%/arm-rpi-linux-gnueabihf/sysroot/usr/include/",
|
||||
"-isystem",
|
||||
"%{PYTHON_INCLUDE_PATH}%",
|
||||
"-isystem",
|
||||
"/usr/include/",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
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",
|
||||
"-DRASPBERRY_PI",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
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",
|
||||
"-isystem",
|
||||
"%{AARCH64_COMPILER_PATH}%/aarch64-none-linux-gnu/include/c++/9.2.1/",
|
||||
"-isystem",
|
||||
"%{AARCH64_COMPILER_PATH}%/lib/gcc/aarch64-none-linux-gnu/9.2.1/include",
|
||||
"-isystem",
|
||||
"%{AARCH64_COMPILER_PATH}%/lib/gcc/aarch64-none-linux-gnu/9.2.1/include-fixed",
|
||||
"-isystem",
|
||||
"%{AARCH64_COMPILER_PATH}%/aarch64-none-linux-gnu/libc/usr/include/",
|
||||
"-isystem",
|
||||
"%{PYTHON_INCLUDE_PATH}%",
|
||||
"-isystem",
|
||||
"/usr/include/",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
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",
|
||||
"-Wall",
|
||||
"-Wunused-but-set-parameter",
|
||||
"-Wno-free-nonheap-object",
|
||||
"-fno-omit-frame-pointer",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
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++0x"])],
|
||||
),
|
||||
],
|
||||
)
|
||||
else:
|
||||
default_compile_flags_feature = None
|
||||
|
||||
if (ctx.attr.cpu == "local"):
|
||||
default_link_flags_feature = feature(
|
||||
name = "default_link_flags",
|
||||
enabled = True,
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = all_link_actions,
|
||||
flag_groups = [
|
||||
flag_group(
|
||||
flags = [
|
||||
"-lstdc++",
|
||||
"-B/usr/bin/",
|
||||
"-Wl,-z,relro,-z,now",
|
||||
"-no-canonical-prefixes",
|
||||
"-pass-exit-codes",
|
||||
"-Wl,--build-id=md5",
|
||||
"-Wl,--hash-style=gnu",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
flag_set(
|
||||
actions = all_link_actions,
|
||||
flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])],
|
||||
with_features = [with_feature_set(features = ["opt"])],
|
||||
),
|
||||
],
|
||||
)
|
||||
elif (ctx.attr.cpu == "armeabi" or ctx.attr.cpu == "aarch64"):
|
||||
default_link_flags_feature = feature(
|
||||
name = "default_link_flags",
|
||||
enabled = True,
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = all_link_actions,
|
||||
flag_groups = [
|
||||
flag_group(
|
||||
flags = [
|
||||
"-lstdc++",
|
||||
"-Wl,-z,relro,-z,now",
|
||||
"-no-canonical-prefixes",
|
||||
"-pass-exit-codes",
|
||||
"-Wl,--build-id=md5",
|
||||
"-Wl,--hash-style=gnu",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
flag_set(
|
||||
actions = all_link_actions,
|
||||
flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])],
|
||||
with_features = [with_feature_set(features = ["opt"])],
|
||||
),
|
||||
],
|
||||
)
|
||||
else:
|
||||
default_link_flags_feature = None
|
||||
|
||||
supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
|
||||
|
||||
supports_pic_feature = feature(name = "supports_pic", 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",
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
if (ctx.attr.cpu == "local"):
|
||||
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,
|
||||
sysroot_feature,
|
||||
unfiltered_compile_flags_feature,
|
||||
]
|
||||
elif (ctx.attr.cpu == "armeabi" or ctx.attr.cpu == "aarch64"):
|
||||
features = [
|
||||
default_compile_flags_feature,
|
||||
default_link_flags_feature,
|
||||
supports_dynamic_linker_feature,
|
||||
supports_pic_feature,
|
||||
opt_feature,
|
||||
dbg_feature,
|
||||
user_compile_flags_feature,
|
||||
sysroot_feature,
|
||||
unfiltered_compile_flags_feature,
|
||||
]
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
cxx_builtin_include_directories = [
|
||||
"%{ARM_COMPILER_PATH}%/lib/gcc/arm-rpi-linux-gnueabihf/6.5.0/include",
|
||||
"%{ARM_COMPILER_PATH}%/lib/gcc/arm-rpi-linux-gnueabihf/6.5.0/include-fixed",
|
||||
"%{ARM_COMPILER_PATH}%/arm-rpi-linux-gnueabihf/sysroot/usr/include/",
|
||||
"%{ARM_COMPILER_PATH}%/arm-rpi-linux-gnueabihf/include/c++/6.5.0/",
|
||||
"/usr/include",
|
||||
"/tmp/openblas_install/include/",
|
||||
]
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
cxx_builtin_include_directories = [
|
||||
"%{AARCH64_COMPILER_PATH}%/aarch64-none-linux-gnu/include/c++/9.2.1/",
|
||||
"%{AARCH64_COMPILER_PATH}%/lib/gcc/aarch64-none-linux-gnu/9.2.1/include",
|
||||
"%{AARCH64_COMPILER_PATH}%/lib/gcc/aarch64-none-linux-gnu/9.2.1/include-fixed",
|
||||
"%{AARCH64_COMPILER_PATH}%/aarch64-none-linux-gnu/libc/usr/include/",
|
||||
"/usr/include",
|
||||
"/tmp/openblas_install/include/",
|
||||
]
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
cxx_builtin_include_directories = ["/usr/lib/gcc/", "/usr/local/include", "/usr/include"]
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
artifact_name_patterns = []
|
||||
|
||||
make_variables = []
|
||||
|
||||
if (ctx.attr.cpu == "armeabi"):
|
||||
tool_paths = [
|
||||
tool_path(
|
||||
name = "ar",
|
||||
path = "%{ARM_COMPILER_PATH}%/bin/arm-rpi-linux-gnueabihf-ar",
|
||||
),
|
||||
tool_path(name = "compat-ld", path = "/bin/false"),
|
||||
tool_path(
|
||||
name = "cpp",
|
||||
path = "%{ARM_COMPILER_PATH}%/bin/arm-rpi-linux-gnueabihf-cpp",
|
||||
),
|
||||
tool_path(
|
||||
name = "dwp",
|
||||
path = "%{ARM_COMPILER_PATH}%/bin/arm-rpi-linux-gnueabihf-dwp",
|
||||
),
|
||||
tool_path(
|
||||
name = "gcc",
|
||||
path = "%{ARM_COMPILER_PATH}%/bin/arm-rpi-linux-gnueabihf-gcc",
|
||||
),
|
||||
tool_path(
|
||||
name = "gcov",
|
||||
path = "%{ARM_COMPILER_PATH}%/bin/arm-rpi-linux-gnueabihf-gcov",
|
||||
),
|
||||
tool_path(
|
||||
name = "ld",
|
||||
path = "%{ARM_COMPILER_PATH}%/bin/arm-rpi-linux-gnueabihf-ld",
|
||||
),
|
||||
tool_path(
|
||||
name = "nm",
|
||||
path = "%{ARM_COMPILER_PATH}%/bin/arm-rpi-linux-gnueabihf-nm",
|
||||
),
|
||||
tool_path(
|
||||
name = "objcopy",
|
||||
path = "%{ARM_COMPILER_PATH}%/bin/arm-rpi-linux-gnueabihf-objcopy",
|
||||
),
|
||||
tool_path(
|
||||
name = "objdump",
|
||||
path = "%{ARM_COMPILER_PATH}%/bin/arm-rpi-linux-gnueabihf-objdump",
|
||||
),
|
||||
tool_path(
|
||||
name = "strip",
|
||||
path = "%{ARM_COMPILER_PATH}%/bin/arm-rpi-linux-gnueabihf-strip",
|
||||
),
|
||||
]
|
||||
elif (ctx.attr.cpu == "aarch64"):
|
||||
tool_paths = [
|
||||
tool_path(
|
||||
name = "ar",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-none-linux-gnu-ar",
|
||||
),
|
||||
tool_path(name = "compat-ld", path = "/bin/false"),
|
||||
tool_path(
|
||||
name = "cpp",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-none-linux-gnu-cpp",
|
||||
),
|
||||
tool_path(
|
||||
name = "dwp",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-none-linux-gnu-dwp",
|
||||
),
|
||||
tool_path(
|
||||
name = "gcc",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-none-linux-gnu-gcc",
|
||||
),
|
||||
tool_path(
|
||||
name = "gcov",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-none-linux-gnu-gcov",
|
||||
),
|
||||
tool_path(
|
||||
name = "ld",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-none-linux-gnu-ld",
|
||||
),
|
||||
tool_path(
|
||||
name = "nm",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-none-linux-gnu-nm",
|
||||
),
|
||||
tool_path(
|
||||
name = "objcopy",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-none-linux-gnu-objcopy",
|
||||
),
|
||||
tool_path(
|
||||
name = "objdump",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-none-linux-gnu-objdump",
|
||||
),
|
||||
tool_path(
|
||||
name = "strip",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-none-linux-gnu-strip",
|
||||
),
|
||||
]
|
||||
elif (ctx.attr.cpu == "local"):
|
||||
tool_paths = [
|
||||
tool_path(name = "ar", path = "/usr/bin/ar"),
|
||||
tool_path(name = "compat-ld", path = "/usr/bin/ld"),
|
||||
tool_path(name = "cpp", path = "/usr/bin/cpp"),
|
||||
tool_path(name = "dwp", path = "/usr/bin/dwp"),
|
||||
tool_path(name = "gcc", path = "/usr/bin/gcc"),
|
||||
tool_path(name = "gcov", path = "/usr/bin/gcov"),
|
||||
tool_path(name = "ld", path = "/usr/bin/ld"),
|
||||
tool_path(name = "nm", path = "/usr/bin/nm"),
|
||||
tool_path(name = "objcopy", path = "/usr/bin/objcopy"),
|
||||
tool_path(name = "objdump", path = "/usr/bin/objdump"),
|
||||
tool_path(name = "strip", path = "/usr/bin/strip"),
|
||||
]
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
|
||||
out = ctx.actions.declare_file(ctx.label.name)
|
||||
ctx.actions.write(out, "Fake executable")
|
||||
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
|
||||
),
|
||||
DefaultInfo(
|
||||
executable = out,
|
||||
),
|
||||
]
|
||||
cc_toolchain_config = rule(
|
||||
implementation = _impl,
|
||||
attrs = {
|
||||
"cpu": attr.string(mandatory=True, values=["armeabi", "aarch64", "local"]),
|
||||
},
|
||||
provides = [CcToolchainConfigInfo],
|
||||
executable = True,
|
||||
)
|
||||
177
third_party/toolchains/cpus/py/BUILD
vendored
177
third_party/toolchains/cpus/py/BUILD
vendored
File diff suppressed because one or more lines are too long
185
third_party/toolchains/cpus/py3/BUILD
vendored
185
third_party/toolchains/cpus/py3/BUILD
vendored
File diff suppressed because one or more lines are too long
4
third_party/toolchains/embedded/README.md
vendored
4
third_party/toolchains/embedded/README.md
vendored
|
|
@ -1,4 +0,0 @@
|
|||
# Embedded toolchains
|
||||
|
||||
This repository contains toolchains for various embedded systems such as
|
||||
Raspberry Pi and Coral development boards.
|
||||
66
third_party/toolchains/embedded/arm-linux/BUILD
vendored
66
third_party/toolchains/embedded/arm-linux/BUILD
vendored
|
|
@ -1,66 +0,0 @@
|
|||
load(":cc_config.bzl", "cc_toolchain_config")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
licenses(["restricted"]) # GPLv3
|
||||
|
||||
cc_toolchain_suite(
|
||||
name = "toolchain",
|
||||
toolchains = {
|
||||
"aarch64": ":cc-compiler-aarch64",
|
||||
"armhf": ":cc-compiler-armhf",
|
||||
},
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "empty",
|
||||
srcs = [],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "aarch64_toolchain_all_files",
|
||||
srcs = [
|
||||
"@aarch64_linux_toolchain//:compiler_pieces",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "armhf_toolchain_all_files",
|
||||
srcs = [
|
||||
"@armhf_linux_toolchain//:compiler_pieces",
|
||||
],
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "aarch64_toolchain_config",
|
||||
cpu = "aarch64",
|
||||
)
|
||||
|
||||
cc_toolchain_config(
|
||||
name = "armhf_toolchain_config",
|
||||
cpu = "armhf",
|
||||
)
|
||||
|
||||
cc_toolchain(
|
||||
name = "cc-compiler-aarch64",
|
||||
all_files = ":aarch64_toolchain_all_files",
|
||||
compiler_files = ":aarch64_toolchain_all_files",
|
||||
dwp_files = ":empty",
|
||||
linker_files = ":aarch64_toolchain_all_files",
|
||||
objcopy_files = "aarch64_toolchain_all_files",
|
||||
strip_files = "aarch64_toolchain_all_files",
|
||||
supports_param_files = 1,
|
||||
toolchain_config = ":aarch64_toolchain_config",
|
||||
)
|
||||
|
||||
cc_toolchain(
|
||||
name = "cc-compiler-armhf",
|
||||
all_files = ":armhf_toolchain_all_files",
|
||||
compiler_files = ":armhf_toolchain_all_files",
|
||||
dwp_files = ":empty",
|
||||
linker_files = ":armhf_toolchain_all_files",
|
||||
objcopy_files = "armhf_toolchain_all_files",
|
||||
strip_files = "armhf_toolchain_all_files",
|
||||
supports_param_files = 1,
|
||||
toolchain_config = ":armhf_toolchain_config",
|
||||
)
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
# ARM GCC toolchains
|
||||
|
||||
This repository contains Bazel C++ toolchain configurations for ARM GCC.
|
||||
The following toolchains are configured:
|
||||
|
||||
source: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads
|
||||
- gcc 8.3
|
||||
- glibc 2.28
|
||||
|
||||
target cpu: aarch64, armhf
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
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 = [
|
||||
":ar",
|
||||
":as",
|
||||
":gcc",
|
||||
":ld",
|
||||
":nm",
|
||||
":objcopy",
|
||||
":objdump",
|
||||
":strip",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
"""Repository rule for ARM cross compiler autoconfiguration."""
|
||||
|
||||
def _tpl(repository_ctx, tpl, substitutions = {}, out = None):
|
||||
if not out:
|
||||
out = tpl
|
||||
repository_ctx.template(
|
||||
out,
|
||||
Label("//third_party/toolchains/embedded/arm-linux:%s.tpl" % tpl),
|
||||
substitutions,
|
||||
)
|
||||
|
||||
def _arm_linux_toolchain_configure_impl(repository_ctx):
|
||||
# We need to find a cross-compilation include directory for Python, so look
|
||||
# for an environment variable. Be warned, this crosstool template is only
|
||||
# regenerated on the first run of Bazel, so if you change the variable after
|
||||
# it may not be reflected in later builds. Doing a shutdown and clean of Bazel
|
||||
# doesn't fix this, you'll need to delete the generated file at something like:
|
||||
# external/local_config_arm_compiler/CROSSTOOL in your Bazel install.
|
||||
if "CROSSTOOL_PYTHON_INCLUDE_PATH" in repository_ctx.os.environ:
|
||||
python_include_path = repository_ctx.os.environ["CROSSTOOL_PYTHON_INCLUDE_PATH"]
|
||||
else:
|
||||
python_include_path = "/usr/include/python3.5"
|
||||
_tpl(repository_ctx, "cc_config.bzl", {
|
||||
"%{AARCH64_COMPILER_PATH}%": str(repository_ctx.path(
|
||||
repository_ctx.attr.aarch64_repo,
|
||||
)),
|
||||
"%{ARMHF_COMPILER_PATH}%": str(repository_ctx.path(
|
||||
repository_ctx.attr.armhf_repo,
|
||||
)),
|
||||
"%{PYTHON_INCLUDE_PATH}%": python_include_path,
|
||||
})
|
||||
repository_ctx.symlink(Label(repository_ctx.attr.build_file), "BUILD")
|
||||
|
||||
arm_linux_toolchain_configure = repository_rule(
|
||||
implementation = _arm_linux_toolchain_configure_impl,
|
||||
attrs = {
|
||||
"aarch64_repo": attr.string(mandatory = True, default = ""),
|
||||
"armhf_repo": attr.string(mandatory = True, default = ""),
|
||||
"build_file": attr.string(),
|
||||
},
|
||||
)
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
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 = [
|
||||
":ar",
|
||||
":as",
|
||||
":gcc",
|
||||
":ld",
|
||||
":nm",
|
||||
":objcopy",
|
||||
":objdump",
|
||||
":strip",
|
||||
],
|
||||
)
|
||||
|
|
@ -1,619 +0,0 @@
|
|||
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")
|
||||
|
||||
def _impl(ctx):
|
||||
if (ctx.attr.cpu == "aarch64"):
|
||||
toolchain_identifier = "aarch64-linux-gnu"
|
||||
host_system_name = "aarch64"
|
||||
target_system_name = "aarch64"
|
||||
target_cpu = "aarch64"
|
||||
target_libc = "aarch64"
|
||||
abi_version = "aarch64"
|
||||
abi_libc_version = "aarch64"
|
||||
elif (ctx.attr.cpu == "armhf"):
|
||||
toolchain_identifier = "armhf-linux-gnueabihf"
|
||||
host_system_name = "armhf"
|
||||
target_system_name = "armhf"
|
||||
target_cpu = "armhf"
|
||||
target_libc = "armhf"
|
||||
abi_version = "armhf"
|
||||
abi_libc_version = "armhf"
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
compiler = "compiler"
|
||||
|
||||
cc_target_os = None
|
||||
|
||||
builtin_sysroot = None
|
||||
|
||||
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,
|
||||
]
|
||||
|
||||
if (ctx.attr.cpu == "aarch64" or ctx.attr.cpu == "armhf"):
|
||||
action_configs = []
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
opt_feature = feature(name = "opt")
|
||||
|
||||
dbg_feature = feature(name = "dbg")
|
||||
|
||||
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",
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
if (ctx.attr.cpu == "aarch64" or ctx.attr.cpu == "armhf"):
|
||||
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 = [
|
||||
"-Wno-builtin-macro-redefined",
|
||||
"-D__DATE__=\"redacted\"",
|
||||
"-D__TIMESTAMP__=\"redacted\"",
|
||||
"-D__TIME__=\"redacted\"",
|
||||
"-no-canonical-prefixes",
|
||||
"-fno-canonical-system-headers",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
else:
|
||||
unfiltered_compile_flags_feature = None
|
||||
|
||||
if (ctx.attr.cpu == "aarch64"):
|
||||
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 = [
|
||||
"-fstack-protector", # TODO: needed?
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
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 = [
|
||||
"-isystem",
|
||||
"%{AARCH64_COMPILER_PATH}%/lib/gcc/aarch64-linux-gnu/8.3.0/include",
|
||||
"-isystem",
|
||||
"%{AARCH64_COMPILER_PATH}%/lib/gcc/aarch64-linux-gnu/8.3.0/include-fixed",
|
||||
"-isystem",
|
||||
"%{AARCH64_COMPILER_PATH}%/aarch64-linux-gnu/include/c++/8.3.0/",
|
||||
"-isystem",
|
||||
"%{AARCH64_COMPILER_PATH}%/aarch64-linux-gnu/libc/usr/include/",
|
||||
"-isystem",
|
||||
"%{PYTHON_INCLUDE_PATH}%",
|
||||
"-isystem",
|
||||
"/usr/include/",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
elif (ctx.attr.cpu == "armhf"):
|
||||
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 = [
|
||||
"-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 = [
|
||||
"-isystem",
|
||||
"%{ARMHF_COMPILER_PATH}%/lib/gcc/arm-linux-gnueabihf/8.3.0/include",
|
||||
"-isystem",
|
||||
"%{ARMHF_COMPILER_PATH}%/lib/gcc/arm-linux-gnueabihf/8.3.0/include-fixed",
|
||||
"-isystem",
|
||||
"%{ARMHF_COMPILER_PATH}%/arm-linux-gnueabihf/include/c++/8.3.0/",
|
||||
"-isystem",
|
||||
"%{ARMHF_COMPILER_PATH}%/arm-linux-gnueabihf/libc/usr/include/",
|
||||
"-isystem",
|
||||
"%{PYTHON_INCLUDE_PATH}%",
|
||||
"-isystem",
|
||||
"/usr/include/",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
else:
|
||||
default_compile_flags_feature = None
|
||||
|
||||
if (ctx.attr.cpu == "aarch64"):
|
||||
default_link_flags_feature = feature(
|
||||
name = "default_link_flags",
|
||||
enabled = True,
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = all_link_actions,
|
||||
flag_groups = [
|
||||
flag_group(
|
||||
flags = [
|
||||
"-lstdc++",
|
||||
"-Wl,-z,relro,-z,now",
|
||||
"-no-canonical-prefixes",
|
||||
"-pass-exit-codes",
|
||||
"-Wl,--build-id=md5",
|
||||
"-Wl,--hash-style=gnu",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
flag_set(
|
||||
actions = all_link_actions,
|
||||
flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])],
|
||||
with_features = [with_feature_set(features = ["opt"])],
|
||||
),
|
||||
],
|
||||
)
|
||||
elif (ctx.attr.cpu == "armhf"):
|
||||
default_link_flags_feature = feature(
|
||||
name = "default_link_flags",
|
||||
enabled = True,
|
||||
flag_sets = [
|
||||
flag_set(
|
||||
actions = all_link_actions,
|
||||
flag_groups = [
|
||||
flag_group(
|
||||
flags = [
|
||||
"-lstdc++",
|
||||
"-Wl,-z,relro,-z,now",
|
||||
"-no-canonical-prefixes",
|
||||
"-pass-exit-codes",
|
||||
"-Wl,--build-id=md5",
|
||||
"-Wl,--hash-style=gnu",
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
flag_set(
|
||||
actions = all_link_actions,
|
||||
flag_groups = [flag_group(flags = ["-Wl,--gc-sections"])],
|
||||
with_features = [with_feature_set(features = ["opt"])],
|
||||
),
|
||||
],
|
||||
)
|
||||
else:
|
||||
default_link_flags_feature = None
|
||||
|
||||
supports_dynamic_linker_feature = feature(name = "supports_dynamic_linker", enabled = True)
|
||||
|
||||
supports_pic_feature = feature(name = "supports_pic", 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",
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
if (ctx.attr.cpu == "aarch64" or ctx.attr.cpu == "armhf"):
|
||||
features = [
|
||||
default_compile_flags_feature,
|
||||
default_link_flags_feature,
|
||||
supports_dynamic_linker_feature,
|
||||
supports_pic_feature,
|
||||
opt_feature,
|
||||
dbg_feature,
|
||||
user_compile_flags_feature,
|
||||
sysroot_feature,
|
||||
unfiltered_compile_flags_feature,
|
||||
]
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
if (ctx.attr.cpu == "aarch64"):
|
||||
cxx_builtin_include_directories = [
|
||||
"%{AARCH64_COMPILER_PATH}%/lib/gcc/aarch64-linux-gnu/8.3.0/include",
|
||||
"%{AARCH64_COMPILER_PATH}%/lib/gcc/aarch64-linux-gnu/8.3.0/include-fixed",
|
||||
"%{AARCH64_COMPILER_PATH}%/aarch64-linux-gnu/include/c++/8.3.0/",
|
||||
"%{AARCH64_COMPILER_PATH}%/aarch64-linux-gnu/libc/usr/include/",
|
||||
"/usr/include",
|
||||
]
|
||||
elif (ctx.attr.cpu == "armhf"):
|
||||
cxx_builtin_include_directories = [
|
||||
"%{ARMHF_COMPILER_PATH}%/lib/gcc/arm-linux-gnueabihf/8.3.0/include",
|
||||
"%{ARMHF_COMPILER_PATH}%/lib/gcc/arm-linux-gnueabihf/8.3.0/include-fixed",
|
||||
"%{ARMHF_COMPILER_PATH}%/arm-linux-gnueabihf/include/c++/8.3.0/",
|
||||
"%{ARMHF_COMPILER_PATH}%/arm-linux-gnueabihf/libc/usr/include/",
|
||||
"/usr/include",
|
||||
]
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
artifact_name_patterns = []
|
||||
|
||||
make_variables = []
|
||||
|
||||
if (ctx.attr.cpu == "aarch64"):
|
||||
tool_paths = [
|
||||
tool_path(
|
||||
name = "ar",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-linux-gnu-ar",
|
||||
),
|
||||
tool_path(name = "compat-ld", path = "/bin/false"),
|
||||
tool_path(
|
||||
name = "cpp",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-linux-gnu-cpp",
|
||||
),
|
||||
tool_path(
|
||||
name = "dwp",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-linux-gnu-dwp",
|
||||
),
|
||||
tool_path(
|
||||
name = "gcc",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-linux-gnu-gcc",
|
||||
),
|
||||
tool_path(
|
||||
name = "gcov",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-linux-gnu-gcov",
|
||||
),
|
||||
tool_path(
|
||||
name = "ld",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-linux-gnu-ld",
|
||||
),
|
||||
tool_path(
|
||||
name = "nm",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-linux-gnu-nm",
|
||||
),
|
||||
tool_path(
|
||||
name = "objcopy",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-linux-gnu-objcopy",
|
||||
),
|
||||
tool_path(
|
||||
name = "objdump",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-linux-gnu-objdump",
|
||||
),
|
||||
tool_path(
|
||||
name = "strip",
|
||||
path = "%{AARCH64_COMPILER_PATH}%/bin/aarch64-linux-gnu-strip",
|
||||
),
|
||||
]
|
||||
elif (ctx.attr.cpu == "armhf"):
|
||||
tool_paths = [
|
||||
tool_path(
|
||||
name = "ar",
|
||||
path = "%{ARMHF_COMPILER_PATH}%/bin/arm-linux-gnueabihf-ar",
|
||||
),
|
||||
tool_path(name = "compat-ld", path = "/bin/false"),
|
||||
tool_path(
|
||||
name = "cpp",
|
||||
path = "%{ARMHF_COMPILER_PATH}%/bin/arm-linux-gnueabihf-cpp",
|
||||
),
|
||||
tool_path(
|
||||
name = "dwp",
|
||||
path = "%{ARMHF_COMPILER_PATH}%/bin/arm-linux-gnueabihf-dwp",
|
||||
),
|
||||
tool_path(
|
||||
name = "gcc",
|
||||
path = "%{ARMHF_COMPILER_PATH}%/bin/arm-linux-gnueabihf-gcc",
|
||||
),
|
||||
tool_path(
|
||||
name = "gcov",
|
||||
path = "%{ARMHF_COMPILER_PATH}%/bin/arm-linux-gnueabihf-gcov",
|
||||
),
|
||||
tool_path(
|
||||
name = "ld",
|
||||
path = "%{ARMHF_COMPILER_PATH}%/bin/arm-linux-gnueabihf-ld",
|
||||
),
|
||||
tool_path(
|
||||
name = "nm",
|
||||
path = "%{ARMHF_COMPILER_PATH}%/bin/arm-linux-gnueabihf-nm",
|
||||
),
|
||||
tool_path(
|
||||
name = "objcopy",
|
||||
path = "%{ARMHF_COMPILER_PATH}%/bin/arm-linux-gnueabihf-objcopy",
|
||||
),
|
||||
tool_path(
|
||||
name = "objdump",
|
||||
path = "%{ARMHF_COMPILER_PATH}%/bin/arm-linux-gnueabihf-objdump",
|
||||
),
|
||||
tool_path(
|
||||
name = "strip",
|
||||
path = "%{ARMHF_COMPILER_PATH}%/bin/arm-linux-gnueabihf-strip",
|
||||
),
|
||||
]
|
||||
else:
|
||||
fail("Unreachable")
|
||||
|
||||
|
||||
out = ctx.actions.declare_file(ctx.label.name)
|
||||
ctx.actions.write(out, "Fake executable")
|
||||
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
|
||||
),
|
||||
DefaultInfo(
|
||||
executable = out,
|
||||
),
|
||||
]
|
||||
cc_toolchain_config = rule(
|
||||
implementation = _impl,
|
||||
attrs = {
|
||||
"cpu": attr.string(mandatory=True, values=["aarch64", "armhf"]),
|
||||
},
|
||||
provides = [CcToolchainConfigInfo],
|
||||
executable = True,
|
||||
)
|
||||
Loading…
Reference in New Issue
Block a user