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

mavros: "undefined reference to `__atomic_{load,store}_8'" while linking on qemuarm, qemumips, qemuppc #525

Closed
bulwahn opened this issue Jul 2, 2017 · 3 comments

Comments

@bulwahn
Copy link
Contributor

bulwahn commented Jul 2, 2017

On the current openembedded-core master with qemuarm and on poky pyro with qemuarm, qemumips and qemuppc, the mavros recipe fails with:

| /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot-native/usr/bin/arm-oe-linux-gnueabi/arm-oe-linux-gnueabi-g++   -march=armv5e -marm  --sysroot=/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0=/usr/src/debug/mavros/0.18.7-r0 -fdebug-prefix-map=/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot-native= -fdebug-prefix-map=/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot=  -fvisibility-inlines-hidden  -march=armv5e -marm  --sysroot=/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot -std=c++14  -march=armv5e -marm  --sysroot=/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot  -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0=/usr/src/debug/mavros/0.18.7-r0 -fdebug-prefix-map=/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot-native= -fdebug-prefix-map=/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot=  -fvisibility-inlines-hidden  -march=armv5e -marm  --sysroot=/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -rdynamic CMakeFiles/mavros_node.dir/src/mavros_node.cpp.o  -o devel/lib/mavros/mavros_node -Wl,-rpath,/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build/devel/lib:/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib: devel/lib/libmavros.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libclass_loader.so -lPocoFoundation -ldl /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libroslib.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/librospack.so -lpython3.5m -lboost_program_options-mt -ltinyxml /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libtf2_ros.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libactionlib.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libmessage_filters.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libroscpp.so -lpthread -lboost_signals-mt -lboost_filesystem-mt /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libxmlrpcpp.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libtf2.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libmavconn.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/librosconsole_bridge.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/librosconsole.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/librosconsole_log4cxx.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/librosconsole_backend_interface.so -llog4cxx -lboost_regex-mt /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libeigen_conversions.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/usr/lib/liborocos-kdl.so.1.3.0 /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libroscpp_serialization.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/librostime.so /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot/opt/ros/indigo/lib/libcpp_common.so -lboost_system-mt -lboost_thread-mt -lboost_chrono-mt -lboost_date_time-mt -lboost_atomic-mt -lconsole_bridge -lboost_system-mt -lboost_thread-mt -lboost_chrono-mt -lboost_date_time-mt -lboost_atomic-mt -lconsole_bridge
| devel/lib/libmavros.so: undefined reference to `__atomic_load_8'
| devel/lib/libmavros.so: undefined reference to `__atomic_store_8'
| collect2: error: ld returned 1 exit status
| make[2]: *** [devel/lib/mavros/gcs_bridge] Error 1
| make[2]: Leaving directory `/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build'
| make[1]: *** [CMakeFiles/gcs_bridge.dir/all] Error 2
| make[1]: *** Waiting for unfinished jobs....
| devel/lib/libmavros.so: undefined reference to `__atomic_load_8'
| devel/lib/libmavros.so: undefined reference to `__atomic_store_8'
| collect2: error: ld returned 1 exit status
| make[2]: *** [devel/lib/mavros/mavros_node] Error 1
| make[2]: Leaving directory `/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build'
| make[1]: *** [CMakeFiles/mavros_node.dir/all] Error 2
| make[2]: Entering directory `/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build'
| cd /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build && /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/recipe-sysroot-native/usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/mavros-0.18.7/mavros /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/mavros-0.18.7/mavros /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build/CMakeFiles/mavros_plugins.dir/DependInfo.cmake --color=
| make[2]: Leaving directory `/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build'
| make -f CMakeFiles/mavros_plugins.dir/build.make CMakeFiles/mavros_plugins.dir/build
| make[2]: Entering directory `/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build'
| make[2]: Nothing to be done for `CMakeFiles/mavros_plugins.dir/build'.
| make[2]: Leaving directory `/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build'
| [ 95%] Built target mavros_plugins
| make[1]: Leaving directory `/home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/build'
| make: *** [all] Error 2
| WARNING: exit code 2 from a shell command.
| ERROR: Function failed: do_compile (log file is located at /home/lukas/work/repositories/openembedded.org/openembedded-core/build/tmp-glibc/work/armv5e-oe-linux-gnueabi/mavros/0.18.7-r0/temp/log.do_compile.12713)
ERROR: Task (/home/lukas/work/repositories/github.com/bmwcarit/meta-ros/recipes-ros/mavros/mavros_0.18.7.bb:do_compile) failed with exit code '1'

I did not test yet on the current openembedded-core master with other machine than qemuarm; it probably also occurs with qemumips and qemuppc, as this failed on the poky pyro release with those machines.
These are the build configurations where mavros was failing:


