From 9304d4ba7432693c00a6052cb18203fe0b286f8d Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 28 Sep 2024 23:13:20 +0300 Subject: [PATCH] Another attempt at fixing the RPATH issue in CI --- .github/workflows/build.yml | 15 +++++++++++++-- cmake/third_party.cmake | 16 ++++++++++++++++ conanfile.py | 22 ++++++++++++++++++++++ conanfile.txt | 20 -------------------- 4 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 conanfile.py delete mode 100644 conanfile.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8d429ce2a..6cf8031da 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,10 +65,21 @@ jobs: run: cmake --build out/build --parallel --config ${{ env.BUILD_TYPE }} - name: Inspect build outputs - run: ls -lh out/build/bin/* + if: env.OPERATING_SYSTEM == 'linux' + run: | + ls -lh out/build/bin/* + (cd out/build/bin/* && for f in *; do echo $f; objdump -p $f | grep -P 'RUNPATH|RPATH' || true; done) + + - name: Debug dynamic linking issue + if: env.OPERATING_SYSTEM == 'linux' + env: + LD_DEBUG: libs + run: cd out/build/bin/*; ./common_test - name: Unit Tests - run: ctest --test-dir out/build --build-config ${{ env.BUILD_TYPE }} --output-on-failure + env: + LD_DEBUG: libs + run: export LD_DEBUG=libs; ctest --test-dir out/build --build-config ${{ env.BUILD_TYPE }} --output-on-failure - name: Regression Tests shell: bash diff --git a/cmake/third_party.cmake b/cmake/third_party.cmake index 8c7e21de4..6237cd592 100644 --- a/cmake/third_party.cmake +++ b/cmake/third_party.cmake @@ -46,6 +46,22 @@ function(copy_third_party_shared_libs target_dir) else() set(pattern "*.so*") endif() + file(GLOB_RECURSE libs "${CONAN_DEPLOYER_DIR}/*/${pattern}") file(COPY ${libs} DESTINATION "${target_dir}") + + # Set RPATH to $ORIGIN for the copied libraries + if(NOT WIN32) + file(GLOB_RECURSE PATCHELF_EXECUTABLE "${CMAKE_BINARY_DIR}/full_deploy/build/*/patchelf") + foreach(lib ${libs}) + get_filename_component(lib_name ${lib} NAME) + if(APPLE) + execute_process(COMMAND install_name_tool -add_rpath @loader_path "${target_dir}/${lib_name}" + COMMAND_ERROR_IS_FATAL ANY) + else() + execute_process(COMMAND "${PATCHELF_EXECUTABLE}" --set-rpath '$ORIGIN' "${target_dir}/${lib_name}" + COMMAND_ERROR_IS_FATAL ANY) + endif() + endforeach() + endif() endfunction() diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 000000000..71407aab3 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,22 @@ +from conan import ConanFile + +class NovatelEdiePackage(ConanFile): + settings = "os", "compiler", "build_type", "arch" + requires = [ + "nlohmann_json/[>=3.11 <3.12]", + "gegles-spdlog_setup/[>=1.1 <2]", + "spdlog/[>=1.13 <2]" + ] + default_options = { + # Statically linking against spdlog causes its singleton registry to be + # re-instantiated in each shared library or executable that links against it. + "spdlog/*:shared": True, + "fmt/*:shared": True + } + generators = "CMakeDeps", "CMakeToolchain" + cmake_layout = "cmake_layout" + + def build_requirements(self): + self.test_requires("gtest/[>=1.14 <1.15]") + if self.settings.os in ["Linux", "FreeBSD"]: + self.tool_requires("patchelf/0.18") diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100644 index 7badad415..000000000 --- a/conanfile.txt +++ /dev/null @@ -1,20 +0,0 @@ -[requires] -nlohmann_json/[>=3.11 <3.12] -gegles-spdlog_setup/[>=1.1 <2] -spdlog/[>=1.13 <2] - -[test_requires] -gtest/[>=1.14 <1.15] - -[options] -# Statically linking against spdlog causes its singleton registry to be -# re-instantiated in each shared library or executable that links against it. -spdlog/*:shared=True -fmt/*:shared=True - -[layout] -cmake_layout - -[generators] -CMakeDeps -CMakeToolchain