abseil / abseil-cpp

Abseil Common Libraries (C++)
https://abseil.io
Apache License 2.0
15.11k stars 2.64k forks source link

cross compile for armv7 with musl error for stacktrace_generic-inl.inc used #1214

Open xiedeacc opened 2 years ago

xiedeacc commented 2 years ago

when use bazel cross compile for armv7 with musl libc library, meet below errors, use stacktrace_arm-inl.inc by manual change stacktrace_config.h compile success, why stacktrace_config.h not detect armv7 then use stacktrace_arm-inl.inc?

ERROR: /root/src/cpp/abseil-cpp/absl/debugging/BUILD.bazel:30:11: Compiling absl/debugging/stacktrace.cc failed: (Exit 1): arm-openwrt-linux-muslgnueabi-gcc failed: error executing command external/gcc11_arm_armv7_none_musleabi/bin/arm-openwrt-linux-muslgnueabi-gcc -fPIC -fstack-protector -Wall -fno-omit-frame-pointer '--sysroot=external/gcc11_arm_armv7_none_musleabi' -pthread ... (remaining 37 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
arm-openwrt-linux-muslgnueabi-gcc: warning: environment variable 'STAGING_DIR' not defined
In file included from ./absl/debugging/internal/stacktrace_generic-inl.inc:23,
                 from absl/debugging/stacktrace.cc:46:
/usr/include/execinfo.h:23:1: error: '__BEGIN_DECLS' does not name a type
   23 | __BEGIN_DECLS
      | ^~~~~~~~~~~~~
/usr/include/execinfo.h:33:6: error: expected initializer before '__THROW'
   33 |      __THROW __nonnull ((1));
      |      ^~~~~~~
/usr/include/execinfo.h:39:6: error: expected initializer before '__THROW'
   39 |      __THROW __nonnull ((1));
      |      ^~~~~~~
/usr/include/execinfo.h:41:1: error: '__END_DECLS' does not name a type
   41 | __END_DECLS
      | ^~~~~~~~~~~
In file included from ./absl/debugging/internal/stacktrace_generic-inl.inc:25,
                 from absl/debugging/stacktrace.cc:46:
external/gcc11_arm_armv7_none_musleabi/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/11.2.0/../../../../arm-openwrt-linux-muslgnueabi/include/c++/11.2.0/cstring:77:11: error: 'memchr' has not been declared in '::'
   77 |   using ::memchr;
ljluestc commented 1 year ago

It looks like you're facing compilation errors while cross-compiling Abseil for armv7 with the Musl libc library using Bazel. The errors are related to include files and declarations, specifically in the execinfo.h header and the C++ standard library.

You mentioned that manually changing the stacktrace_config.h file to use stacktrace_arm-inl.inc resolved the issue. This indicates that the stacktrace_config.h might not be detecting the armv7 architecture correctly and thus not using the appropriate include files and configurations for Musl libc and armv7.

To address this issue, you might want to check the configuration settings in the stacktrace_config.h file for armv7 and Musl libc. Ensure that the necessary definitions and includes are present to correctly configure the stack tracing for your target platform. If the stacktrace_config.h file is not detecting the armv7 architecture, you might need to modify or extend the configuration logic to accommodate your cross-compilation setup.

Additionally, consider checking if there are any updates or fixes in more recent versions of Abseil that address compatibility issues with Musl libc and armv7 cross-compilation. You could also reach out to the Abseil development team or community forums for assistance with this specific cross-compilation issue.

CorentinLibert commented 10 months ago

Hello, I have the same issue. Did you resolved it ?