Я пытаюсь кросс-компилировать посланника (использует Bazel) в lubuntu 16.04 LTS для варианта aarch64, используя цепочку инструментов Linaro на https://releases.linaro.org/components/toolchain/binaries/latest-7/aarch64-linux-gnu/gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz
Я написал собственный набор инструментов для bazel, но gperftools не удается собрать со следующей ошибкой:
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for git... /usr/bin/git
checking for style of include used by make... GNU
checking for gcc... /home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/bin/aarch64-linux-gnu-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure error: in '/tmp/tmp.JdoXpg4e35'
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
Мне кажется, тип хоста должен быть aarch64.
Мне интересно, как я задаю аргумент --host в bazel для скрипта configure, который компилирует gperftools. Также вполне возможно, что мои файлы набора инструментов неверны, так как я впервые пытался написать один.
Я пытался адаптировать учебник на https://docs.bazel.build/versions/master/tutorial/cc-toolchain-config.html#setting-up-the-build-environment
Моя сборка верхнего уровня содержит
build:cross --crosstool_top=//toolchain:aarch64
build:cross --cpu=aarch64
build:cross --host_crosstool_top=//toolchain:aarch64
build:cross --linkopt -fPIE
Мой каталог инструментов содержит файл BUILD с
package(default_visibility = ['//visibility:public'])
filegroup(name = "crossbuild")
cc_toolchain_suite(
name = "aarch64",
toolchains = {
"aarch64": ":aarch64_toolchain",
"k8": ":aarch64_toolchain",
},
)
filegroup(name = "empty")
load(":cc_toolchain_config.bzl", "cc_toolchain_config")
cc_toolchain_config(name = "aarch64_toolchain_config")
cc_toolchain(
name = "aarch64_toolchain",
toolchain_identifier = "aarch64-toolchain",
toolchain_config = ":aarch64_toolchain_config",
all_files = ":empty",
compiler_files = ":empty",
dwp_files = ":empty",
linker_files = ":empty",
objcopy_files = ":empty",
strip_files = ":empty",
supports_param_files = 0,
)
и файл с именем cc_toolchain_config.bzl с
load("@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", "tool_path")
def _impl(ctx):
tool_paths = [
tool_path(
name = "gcc",
path = "/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/bin/aarch64-linux-gnu-gcc",
),
tool_path(
name = "ld",
path = "/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/bin/aarch64-linux-gnu-ld",
),
tool_path(
name = "ar",
path = "/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/bin/aarch64-linux-gnu-ar",
),
tool_path(
name = "cpp",
path = "/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/bin/aarch64-linux-gnu-cpp",
),
tool_path(
name = "gcov",
path = "/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/bin/aarch64-linux-gnu-gcov",
),
tool_path(
name = "nm",
path = "/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/bin/aarch64-linux-gnu-nm",
),
tool_path(
name = "objdump",
path = "/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/bin/aarch64-linux-gnu-objdump",
),
tool_path(
name = "strip",
path = "/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/bin/aarch64-linux-gnu-strip",
),
]
return cc_common.create_cc_toolchain_config_info(
ctx = ctx,
toolchain_identifier = "aarch64-toolchain",
host_system_name = "x86_64-linux-gnu",
target_system_name = "aarch64",
target_cpu = "aarch64",
target_libc = "unknown",
compiler = "gcc-7.4.1",
abi_version = "unknown",
abi_libc_version = "unknown",
tool_paths=tool_paths,
cxx_builtin_include_directories=["/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/aarch64-linux-gnu/libc/usr/include/",
"/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/aarch64-linux-gnu/include/c++/7.4.1/",
"/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/aarch64-linux-gnu/include/c++/7.4.1/aarch64-linux-gnu/bits/",
"/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/aarch64-linux-gnu/libc/usr/include/",
"/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/lib/gcc/aarch64-linux-gnu/7.4.1/include/",
"/home/user/Desktop/workspace/envoy/toolchain/aarch64-linux-gnu-gcc-7.4.1/lib/gcc/aarch64-linux-gnu/7.4.1/include-fixed/"],
)
cc_toolchain_config = rule(
implementation = _impl,
attrs = {},
provides = [CcToolchainConfigInfo],
)
Я использовал эту команду сборки
bazel build --config=cross -c opt //source/exe:envoy-static.stripped --verbose_failures