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
This commit is contained in:
Rodrigo Arias 2023-12-11 18:46:05 +01:00
parent 0f7ccc89de
commit 6d584c646c
6 changed files with 31 additions and 0 deletions

View File

@ -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 - Updated process metadata to version 2 (traces generated with an older libovni
are not compatible with the emulator). are not compatible with the emulator).
- Emulation models now have a semantic version (X.Y.Z) instead of just a number. - 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 ## [1.4.1] - 2023-11-16

View File

@ -76,6 +76,8 @@ target_link_libraries(ovnitop emu parson-static ovni-static)
add_executable(ovniver ovniver.c) add_executable(ovniver ovniver.c)
target_link_libraries(ovniver ovni) 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)") set(USE_MPI ON CACHE BOOL "Use MPI (required by ovnisync)")
if(USE_MPI) if(USE_MPI)

View File

@ -2,11 +2,18 @@
* SPDX-License-Identifier: GPL-3.0-or-later */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include "ovni.h" #include "ovni.h"
int int
main(void) 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; const char *version, *commit;
ovni_version_get(&version, &commit); ovni_version_get(&version, &commit);

View File

@ -24,3 +24,4 @@ test_emu(require-repeated.c)
test_emu(thread-crash.c SHOULD_FAIL REGEX "incomplete stream") test_emu(thread-crash.c SHOULD_FAIL REGEX "incomplete stream")
test_emu(flush-tmpdir.c MP DRIVER "flush-tmpdir.driver.sh") test_emu(flush-tmpdir.c MP DRIVER "flush-tmpdir.driver.sh")
test_emu(tmpdir-metadata.c MP DRIVER "tmpdir-metadata.driver.sh") test_emu(tmpdir-metadata.c MP DRIVER "tmpdir-metadata.driver.sh")
test_emu(dummy.c NAME "ovniver" DRIVER "ovniver.driver.sh")

8
test/emu/ovni/dummy.c Normal file
View File

@ -0,0 +1,8 @@
/* Copyright (c) 2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
int
main(void)
{
return 0;
}

View File

@ -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"
)