Build Configuration:
BB_VERSION        = "1.33.4"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "ubuntu-14.04"
TARGET_SYS        = "arm-oe-linux-gnueabi"
MACHINE           = "qemuarm"
DISTRO            = "nodistro"
DISTRO_VERSION    = "nodistro.0"
TUNE_FEATURES     = "arm armv5 thumb dsp"
TARGET_FPU        = "soft"
meta              = "master:de7914954571ea8e717f56b6d6df13157b0973bc"
meta-oe           
meta-multimedia   
meta-python       = "master:bd259171ec0c2163a2c1025e1b83ae379cee96a7"
meta-ros          = "master:b0bf3da6d5543234bda7c87b1ea93f323e8ac469"
Build Configuration:
BB_VERSION        = "1.34.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "ubuntu-14.04"
TARGET_SYS        = "mips-poky-linux"
MACHINE           = "qemumips"
DISTRO            = "poky"
DISTRO_VERSION    = "2.3"
TUNE_FEATURES     = "o32 bigendian fpu-hard mips32r2"
TARGET_FPU        = ""
meta
meta-poky
meta-yocto-bsp    = "pyro:f0d128ea0dfc2c403ff53a1ac1db3521854b63d5"
meta-oe
meta-python
meta-multimedia   = "pyro:5e82995148a2844c6f483ae5ddd1438d87ea9fb7"
meta-ros          = "master:b0bf3da6d5543234bda7c87b1ea93f323e8ac469"
Build Configuration:
BB_VERSION        = "1.34.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "universal-4.8"
TARGET_SYS        = "powerpc-poky-linux"
MACHINE           = "qemuppc"
DISTRO            = "poky"
DISTRO_VERSION    = "2.3"
TUNE_FEATURES     = "m32 fpu-hard ppc7400 altivec"
TARGET_FPU        = ""
meta              
meta-poky         
meta-yocto-bsp    = "pyro:f0d128ea0dfc2c403ff53a1ac1db3521854b63d5"
meta-oe           
meta-python       
meta-multimedia   = "pyro:5e82995148a2844c6f483ae5ddd1438d87ea9fb7"
meta-ros          = "master:b0bf3da6d5543234bda7c87b1ea93f323e8ac469"
@bulwahn
Copy link
Contributor Author

bulwahn commented Jul 2, 2017

@TSC21 Would you have time to look into this issue? Possibly you already resolved this issue upstream and we must just apply a patch from the upstream repository?

@TSC21
Copy link

TSC21 commented Jul 3, 2017

@bulwahn it's the first time I'm seeing this problem. Most probable is a GCC compatibility issue. I will recheck the current recipe but I believe that the more we upgrade MAVROS and don't keep up with the ROS version, more problems will come.

@bulwahn
Copy link
Contributor Author

bulwahn commented Aug 25, 2017

I did some research and found out that:
For arm & mips architecture, the linker must explicitly be asked to link the atomic library (with -latomic).

Some discussions that point out the issue are:

More discussions on this error can be found by googling for undefined reference to `__atomic_load_8'.

I have a patch that resolves the issue and will provide that upstream at the mavros repository soon, discuss it, and then finally also provide a pull request here in meta-ros.

bulwahn added a commit to bulwahn/mavros that referenced this issue Aug 30, 2017
For arm & mips architecture, the linker must explicitly be asked to
link the atomic library (with `-latomic`).

Otherwise, the linking fails with:

```
| devel/lib/libmavros.so: undefined reference to `__atomic_load_8'
| devel/lib/libmavros.so: undefined reference to `__atomic_store_8'
| collect2: error: ld returned 1 exit status
```

Linking `atomic` unconditionally as library is strictly needed only
for arm & mips, but it seems not to imply any further differences
with other architectures. Hence, this commit simply adds `atomic`
unconditionally for a uniform handling of all machine architectures.

This is an alternative solution to the proposed solution in mavlink#790.

The issue was discovered cross-compiling mavros in meta-ros, the
OpenEmbedded layer for ROS. Some further pointers are available at:

  ros/meta-ros#525

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
vooon pushed a commit to mavlink/mavros that referenced this issue Sep 4, 2017
For arm & mips architecture, the linker must explicitly be asked to
link the atomic library (with `-latomic`).

Otherwise, the linking fails with:

```
| devel/lib/libmavros.so: undefined reference to `__atomic_load_8'
| devel/lib/libmavros.so: undefined reference to `__atomic_store_8'
| collect2: error: ld returned 1 exit status
```

Linking `atomic` unconditionally as library is strictly needed only
for arm & mips, but it seems not to imply any further differences
with other architectures. Hence, this commit simply adds `atomic`
unconditionally for a uniform handling of all machine architectures.

This is an alternative solution to the proposed solution in #790.

The issue was discovered cross-compiling mavros in meta-ros, the
OpenEmbedded layer for ROS. Some further pointers are available at:

  ros/meta-ros#525

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
@bulwahn bulwahn closed this as completed in 25d97e4 Sep 5, 2017
bulwahn added a commit that referenced this issue Sep 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants