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

CMake: Fix link to atomic library in armhf and mips arch #790

Closed
wants to merge 1 commit into from

Conversation

TSC21
Copy link
Member

@TSC21 TSC21 commented Aug 25, 2017

Fixes ros/meta-ros#525.
@bulwahn can you test it and check if this addresses and fixes the problem? Thanks

@TSC21 TSC21 added this to the Version 0.21 milestone Aug 25, 2017
@TSC21
Copy link
Member Author

TSC21 commented Aug 28, 2017

@bulwahn friendly ping

bulwahn added a commit to bulwahn/mavros that referenced this pull request 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>
@bulwahn
Copy link
Contributor

bulwahn commented Aug 30, 2017

@TSC21 I proposed an alternative solution in #797, which I came up with in parallel to your solution on last Friday. Maybe you can have a look, consider which you would find better and test #797 as well, esp. if it breaks your default build setups. I will test today if this pull request also resolves the issue in meta-ros.

@bulwahn
Copy link
Contributor

bulwahn commented Aug 30, 2017

@TSC21 I tested your commit applied in meta-ros, and it remains to fail 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

for the arm architecture.
I am not sure, but I believe checking the HOST architecture might be ineffective in the cross-compiliation where you would actually want to check the TARGET architecture instead to set the flags accordingly. Rather than looking deeper into your solution now, I would be interested in your opinion of #797.
For the record, this is the build configuration I tested the commit with:

Build Configuration:
BB_VERSION        = "1.35.0"
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              = "HEAD:82ea78bd2f03b6ba4d720595d3a3fbd96e0232f9"
meta-oe           
meta-multimedia   
meta-python       = "master:ac2a6d2b5d69937577effcb8bb2149651bac0176"
meta-ros          = "mavros-solution-TSC21:8dcc2ba0c5f050dfd41c10dc8a5a9ee639f9d58c"

@TSC21
Copy link
Member Author

TSC21 commented Aug 30, 2017

I see your point. But I would like to this being added to the CMakeList and only be added the flag when required for the target architecture. Maybe changing from the HOST to the TARGET arch would work? I will add that change, and if it works we can merge this. If not, we can accept your PR.

@TSC21
Copy link
Member Author

TSC21 commented Aug 30, 2017

@bulwahn I think I found a solution to check for the TARGET arch. Will replace the code of this PR soon.

@bulwahn
Copy link
Contributor

bulwahn commented Sep 1, 2017

@TSC21 Once a new commit is available, just ping me and run tests in the cross-compile tool chain to check if it works. By the way, the issue occurs with arm, mips and ppc, not just arm and mips.

@TSC21
Copy link
Member Author

TSC21 commented Sep 1, 2017

https://github.com/axr/solar-cmake/blob/master/TargetArch.cmake seems to aid on the solution. The trouble is: there are so many archs that can be linked to the -march compile variable, so I suppose a more general explicit link would be enough, as adding this wouldn't be cost-beneficial. I'm closing this in favor of #797.

@TSC21 TSC21 closed this Sep 1, 2017
@TSC21 TSC21 deleted the armhf_atomic_fix branch September 1, 2017 10:12
vooon pushed a commit that referenced this pull request 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>
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 this pull request may close these issues.

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