-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] crosscompile failed using custom cc_toolchain with platform_cpu. #261
Comments
Seems to be a hermatic issue on first glance (gcc executable is not correctly brought into the building sandbox). The ccbin is just taken from the cc toolchain in use and then passthrough, since cc_toolchain is an implicit dep, then all related files claimed by the cc toolchain config should be brought into the sandbox automatically. You might need to inspect into the Before dive deep, it is worth to first try to use |
Thanks for your quick reply!
About bazelrc, I already have it configured, the content of # +------------------------------------------------------------+
# | Startup Options |
# +------------------------------------------------------------+
startup --batch_cpu_scheduling
startup --host_jvm_args=-XX:-UseParallelGC
# offline options
common --repository_cache="./.cache"
# Don't use bzlmod yet.
common --enable_bzlmod=false
# common --registry="path/to/local/bcr/registry"
# common --enable_platform_specific_config
# --platform_suffix=platsuffix
common --default_visibility=public
# +------------------------------------------------------------+
# | Build Configurations |
# +------------------------------------------------------------+
# dist folder
build --distdir="./bazel/dist"
build --python_path=/usr/bin/python3
build --skip_incompatible_explicit_targets
# Enable colorful output of GCC
build --cxxopt="-fdiagnostics-color=always"
build --cxxopt='-std=c++17'
build --cxxopt='-D_GLIBCXX_USE_CXX11_ABI=1'
build --output_filter="^//"
build --show_timestamps
build --force_pic
# Work around the sandbox issue.
build --spawn_strategy=local
# Specify protobuf cc toolchain
build --proto_toolchain_for_cc="@com_google_protobuf//:cc_toolchain"
# cuda related configs
# Convenient flag shortcuts.
build --flag_alias=enable_cuda=@rules_cuda//cuda:enable
build --flag_alias=cuda_archs=@rules_cuda//cuda:archs
build --flag_alias=cuda_compiler=@rules_cuda//cuda:compiler
build --flag_alias=cuda_copts=@rules_cuda//cuda:copts
build --flag_alias=cuda_runtime=@rules_cuda//cuda:runtime
build --flag_alias=cuda_host_copts=@rules_cuda//cuda:host_copts
build --enable_cuda=True
build --cuda_archs=compute_86:compute_86,sm_86
# special configs
build:ubuntu_host_linux --python_path=/usr/bin/python3
build:drive_sdk_6081_linux --python_path=/usr/bin/python3
# build with profiling
build:cpu_prof --linkopt=-lprofiler
# build debug
# build --sandbox_debug
build --verbose_failures
# build --explain=./bazel.log
yes, and It's not clear what behavior/variable from return cc_common.create_cc_toolchain_config_info(
ctx = ctx,
toolchain_identifier = ctx.attr.toolchain_identifier,
host_system_name = ctx.attr.host_system_name,
target_system_name = "aarch64-buildroot-linux-gnu",
target_cpu = "aarch64-buildroot-linux-gnu",
target_libc = "gcc",
compiler = ctx.attr.gcc_repo,
cxx_builtin_include_directories = cxx_builtin_include_directories,
# builtin_sysroot = DRIVE_SDK_V5L_SYS_ROOT,
abi_version = "gcc-9.3",
abi_libc_version = ctx.attr.gcc_version,
cc_target_os = "linux",
action_configs = action_configs,
features = [
toolchain_compiler_flags,
toolchain_linker_flags,
custom_linkopts,
dbg_feature,
opt_feature,
],
)
I will get into it soon . EDIT: After watching the files in in tool_paths = {"ar": "/usr/bin/ar",
"ld": "/usr/bin/ld",
"llvm-cov": "None",
"llvm-profdata": "None",
"cpp": "/usr/bin/cpp",
"gcc": "/usr/bin/gcc",
"dwp": "/usr/bin/dwp",
"gcov": "/usr/bin/gcov",
"nm": "/usr/bin/nm",
"objcopy": "/usr/bin/objcopy",
"objdump": "/usr/bin/objdump",
"strip": "/usr/bin/strip"}, but in default-cross-toolchain(auto-generated), bazel-gw_demo/external/local_config_cc/armeabi_cc_toolchain_config.bzl tool_paths = [
tool_path(name = "ar", path = "/bin/false"),
tool_path(name = "cpp", path = "/bin/false"),
tool_path(name = "dwp", path = "/bin/false"),
tool_path(name = "gcc", path = "/bin/false"),
tool_path(name = "gcov", path = "/bin/false"),
tool_path(name = "ld", path = "/bin/false"),
tool_path(name = "llvm-profdata", path = "/bin/false"),
tool_path(name = "nm", path = "/bin/false"),
tool_path(name = "objcopy", path = "/bin/false"),
tool_path(name = "objdump", path = "/bin/false"),
tool_path(name = "strip", path = "/bin/false"),
] |
BTW, is there any plan of the project give an example to use custom/crosscompile cc_toolchain? |
After add tool_paths in cc_toolchain_config_info, the variable gets available. tool_paths = [
tool_path(
name = "ld",
path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-buildroot-linux-gnu-ld.gold",
),
tool_path(
name = "cpp",
path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-buildroot-linux-gnu-cpp",
),
tool_path(
name = "dwp",
path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-buildroot-linux-gnu-dwp",
),
tool_path(
name = "gcov",
path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-buildroot-linux-gnu-gcov",
),
tool_path(
name = "nm",
path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-buildroot-linux-gnu-nm",
),
tool_path(
name = "objcopy",
path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-buildroot-linux-gnu-objcopy",
),
tool_path(
name = "objdump",
path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-buildroot-linux-gnu-objdump",
),
tool_path(
name = "strip",
path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-buildroot-linux-gnu-strip",
),
tool_path(
name = "gcc",
path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-buildroot-linux-gnu-gcc",
),
tool_path(
name = "ar",
path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-buildroot-linux-gnu-ar",
),
] |
If it can help anyone finding this issue in the future: facing a similar issue using https://github.com/bazelbuild/rules_cc to declare my |
Digging a bit deeper, found that |
brief
NOTE: in the default platform, which is x86_64(k8) toolchain , the compile works.
I wonder if it's a bug or just a misconfiguration in the toolchain_config?
environment
bazel: version7.0.2
cctoolchain: //bazel/toolchains/v5l (a custom cc toolchain for cross compile in aarch64, like https://github.com/f0rmiga/gcc-toolchain/blob/main/toolchain/cc_toolchain_config.bzl)
repro steps
simply compile the basic example with cu_library and report the following errors.
NOTE: in the default platform, which is x86_64(k8) toolchain , the compile works.
considerations
-ccbin
parameter is inrules_cuda/cuda/private/toolchain_configs/nvcc.bzl
Lines 66 to 78 in 13a6f13
which is created from
host_compiler
, inrules_cuda/cuda/private/actions/compile.bzl
Lines 25 to 37 in 13a6f13
originaly created from
rules_cuda/cuda/private/rules/cuda_library.bzl
Lines 9 to 18 in 13a6f13
related info
there is an issue bazelbuild/bazel#22561 , which describes the
*_executable
variable empty, but I think this issue is not related here, because the variable compiler_executable is wrong withbazel/toolchains/v5l
, the gcc toolchain and some other tools are linked under the wrong directory. actually the gcc is in/drive/toolchains/aarch64--glibc--stable-2022.03-1/bin/aarch64-linux-gcc
bazelbuild/bazel#7105 this issue describes the
cc_toolchain.compiler_executable()
usage.https://bazel.build/rules/lib/providers/CcToolchainInfo#compiler_executable and https://bazel.build/configure/integrate-cpp are the bazel official doc about this topic.
the official example about this variable is here https://github.com/bazelbuild/rules_cc/blob/main/examples/write_cc_toolchain_cpu/write_cc_toolchain_cpu.bzl
I wonder if it's a bug or just a misconfiguration in the toolchain_config?
workaround(failed)
I tried to set some soft links to the toolchain crosstool, but failing with more compiling errors.
The text was updated successfully, but these errors were encountered: