Skip to content
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] bazel cross-compile protobuf with aarch64-linux-toolchain generating zlib errors. #16187

Closed
ZhenshengLee opened this issue Mar 15, 2024 · 2 comments
Labels
untriaged auto added to all issues by default when created.

Comments

@ZhenshengLee
Copy link

What version of protobuf and what language are you using?

3.14.0+cpp

What operating system (Linux, Windows, ...) and version?

Linux

What runtime / compiler are you using (e.g., python version or gcc version)

aarch64-gcc-linux 9

What did you do?

bazel configs

bazel 7.0.2 with platforms

workspace config

http_archive(
    name = "rules_proto",
    sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
    strip_prefix = "rules_proto-5.3.0-21.7",
    urls = [
        "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
    ],
)
load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
rules_proto_dependencies()
rules_proto_toolchains()

cc toolchain config

toolchains/V5L/BUILD

package(default_visibility = ["//visibility:public"])
load("//bazel/toolchains/V5L:V5L_cc_toolchain_config.bzl", "V5L_cc_toolchain_config")

DRIVE_SDK_V5L_TOOLCHAIN_ROOT = "drive/toolchains/aarch64--glibc--stable-2022.03-1"

V5L_cc_toolchain_config(
    name = "V5L_toolchain_config",
    cpu = "aarch64",
    gcc_toolchain_version = "gcc9.3",
)

cc_toolchain(
    name = "gcc_linux_aarch64_toolchain",
    all_files = ":empty",
    compiler_files = ":empty",
    dwp_files = ":empty",
    linker_files = ":empty",
    objcopy_files = "empty",
    strip_files = "empty",
    supports_param_files = 1,
    toolchain_identifier = "aarch64-buildroot-linux-gnu",
    toolchain_config = ":V5L_toolchain_config"
)

toolchain(
    name = "cc_toolchain_for_linux_aarch64",
    toolchain = ":gcc_linux_aarch64_toolchain",
    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
    exec_compatible_with = [
        "@platforms//cpu:x86_64",
        "@platforms//os:linux",
    ],
    target_compatible_with = [
        "@platforms//cpu:aarch64",
        "@platforms//os:linux",
    ],
)

filegroup(
    name = "empty",
    srcs = [],
)

filegroup(
    name = "gcc",
    srcs = [
        DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-gcc",
    ],
)

filegroup(
    name = "ar",
    srcs = [
        DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-ar",
    ],
)

filegroup(
    name = "ld",
    srcs = [
        DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-ld.bfd",
    ],
)

filegroup(
    name = "nm",
    srcs = [
        DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-nm",
    ],
)

filegroup(
    name = "objcopy",
    srcs = [
        DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-objcopy",
    ],
)

filegroup(
    name = "objdump",
    srcs = [
        DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-objdump",
    ],
)

filegroup(
    name = "strip",
    srcs = [
        DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-strip",
    ],
)

filegroup(
    name = "as",
    srcs = [
        DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-as",
    ],
)

# filegroup(
#     name = "compiler_pieces",
#     srcs = glob([
#         "usr/lib/gcc-cross/aarch64-buildroot-linux-gnu/9/**",
#         "usr/aarch64-buildroot-linux-gnu/**",
#     ]),
# )

filegroup(
    name = "compiler_components",
    srcs = [
        ":ar",
        ":as",
        ":gcc",
        ":ld",
        ":nm",
        ":objcopy",
        ":objdump",
        ":strip",
    ],
)

toolchains/V5L/V5L_cc_toolchain_config.bzl

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")

DRIVE_SDK_V5L_TOOLCHAIN_ROOT = "/drive/toolchains/aarch64--glibc--stable-2022.03-1"
DRIVE_SDK_V5L_SYS_ROOT = "/drive/drive-linux/filesystem/targetfs"

