From 6d584c646c35f33649a299dd2abe8bbfd7b13adc Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Mon, 11 Dec 2023 18:46:05 +0100 Subject: [PATCH] Install ovniver with the runpath set When running ovniver without LD_LIBRARY_PATH set, the loader couldn't find any ovni installation and therefore was failing to start the program. With this change we set the RUNPATH (not RPATH) of ovniver to the installation libdir, so when no other libovni library is loaded via LD_LIBRARY_PATH the one provided by the same source as ovniver is used. The value of LD_LIBRARY_PATH is also printed so we can determine where it may be loading libovni. Using LD_DEBUG=libs will give more information of the search process. Fixes: https://pm.bsc.es/gitlab/rarias/ovni/-/issues/163 --- CHANGELOG.md | 1 + src/emu/CMakeLists.txt | 2 ++ src/emu/ovniver.c | 7 +++++++ test/emu/ovni/CMakeLists.txt | 1 + test/emu/ovni/dummy.c | 8 ++++++++ test/emu/ovni/ovniver.driver.sh | 12 ++++++++++++ 6 files changed, 31 insertions(+) create mode 100644 test/emu/ovni/dummy.c create mode 100644 test/emu/ovni/ovniver.driver.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index df64be2..190f899 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated process metadata to version 2 (traces generated with an older libovni are not compatible with the emulator). - Emulation models now have a semantic version (X.Y.Z) instead of just a number. +- Install ovniver with the runpath set. ## [1.4.1] - 2023-11-16 diff --git a/src/emu/CMakeLists.txt b/src/emu/CMakeLists.txt index c252c6c..b894965 100644 --- a/src/emu/CMakeLists.txt +++ b/src/emu/CMakeLists.txt @@ -76,6 +76,8 @@ target_link_libraries(ovnitop emu parson-static ovni-static) add_executable(ovniver ovniver.c) target_link_libraries(ovniver ovni) +set_property(TARGET ovniver + PROPERTY INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") set(USE_MPI ON CACHE BOOL "Use MPI (required by ovnisync)") if(USE_MPI) diff --git a/src/emu/ovniver.c b/src/emu/ovniver.c index 6cc06e5..3c26a25 100644 --- a/src/emu/ovniver.c +++ b/src/emu/ovniver.c @@ -2,11 +2,18 @@ * SPDX-License-Identifier: GPL-3.0-or-later */ #include +#include #include "ovni.h" int main(void) { + const char *libpath = getenv("LD_LIBRARY_PATH"); + if (libpath != NULL) + printf("LD_LIBRARY_PATH set to %s\n", libpath); + else + printf("LD_LIBRARY_PATH not set\n"); + const char *version, *commit; ovni_version_get(&version, &commit); diff --git a/test/emu/ovni/CMakeLists.txt b/test/emu/ovni/CMakeLists.txt index 879df11..7f28418 100644 --- a/test/emu/ovni/CMakeLists.txt +++ b/test/emu/ovni/CMakeLists.txt @@ -24,3 +24,4 @@ test_emu(require-repeated.c) test_emu(thread-crash.c SHOULD_FAIL REGEX "incomplete stream") test_emu(flush-tmpdir.c MP DRIVER "flush-tmpdir.driver.sh") test_emu(tmpdir-metadata.c MP DRIVER "tmpdir-metadata.driver.sh") +test_emu(dummy.c NAME "ovniver" DRIVER "ovniver.driver.sh") diff --git a/test/emu/ovni/dummy.c b/test/emu/ovni/dummy.c new file mode 100644 index 0000000..861cd12 --- /dev/null +++ b/test/emu/ovni/dummy.c @@ -0,0 +1,8 @@ +/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC) + * SPDX-License-Identifier: GPL-3.0-or-later */ + +int +main(void) +{ + return 0; +} diff --git a/test/emu/ovni/ovniver.driver.sh b/test/emu/ovni/ovniver.driver.sh new file mode 100644 index 0000000..e8efcc1 --- /dev/null +++ b/test/emu/ovni/ovniver.driver.sh @@ -0,0 +1,12 @@ +# Test ovniver as-is +( + ovniver +) + +# Test LD_LIBRARY_PATH check in ovniver +( + export LD_LIBRARY_PATH=/hopefully/nothing/is/here + ovniver | grep "LD_LIBRARY_PATH set to" + unset LD_LIBRARY_PATH + ovniver | grep "LD_LIBRARY_PATH not set" +)