From 84c1e54b1165a590d4c7fd99f5bbea85db636e74 Mon Sep 17 00:00:00 2001 From: Dmitry Rozhkov Date: Mon, 28 Aug 2017 17:11:08 +0300 Subject: [PATCH] catkin.bbclass: adapt to binutils 2.29 After updating to binutils 2.29 builds fail with build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot-native/usr/bin/i586-oe-linux/../../libexec/i586-oe-linux/gcc/i586-oe-linux/7.2.0/ld: warning: libclass_loader.so, needed by /home/rojkov/work/ros/build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so, not found (try using -rpath or -rpath-link) build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot-native/usr/bin/i586-oe-linux/../../libexec/i586-oe-linux/gcc/i586-oe-linux/7.2.0/ld: warning: libroslib.so, needed by /home/rojkov/work/ros/build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so, not found (try using -rpath or -rpath-link) build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::ClassLoader::isLibraryLoaded()' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::MultiLibraryClassLoader::loadLibrary(std::__cxx11::basic_string, std::allocator > const&)' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::MultiLibraryClassLoader::MultiLibraryClassLoader(bool)' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `ros::package::getPath(std::__cxx11::basic_string, std::allocator > const&)' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::systemLibrarySuffix[abi:cxx11]()' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::class_loader_private::AbstractMetaObjectBase::isOwnedBy(class_loader::ClassLoader const*)' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::class_loader_private::getFactoryMapForBaseClass(std::__cxx11::basic_string, std::allocator > const&)' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::MultiLibraryClassLoader::getAllAvailableClassLoaders()' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::ClassLoader::hasUnmanagedInstanceBeenCreated()' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::ClassLoader::unloadLibraryInternal(bool)' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::MultiLibraryClassLoader::unloadLibrary(std::__cxx11::basic_string, std::allocator > const&)' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::class_loader_private::getPluginBaseToFactoryMapMapMutex()' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::MultiLibraryClassLoader::getRegisteredLibraries[abi:cxx11]()' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `ros::package::getPlugins(std::__cxx11::basic_string, std::allocator > const&, std::__cxx11::basic_string, std::allocator > const&, std::vector, std::allocator >, std::allocator, std::allocator > > >&, bool)' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::MultiLibraryClassLoader::~MultiLibraryClassLoader()' build/tmp-glibc/work/i586-oe-linux/kdl-parser/1.11.14-r0/recipe-sysroot/opt/ros/indigo/lib/liburdf.so: undefined reference to `class_loader::ClassLoader::loadLibrary()' because of wrong value of -Wl,-rpath provided to the cross-linker. This patch makes use of -Wl,-rpath-link option added unconditionally to all catkin-based builds to aleviate the problem. NB: The proper fix though should either replace -Wl,-rpath with -Wl,-rpath-link where it's needed or use correct path to target libs in -Wl,-rpath. Signed-off-by: Dmitry Rozhkov --- classes/catkin.bbclass | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/classes/catkin.bbclass b/classes/catkin.bbclass index dffb8d9..9fa086e 100644 --- a/classes/catkin.bbclass +++ b/classes/catkin.bbclass @@ -29,6 +29,14 @@ EXTRA_OECMAKE_prepend = "\ OECMAKE_SOURCEPATH = "${S}" OECMAKE_BUILDPATH = "${S}/build" +# Having a command like `find_package(catkin COMPONENTS roscpp)` in a package's CMakeLists.txt +# leads to adding "-Wl,-rpath=${RECIPE_SYSROOT}${ros_libdir}" option to the cross-linker. +# However starting from binutils 2.29 the cross-linker prepends this path with the value +# of --sysroot option thus producing wrong effective path (see https://sourceware.org/ml/binutils/2017-03/msg00161.html) +# These options help to aleviate the problem. +OECMAKE_C_LINK_FLAGS += "-Wl,-rpath-link=${RECIPE_SYSROOT}${ros_libdir}" +OECMAKE_CXX_LINK_FLAGS += "-Wl,-rpath-link=${RECIPE_SYSROOT}${ros_libdir}" + export BUILD_SYS export HOST_SYS