def _impl(ctx):
    toolchain_identifier = "aarch64-buildroot-linux-gnu"

    host_system_name = "x86_64-unknown-linux-gnu"

    target_system_name = "aarch64"

    target_cpu = "aarch64"

    target_libc = "aarch64"

    compiler = "compiler"

    abi_version = "aarch64"

    abi_libc_version = "aarch64"

    cc_target_os = "linux"

    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,
    ]

    action_configs = []

    coverage_feature = feature(
        name = "coverage",
        flag_sets = [
            flag_set(
                actions = [
                    ACTION_NAMES.preprocess_assemble,
                    ACTION_NAMES.c_compile,
                    ACTION_NAMES.cpp_compile,
                    ACTION_NAMES.cpp_header_parsing,
                    "c++-header-preprocessing",
                    ACTION_NAMES.cpp_module_compile,
                ],
                flag_groups = [flag_group(flags = ["-fprofile-arcs", "-ftest-coverage"])],
            ),
            flag_set(
                actions = [
                    "c++-link-interface-dynamic-library",
                    ACTION_NAMES.cpp_link_dynamic_library,
                    ACTION_NAMES.cpp_link_executable,
                ],
                flag_groups = [flag_group(flags = ["-lgcov"])],
            ),
        ],
        provides = ["profile"],
    )

    debug_feature = feature(
        name = "debug",
        flag_sets = [
            flag_set (
                actions = [
                    "ACTION_NAMES.c_compile",
                    "ACTION_NAMES.cpp_compile"
                ],
                flag_groups = [
                    flag_group(
                        flags = ["-g"],
                    ),
                ],
            )
        ],
    )

    features = [coverage_feature, debug_feature]

    gcc_include_directories_by_version = {
        "gcc9.3": [
            DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/aarch64-buildroot-linux-gnu/sysroot/usr/include/",
            DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/aarch64-buildroot-linux-gnu/include/c++/9.3.0/",
            DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/aarch64-buildroot-linux-gnu/include/c++/9.3.0/backward",
            DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/aarch64-buildroot-linux-gnu/include/",
            DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/lib/gcc/aarch64-buildroot-linux-gnu/9.3.0/include",
            DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/lib/gcc/aarch64-buildroot-linux-gnu/9.3.0/include-fixed",
        ]
    }

    cxx_builtin_include_directories = gcc_include_directories_by_version[ctx.attr.gcc_toolchain_version]
    artifact_name_patterns = []

    make_variables = []

    tool_paths = [
        tool_path(
            name = "ld",
            path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-ld.bfd",
        ),
        tool_path(
            name = "cpp",
            path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-cpp",
        ),
        tool_path(
            name = "dwp",
            path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-dwp",
        ),
        tool_path(
            name = "gcov",
            path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-gcov",
        ),
        tool_path(
            name = "nm",
            path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-nm",
        ),
        tool_path(
            name = "objcopy",
            path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-objcopy",
        ),
        tool_path(
            name = "objdump",
            path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-objdump",
        ),
        tool_path(
            name = "strip",
            path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-strip",
        ),
        tool_path(
            name = "gcc",
            path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-g++",
        ),
        tool_path(
            name = "ar",
            path = DRIVE_SDK_V5L_TOOLCHAIN_ROOT + "/bin/aarch64-linux-ar",
        ),
    ]


    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,
        ),
    ]

V5L_cc_toolchain_config =  rule(
    implementation = _impl,
    attrs = {
        "cpu": attr.string(mandatory=True, values=["aarch64"]),
        "gcc_toolchain_version": attr.string(mandatory=True, values=["gcc9.3"]),
    },
    provides = [CcToolchainConfigInfo],
    executable = True,
)

bazel command

--platforms=//bazel/platforms:drive_sdk_6081+linux

explain.log is in follow

Build options: --repository_cache=./.cache --noenable_bzlmod --distdir=./bazel/dist --cxxopt='-fdiagnostics-color=always' --cxxopt='-std=c++14' --output_filter='^//' --show_timestamps --force_pic --spawn_strategy=local --verbose_failures --explain=./bazel.log --proto_toolchain_for_cc=@com_google_protobuf//:cc_toolchain --per_file_copt='^modules/.*.cc@-Werror=conversion' --python_path=/usr/bin/python3 --jobs=4 --platforms=//bazel/platforms:drive_sdk_6081+linux --compilation_mode=opt
Executing action 'BazelWorkspaceStatusAction stable-status.txt': unconditional execution is requested.
Executing action 'Compiling src/google/protobuf/wrappers.pb.cc [for tool]': no entry in the cache (action is new).
Executing action 'Compiling zutil.c': no entry in the cache (action is new).
Executing action 'Compiling src/google/protobuf/compiler/cpp/cpp_string_field.cc [for tool]': no entry in the cache (action is new).
Executing action 'Compiling modules/team_demo/module_demo/test/demo_module/demo_test.cpp': no entry in the cache (action is new).
Executing action 'Compiling src/google/protobuf/wrappers.pb.cc': no entry in the cache (action is new).

