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

[fast-dds] Fix crosscompilation issues #25195

Closed

Conversation

ericriff
Copy link
Contributor

@ericriff ericriff commented Sep 9, 2024

Summary

Changes to recipe: fast-dds/all

Motivation

Fix crosscompilation issues related to transitive libraries not being properly exposed.

Details

Similarly to #25020 this recipe fails to crosscompile, particularly the test package fails to link.
Flagging these deps with transitive_libs=True fixes the problem.

fast-dds/2.14.3 (test package): RUN: cmake --build "/home/dev/workspace/conan-center-index/recipes/fast-dds/all/test_package/build/gcc-11-armv7hf-release" -- -j16
[4/4] Linking CXX executable test_package
FAILED: test_package 
: && /opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot=/opt/arm32-sdk/sysroots/armv7at2hf-neon-poky-linux-gnueabi -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -fstack-protector-strong -O3 -DNDEBUG  CMakeFiles/test_package.dir/test_package.cpp.o CMakeFiles/test_package.dir/msg2/HelloWorld.cxx.o CMakeFiles/test_package.dir/msg2/HelloWorldPubSubTypes.cxx.o -o test_package -L/home/dev/.conan2/p/b/fast-0c08f31393bf5/p/lib   -L/home/dev/.conan2/p/b/fast-aacd0f6d1136f/p/lib   -L/home/dev/.conan2/p/b/tinyxfb4b06ed47628/p/lib   -L/home/dev/.conan2/p/b/foona77b93f33d9e0e/p/lib -Wl,-rpath,/home/dev/.conan2/p/b/fast-0c08f31393bf5/p/lib:/home/dev/.conan2/p/b/fast-aacd0f6d1136f/p/lib:/home/dev/.conan2/p/b/tinyxfb4b06ed47628/p/lib:/home/dev/.conan2/p/b/foona77b93f33d9e0e/p/lib  /home/dev/.conan2/p/b/fast-0c08f31393bf5/p/lib/libfastrtps.so  -lpthread  -lrt  -ldl  -latomic  /home/dev/.conan2/p/b/fast-aacd0f6d1136f/p/lib/libfastcdr.so  -lm && :
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: warning: libfoonathan_memory-0.7.3.so, needed by /home/dev/.conan2/p/b/fast-0c08f31393bf5/p/lib/libfastrtps.so, not found (try using -rpath or -rpath-link)
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: warning: libtinyxml2.so.10, needed by /home/dev/.conan2/p/b/fast-0c08f31393bf5/p/lib/libfastrtps.so, not found (try using -rpath or -rpath-link)
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: /home/dev/.conan2/p/b/fast-0c08f31393bf5/p/lib/libfastrtps.so: undefined reference to `foonathan::memory::detail::heap_allocator_impl::info()'
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: /home/dev/.conan2/p/b/fast-0c08f31393bf5/p/lib/libfastrtps.so: undefined reference to `foonathan::memory::detail::memory_block_stack::push(foonathan::memory::memory_block)'
<...>
fast-dds/2.14.3 (test package): RUN: cmake --build "/home/dev/workspace/conan-center-index/recipes/fast-dds/all/test_package/build/gcc-11-armv7hf-release" -- -j16
[4/4] Linking CXX executable test_package
FAILED: test_package 
: && /opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot=/opt/arm32-sdk/sysroots/armv7at2hf-neon-poky-linux-gnueabi -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -fstack-protector-strong -O3 -DNDEBUG  CMakeFiles/test_package.dir/test_package.cpp.o CMakeFiles/test_package.dir/msg2/HelloWorld.cxx.o CMakeFiles/test_package.dir/msg2/HelloWorldPubSubTypes.cxx.o -o test_package -L/home/dev/.conan2/p/b/fast-614ee84b565aa/p/lib   -L/home/dev/.conan2/p/b/fast-aacd0f6d1136f/p/lib   -L/home/dev/.conan2/p/b/tinyxfb4b06ed47628/p/lib   -L/home/dev/.conan2/p/b/foona77b93f33d9e0e/p/lib -Wl,-rpath,/home/dev/.conan2/p/b/fast-614ee84b565aa/p/lib:/home/dev/.conan2/p/b/fast-aacd0f6d1136f/p/lib:/home/dev/.conan2/p/b/tinyxfb4b06ed47628/p/lib:/home/dev/.conan2/p/b/foona77b93f33d9e0e/p/lib  /home/dev/.conan2/p/b/fast-614ee84b565aa/p/lib/libfastrtps.so  -lpthread  -lrt  -ldl  -latomic  /home/dev/.conan2/p/b/fast-aacd0f6d1136f/p/lib/libfastcdr.so  -lm  /home/dev/.conan2/p/b/foona77b93f33d9e0e/p/lib/libfoonathan_memory-0.7.3.so && :
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: warning: libtinyxml2.so.10, needed by /home/dev/.conan2/p/b/fast-614ee84b565aa/p/lib/libfastrtps.so, not found (try using -rpath or -rpath-link)
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: /home/dev/.conan2/p/b/fast-614ee84b565aa/p/lib/libfastrtps.so: undefined reference to `tinyxml2::XMLElement::GetText() const'
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: /home/dev/.conan2/p/b/fast-614ee84b565aa/p/lib/libfastrtps.so: undefined reference to `tinyxml2::XMLNode::NextSiblingElement(char const*) const'
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: /home/dev/.conan2/p/b/fast-614ee84b565aa/p/lib/libfastrtps.so: undefined reference to `tinyxml2::XMLDocument::Parse(char const*, unsigned int)'
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: /home/dev/.conan2/p/b/fast-614ee84b565aa/p/lib/libfastrtps.so: undefined reference to `tinyxml2::XMLAttribute::Value() const'
<...>
fast-dds/2.14.3 (test package): RUN: cmake --build "/home/dev/workspace/conan-center-index/recipes/fast-dds/all/test_package/build/gcc-11-armv7hf-release" -- -j16
[4/4] Linking CXX executable test_package
FAILED: test_package 
: && /opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot=/opt/arm32-sdk/sysroots/armv7at2hf-neon-poky-linux-gnueabi -march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard -fstack-protector-strong -O3 -DNDEBUG  CMakeFiles/test_package.dir/test_package.cpp.o CMakeFiles/test_package.dir/msg2/HelloWorld.cxx.o CMakeFiles/test_package.dir/msg2/HelloWorldPubSubTypes.cxx.o -o test_package -L/home/dev/.conan2/p/b/fast-7b29f4fef21e4/p/lib   -L/home/dev/.conan2/p/b/fast-aacd0f6d1136f/p/lib   -L/home/dev/.conan2/p/b/tinyxfb4b06ed47628/p/lib   -L/home/dev/.conan2/p/b/foona77b93f33d9e0e/p/lib   -L/home/dev/.conan2/p/b/opens5488ed7117d28/p/lib   -L/home/dev/.conan2/p/b/zlib8373429f3ea58/p/lib -Wl,-rpath,/home/dev/.conan2/p/b/fast-7b29f4fef21e4/p/lib:/home/dev/.conan2/p/b/fast-aacd0f6d1136f/p/lib:/home/dev/.conan2/p/b/tinyxfb4b06ed47628/p/lib:/home/dev/.conan2/p/b/foona77b93f33d9e0e/p/lib:/home/dev/.conan2/p/b/opens5488ed7117d28/p/lib:/home/dev/.conan2/p/b/zlib8373429f3ea58/p/lib  /home/dev/.conan2/p/b/fast-7b29f4fef21e4/p/lib/libfastrtps.so  -latomic  /home/dev/.conan2/p/b/fast-aacd0f6d1136f/p/lib/libfastcdr.so  -lm  /home/dev/.conan2/p/b/tinyxfb4b06ed47628/p/lib/libtinyxml2.so  /home/dev/.conan2/p/b/foona77b93f33d9e0e/p/lib/libfoonathan_memory-0.7.3.so  -lpthread  -lrt  -ldl && :
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: warning: libssl.so.3, needed by /home/dev/.conan2/p/b/fast-7b29f4fef21e4/p/lib/libfastrtps.so, not found (try using -rpath or -rpath-link)
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: warning: libcrypto.so.3, needed by /home/dev/.conan2/p/b/fast-7b29f4fef21e4/p/lib/libfastrtps.so, not found (try using -rpath or -rpath-link)
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: /home/dev/.conan2/p/b/fast-7b29f4fef21e4/p/lib/libfastrtps.so: undefined reference to `ENGINE_init@OPENSSL_3.0.0'
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: /home/dev/.conan2/p/b/fast-7b29f4fef21e4/p/lib/libfastrtps.so: undefined reference to `EC_KEY_oct2key@OPENSSL_3.0.0'
/opt/arm32-sdk/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/11.3.0/real-ld: /home/dev/.conan2/p/b/fast-7b29f4fef21e4/p/lib/libfastrtps.so: undefined reference to `PEM_read_bio_Parameters@OPENSSL_3.0.0'
<...>

@ericriff
Copy link
Contributor Author

ericriff commented Sep 9, 2024

It looks like this changes based on the linker you use.
My toolchain is set up to use bfd, aka ld.
If I use gold or lld, the error goes away.

tools.build:exelinkflags=['-fuse-ld=gold']
tools.build:sharedlinkflags=['-fuse-ld=gold']

bfd's man page is explicit about this

The default behaviour is to report errors for any undefined symbols referenced in shared libraries if the linker is being used to create an executable, but to allow them if the linker is being used to create a shared library.

So I can also workaround it with

tools.build:exelinkflags=['-fuse-ld=bfd', '-Wl,--allow-shlib-undefined']

But I'm not sure if it is a good idea. LLD (clang's linker) explicitly enable it for executables as well https://nxmnpg.lemoda.net/1/ld.lld#:~:text=%2D%2Dno%2Dallow%2Dshlib,linking%20an%20executable.

Update: It looks like bfd is the linker with the best algorithm to flag these issues https://reviews.llvm.org/D57385

@conan-center-bot

This comment has been minimized.

@ericriff ericriff changed the title Fix crosscompilation issues [fast-dds] Fix crosscompilation issues Sep 27, 2024
@conan-center-bot
Copy link
Collaborator

Conan v1 pipeline ✔️

All green in build 2 (5d4c1b5f91efbd7fd4501fc6ffee696583e8cd21):

  • fast-dds/2.14.0:
    Built 10 packages out of 22 (All logs)

  • fast-dds/2.14.3:
    Built 10 packages out of 22 (All logs)

  • fast-dds/2.11.2:
    Built 10 packages out of 22 (All logs)

  • fast-dds/2.10.1:
    Built 18 packages out of 22 (All logs)

  • fast-dds/2.13.3:
    Built 10 packages out of 22 (All logs)

  • fast-dds/2.3.4:
    Built 18 packages out of 22 (All logs)

@jcar87
Copy link
Contributor

jcar87 commented Nov 4, 2024

It looks like this changes based on the linker you use. My toolchain is set up to use bfd, aka ld. If I use gold or lld, the error goes away.

tools.build:exelinkflags=['-fuse-ld=gold']
tools.build:sharedlinkflags=['-fuse-ld=gold']

bfd's man page is explicit about this

The default behaviour is to report errors for any undefined symbols referenced in shared libraries if the linker is being used to create an executable, but to allow them if the linker is being used to create a shared library.

So I can also workaround it with

tools.build:exelinkflags=['-fuse-ld=bfd', '-Wl,--allow-shlib-undefined']

But I'm not sure if it is a good idea. LLD (clang's linker) explicitly enable it for executables as well https://nxmnpg.lemoda.net/1/ld.lld#:~:text=%2D%2Dno%2Dallow%2Dshlib,linking%20an%20executable.

Update: It looks like bfd is the linker with the best algorithm to flag these issues https://reviews.llvm.org/D57385

It looks like this changes based on the linker you use.
My toolchain is set up to use bfd, aka ld.
If I use gold or lld, the error goes away.

This is a well known behaviour of the bfd linker compared to... well, any other linker on any platform. I doubt it is an issue - it is just how it has always worked, and a behaviour that neither gold, nor lld nor mold have retained.

On the other hand, there is probably a Conan and/or CMake issue here as well - personally the workarounds you are suggesting are perfectly valid and I Would not modify the recipe behaviour.

@ericriff
Copy link
Contributor Author

On the other hand, there is probably a Conan and/or CMake issue here as well - personally the workarounds you are suggesting are perfectly valid and I Would not modify the recipe behaviour.
With workarounds do you mean using a diff linker? I personally don't mind, but bdf/ld being (usually) the default I think some other people will encounter this problem as well.

I don't mind closing the PR if you think it is not worth it to patch the recipe.

@jcar87
Copy link
Contributor

jcar87 commented Dec 9, 2024

Hi @ericriff - thanks for your reply.

Tested this locally on armv8 and transitive_libs=True is indeed not needed - I believe this is a manifestation of
conan-io/conan#17256

That is, this only happens when crossbuilding, using the GNU Linker, and there is --sysroot - where CMake/Conan should end up passing -rpath-link but instead pass -rpath - I'll be looking further into this bug this week - as it can affect other cross-compilation cases in other recipes, and not just this one.

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.

4 participants