I package netcdf for Fedora. I’m working on switching to cmake for building the project and having trouble with RPATHs ending up in installed files. Fedora forbids rpath in installed files. I get the following messages:
ERROR 0002: file '/usr/lib64/openmpi/hdf5/plugin/lib__nczhdf5filters.so' contains an invalid runpath '/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-openmpi' in [/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-openmpi:/usr/lib64/openmpi/lib]
ERROR 0002: file '/usr/lib64/mpich/hdf5/plugin/lib__nczhdf5filters.so' contains an invalid runpath '/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-mpich' in [/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-mpich:/usr/lib64/mpich/lib]
ERROR 0002: file '/usr/lib64/openmpi/hdf5/plugin/lib__nczstdfilters.so' contains an invalid runpath '/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-openmpi' in [/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-openmpi:/usr/lib64/openmpi/lib]
ERROR 0002: file '/usr/lib64/mpich/hdf5/plugin/lib__nczstdfilters.so' contains an invalid runpath '/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-mpich' in [/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-mpich:/usr/lib64/mpich/lib]
ERROR 0010: file '/usr/lib64/openmpi/bin/nccopy' contains an empty runpath in [:/usr/lib64/openmpi/lib]
ERROR 0010: file '/usr/lib64/openmpi/bin/ncdump' contains an empty runpath in [:/usr/lib64/openmpi/lib]
ERROR 0010: file '/usr/lib64/openmpi/bin/ncgen3' contains an empty runpath in [:/usr/lib64/openmpi/lib]
ERROR 0010: file '/usr/lib64/mpich/bin/nccopy' contains an empty runpath in [:/usr/lib64/mpich/lib]
ERROR 0010: file '/usr/lib64/openmpi/bin/ncgen' contains an empty runpath in [:/usr/lib64/openmpi/lib]
ERROR 0010: file '/usr/lib64/mpich/bin/ncdump' contains an empty runpath in [:/usr/lib64/mpich/lib]
ERROR 0010: file '/usr/lib64/mpich/bin/ncgen3' contains an empty runpath in [:/usr/lib64/mpich/lib]
ERROR 0002: file '/usr/lib64/hdf5/plugin/lib__nczhdf5filters.so' contains an invalid runpath '/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-serial' in [/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-serial]
ERROR 0010: file '/usr/lib64/mpich/bin/ncgen' contains an empty runpath in [:/usr/lib64/mpich/lib]
ERROR 0002: file '/usr/lib64/hdf5/plugin/lib__nczstdfilters.so' contains an invalid runpath '/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-serial' in [/home/orion/fedora/netcdf/netcdf-4.9.3-build/netcdf-c-main/redhat-linux-build-serial]
So basically two types of files - utilities and plugin libraries. I’ve tried to avoid this by specifying -DCMAKE_SKIP_INSTALL_RPATH=ON but that had no effect.
netcdf has the following RPATH code:
if(NOT WIN32 AND BUILD_SHARED_LIBS)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif(APPLE)
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
# set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing,
# but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif("${isSystemDir}" STREQUAL "-1")
endif()
So I guess I would expect CMAKE_INSTALL_RPATH to get set for the MPI builds, and this seems to hold for utilities. But my expectation is that setting CMAKE_SKIP_INSTALL_RPATH would have overriden it.
The plugins are currently installed with:
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${INSTALLED_PLUGIN_LIB} DESTINATION ${NETCDF_PLUGIN_INSTALL_DIR})
And I presume it’s the use of PROGRAMS that is the problem with the plugins installed in the serial build. I’ve changed that to:
install(TARGETS ${PRLUGINPRE}${PLUG} DESTINATION ${NETCDF_PLUGIN_INSTALL_DIR})
and removed the CMAKE_INSTALL_RPATH in CMakeLists.txt. That did get rid of the rpath in the serial build plugins, but did nothing for the MPI utilities. So I’m down to:
ERROR 0010: file '/usr/lib64/openmpi/hdf5/plugin/lib__nczhdf5filters.so' contains an empty runpath in [:/usr/lib64/openmpi/lib]
ERROR 0010: file '/usr/lib64/mpich/hdf5/plugin/lib__nczhdf5filters.so' contains an empty runpath in [:/usr/lib64/mpich/lib]
ERROR 0010: file '/usr/lib64/openmpi/hdf5/plugin/lib__nczstdfilters.so' contains an empty runpath in [:/usr/lib64/openmpi/lib]
ERROR 0010: file '/usr/lib64/mpich/hdf5/plugin/lib__nczstdfilters.so' contains an empty runpath in [:/usr/lib64/mpich/lib]
ERROR 0010: file '/usr/lib64/openmpi/bin/nccopy' contains an empty runpath in [:/usr/lib64/openmpi/lib]
ERROR 0010: file '/usr/lib64/openmpi/bin/ncdump' contains an empty runpath in [:/usr/lib64/openmpi/lib]
ERROR 0010: file '/usr/lib64/openmpi/bin/ncgen3' contains an empty runpath in [:/usr/lib64/openmpi/lib]
ERROR 0010: file '/usr/lib64/openmpi/bin/ncgen' contains an empty runpath in [:/usr/lib64/openmpi/lib]
ERROR 0010: file '/usr/lib64/mpich/bin/nccopy' contains an empty runpath in [:/usr/lib64/mpich/lib]
ERROR 0010: file '/usr/lib64/mpich/bin/ncdump' contains an empty runpath in [:/usr/lib64/mpich/lib]
ERROR 0010: file '/usr/lib64/mpich/bin/ncgen3' contains an empty runpath in [:/usr/lib64/mpich/lib]
ERROR 0010: file '/usr/lib64/mpich/bin/ncgen' contains an empty runpath in [:/usr/lib64/mpich/lib]
I’m also not sure why only these two plugins have the rpath - but I think probably because they are the only two that are linked to the netcdf library.
Can someone tell me how to prevent these rpaths from remaining in the installed files?