What did you expect to see

compiling success

What did you see instead?

bazel output

(11:52:51) INFO: Current date is 2024-03-15
(11:52:54) WARNING: /gw_demo/modules/team_demo/module_demo/BUILD:45:13: runfiles symlink modules/team_demo/module_demo/install_module_src -> bazel-out/aarch64-opt/bin/modules/team_demo/module_demo/install_module_src obscured by modules/team_demo/module_demo -> modules/team_demo/module_demo
(11:52:54) WARNING: /gw_demo/modules/team_demo/module_demo/BUILD:45:13: runfiles symlink modules/team_demo/module_demo/install_src -> bazel-out/aarch64-opt/bin/modules/team_demo/module_demo/install_src obscured by modules/team_demo/module_demo -> modules/team_demo/module_demo
(11:52:54) WARNING: /gw_demo/gaos/system_test/test_af/BUILD:38:13: runfiles symlink gaos/system_test/test_af/install_module_src -> bazel-out/aarch64-opt/bin/gaos/system_test/test_af/install_module_src obscured by gaos/system_test/test_af -> gaos/system_test/test_af
(11:52:54) WARNING: /gw_demo/gaos/system_test/test_af/BUILD:38:13: runfiles symlink gaos/system_test/test_af/install_src -> bazel-out/aarch64-opt/bin/gaos/system_test/test_af/install_src obscured by gaos/system_test/test_af -> gaos/system_test/test_af
(11:52:54) WARNING: /gw_demo/gaos/system_test/test_af/BUILD:38:13: runfiles symlink gaos/system_test/test_af/install_header_src -> bazel-out/aarch64-opt/bin/gaos/system_test/test_af/install_header_src obscured by gaos/system_test/test_af -> gaos/system_test/test_af
(11:52:54) WARNING: /gw_demo/modules/team_demo/module_demo/BUILD:45:13: runfiles symlink modules/team_demo/module_demo/install_header_src -> bazel-out/aarch64-opt/bin/modules/team_demo/module_demo/install_header_src obscured by modules/team_demo/module_demo -> modules/team_demo/module_demo
(11:52:57) INFO: Analyzed 24 targets (50 packages loaded, 18664 targets configured).
(11:53:52) ERROR: /home/zs/.cache/bazel/_bazel_zs/2c098eac6c684e1fabebb74f5f4483bd/external/zlib/BUILD.bazel:37:11: Compiling adler32.c failed: (Exit 1): aarch64-linux-g++ failed: error executing CppCompile command (from target @@zlib//:zlib) 
  (cd /home/zs/.cache/bazel/_bazel_zs/2c098eac6c684e1fabebb74f5f4483bd/execroot/gaos && \
  exec env - \
    LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/lib:/usr/lib/x86_64-linux-gnu:/opt/rti.com/rti_connext_dds-6.0.1/lib/x64Linux4gcc7.3.0:/opt/ros/humble/opt/rviz_ogre_vendor/lib:/opt/ros/humble/lib/x86_64-linux-gnu:/opt/ros/humble/lib \
    PATH=/usr/local/cuda/bin:/opt/rti.com/rti_connext_dds-6.0.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/ros/humble/bin \
    PWD=/proc/self/cwd \
  /drive/toolchains/aarch64--glibc--stable-2022.03-1/bin/aarch64-linux-g++ -MD -MF bazel-out/aarch64-opt/bin/external/zlib/_objs/zlib/adler32.pic.d '-frandom-seed=bazel-out/aarch64-opt/bin/external/zlib/_objs/zlib/adler32.pic.o' -fPIC -iquote external/zlib -iquote bazel-out/aarch64-opt/bin/external/zlib -isystem external/zlib/zlib/include -isystem bazel-out/aarch64-opt/bin/external/zlib/zlib/include -Wno-unused-variable -Wno-implicit-function-declaration -c external/zlib/adler32.c -o bazel-out/aarch64-opt/bin/external/zlib/_objs/zlib/adler32.pic.o)
# Configuration: c76ccfe1b039246c80f6731290fc527500e3a40b12634d52de550b9f7488be3f
# Execution platform: @@local_config_platform//:host
cc1plus: warning: command line option '-Wno-implicit-function-declaration' is valid for C/ObjC but not for C++
external/zlib/adler32.c:63:25: error: 'uLong adler32_z' redeclared as different kind of entity
   63 | uLong ZEXPORT adler32_z(adler, buf, len)
      |                         ^~~~~
In file included from external/zlib/zutil.h:22,
                 from external/zlib/adler32.c:8:
external/zlib/zlib.h:1709:23: note: previous declaration 'uLong adler32_z(uLong, const Bytef*, z_size_t)'
 1709 | ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf,
      |                       ^~~~~~~~~
external/zlib/adler32.c:63:25: error: 'adler' was not declared in this scope; did you mean 'adler32'?
   63 | uLong ZEXPORT adler32_z(adler, buf, len)
      |                         ^~~~~
      |                         adler32
external/zlib/adler32.c:63:32: error: 'buf' was not declared in this scope
   63 | uLong ZEXPORT adler32_z(adler, buf, len)
      |                                ^~~
external/zlib/adler32.c:63:37: error: 'len' was not declared in this scope; did you mean 'mblen'?
   63 | uLong ZEXPORT adler32_z(adler, buf, len)
      |                                     ^~~
      |                                     mblen
external/zlib/adler32.c:67:1: error: expected unqualified-id before '{' token
   67 | {
      | ^
external/zlib/adler32.c:134:23: error: 'uLong adler32' redeclared as different kind of entity
  134 | uLong ZEXPORT adler32(adler, buf, len)
      |                       ^~~~~
In file included from external/zlib/zutil.h:22,
                 from external/zlib/adler32.c:8:
external/zlib/zlib.h:1689:23: note: previous declaration 'uLong adler32(uLong, const Bytef*, uInt)'
 1689 | ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
      |                       ^~~~~~~
external/zlib/adler32.c:134:23: error: 'adler' was not declared in this scope; did you mean 'adler32'?
  134 | uLong ZEXPORT adler32(adler, buf, len)
      |                       ^~~~~
      |                       adler32
external/zlib/adler32.c:136:18: error: redefinition of 'const Bytef* buf'
  136 |     const Bytef *buf;
      |                  ^~~
external/zlib/adler32.c:65:18: note: 'const Bytef* buf' previously declared here
   65 |     const Bytef *buf;
      |                  ^~~
external/zlib/adler32.c:137:10: error: conflicting declaration 'uInt len'
  137 |     uInt len;
      |          ^~~
external/zlib/adler32.c:66:14: note: previous declaration as 'z_size_t len'
   66 |     z_size_t len;
      |              ^~~
external/zlib/adler32.c:138:1: error: expected unqualified-id before '{' token
  138 | {
      | ^
external/zlib/adler32.c:143:30: error: 'uLong adler32_combine_' redeclared as different kind of entity
  143 | local uLong adler32_combine_(adler1, adler2, len2)
      |                              ^~~~~~
external/zlib/adler32.c:10:13: note: previous declaration 'uLong adler32_combine_(uLong, uLong, off64_t)'
   10 | local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
      |             ^~~~~~~~~~~~~~~~
external/zlib/adler32.c:143:30: error: 'adler1' was not declared in this scope; did you mean 'adler32'?
  143 | local uLong adler32_combine_(adler1, adler2, len2)
      |                              ^~~~~~
      |                              adler32
external/zlib/adler32.c:143:38: error: 'adler2' was not declared in this scope; did you mean 'adler32'?
  143 | local uLong adler32_combine_(adler1, adler2, len2)
      |                                      ^~~~~~
      |                                      adler32
external/zlib/adler32.c:143:46: error: 'len2' was not declared in this scope; did you mean 'len'?
  143 | local uLong adler32_combine_(adler1, adler2, len2)
      |                                              ^~~~
      |                                              len
external/zlib/adler32.c:147:1: error: expected unqualified-id before '{' token
  147 | {
      | ^
external/zlib/adler32.c:172:31: error: 'uLong adler32_combine' redeclared as different kind of entity
  172 | uLong ZEXPORT adler32_combine(adler1, adler2, len2)
      |                               ^~~~~~
In file included from external/zlib/zutil.h:22,
                 from external/zlib/adler32.c:8:
external/zlib/zlib.h:1897:26: note: previous declaration 'uLong adler32_combine(uLong, uLong, off_t)'
 1897 |    ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
      |                          ^~~~~~~~~~~~~~~
external/zlib/adler32.c:172:31: error: 'adler1' was not declared in this scope; did you mean 'adler2'?
  172 | uLong ZEXPORT adler32_combine(adler1, adler2, len2)
      |                               ^~~~~~
      |                               adler2
external/zlib/adler32.c:174:11: error: redefinition of 'uLong adler2'
  174 |     uLong adler2;
      |           ^~~~~~
external/zlib/adler32.c:145:11: note: 'uLong adler2' previously declared here
  145 |     uLong adler2;
      |           ^~~~~~
external/zlib/adler32.c:175:13: error: redefinition of 'off_t len2'
  175 |     z_off_t len2;
      |             ^~~~
external/zlib/adler32.c:146:15: note: 'off64_t len2' previously declared here
  146 |     z_off64_t len2;
      |               ^~~~
external/zlib/adler32.c:176:1: error: expected unqualified-id before '{' token
  176 | {
      | ^
external/zlib/adler32.c:180:33: error: 'uLong adler32_combine64' redeclared as different kind of entity
  180 | uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
      |                                 ^~~~~~
In file included from external/zlib/zutil.h:22,
                 from external/zlib/adler32.c:8:
external/zlib/zlib.h:1860:26: note: previous declaration 'uLong adler32_combine64(uLong, uLong, off64_t)'
 1860 |    ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t));
      |                          ^~~~~~~~~~~~~~~~~
external/zlib/adler32.c:180:33: error: 'adler1' was not declared in this scope; did you mean 'adler2'?
  180 | uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
      |                                 ^~~~~~
      |                                 adler2
external/zlib/adler32.c:182:11: error: redefinition of 'uLong adler2'
  182 |     uLong adler2;
      |           ^~~~~~
external/zlib/adler32.c:145:11: note: 'uLong adler2' previously declared here
  145 |     uLong adler2;
      |           ^~~~~~
external/zlib/adler32.c:183:15: error: redefinition of 'off64_t len2'
  183 |     z_off64_t len2;
      |               ^~~~
external/zlib/adler32.c:146:15: note: 'off64_t len2' previously declared here
  146 |     z_off64_t len2;
      |               ^~~~
external/zlib/adler32.c:184:1: error: expected unqualified-id before '{' token
  184 | {
      | ^
(11:53:53) INFO: Elapsed time: 61.160s, Critical Path: 11.92s
(11:53:53) INFO: 204 processes: 88 internal, 116 local.
(11:53:53) ERROR: Build did NOT complete successfully

Anything else we should know about your project / environment

extra infomation

only linking with protobuf lib causing the compiling error, which means only cc_binary causing the issue.

proto_library(
    name = "point_proto",
    srcs = ["proto/geometry_msgs/Point.proto"],
)
cc_proto_library(
    name = "point_cc_proto",
    deps = [":point_proto"],
)

proto_library(
    name = "freespace_boundary_proto",
    srcs = ["proto/perception_msgs/FreeSpaceBoundary.proto"],
    deps = [
        ":point_proto"
    ],
)
cc_proto_library(
    name = "freespace_boundary_cc_proto",
    deps = [":freespace_boundary_proto"],
)

# zs: todo: bug: com_google_protobuf cross-compile link failed.
gaos_cc_binary(
    name = "test_proto",
    srcs = ["test/test_proto.cpp"],
    deps = [
        ":point_cc_proto",
        "@com_google_protobuf//:protobuf",
    ],
)
@ZhenshengLee ZhenshengLee added the untriaged auto added to all issues by default when created. label Mar 15, 2024
@ZhenshengLee
Copy link
Author

track with bazelbuild/rules_proto#208

@ZhenshengLee
Copy link
Author

the issue is solved by change compiler of create_cc_toolchain_config_info from g++ to gcc adding -lstdc++, the toolchain config is based on https://github.com/hexdae/bazel-arm-none-eabi/blob/master/toolchain/config.bzl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
untriaged auto added to all issues by default when created.
Projects
None yet
Development

No branches or pull requests

1 participant