krallin / tini

A tiny but valid `init` for containers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

static-tini installation fails with "No valid ELF RPATH or RUNPATH entry exists in the file" message

Apteryks opened this issue · comments

Here's an excerpt of the build log, using GNU Guix:

[...]
[100%] Built target tini
make[1]: Leaving directory '/tmp/guix-build-tini-0.19.0.drv-0/build'
/gnu/store/qixwn3dw6glj848hrr3h8fxm6s7wzxm3-cmake-minimal-3.16.5/bin/cmake -E cmake_progress_start /tmp/guix-build-tini-0.19.0.drv-0/build/CMakeFiles 0
make -f CMakeFiles/Makefile2 preinstall
make[1]: Entering directory '/tmp/guix-build-tini-0.19.0.drv-0/build'
make[1]: Nothing to be done for 'preinstall'.
make[1]: Leaving directory '/tmp/guix-build-tini-0.19.0.drv-0/build'
Install the project...
/gnu/store/qixwn3dw6glj848hrr3h8fxm6s7wzxm3-cmake-minimal-3.16.5/bin/cmake -P cmake_install.cmake
-- Install configuration: "RelWithDebInfo"
-- Installing: /gnu/store/45ml8i8ja7cfyiwydakxfq9pymk5z04k-tini-0.19.0/bin/tini
-- Set runtime path of "/gnu/store/45ml8i8ja7cfyiwydakxfq9pymk5z04k-tini-0.19.0/bin/tini" to "/gnu/store/45ml8i8ja7cfyiwydakxfq9pymk5z04k-tini-0.19.0/lib"
-- Installing: /gnu/store/45ml8i8ja7cfyiwydakxfq9pymk5z04k-tini-0.19.0/bin/tini-static
CMake Error at cmake_install.cmake:70 (file):
  file RPATH_CHANGE could not write new RPATH:

    /gnu/store/45ml8i8ja7cfyiwydakxfq9pymk5z04k-tini-0.19.0/lib

  to the file:

    /gnu/store/45ml8i8ja7cfyiwydakxfq9pymk5z04k-tini-0.19.0/bin/tini-static

  No valid ELF RPATH or RUNPATH entry exists in the file;


make: *** [Makefile:89: install] Error 1
command "make" "install" failed with status 2
builder for `/gnu/store/h3cbka6s0fvrsq4b56nq0v3vdiggql1d-tini-0.19.0.drv' failed with exit code 1
@ build-failed /gnu/store/h3cbka6s0fvrsq4b56nq0v3vdiggql1d-tini-0.19.0.drv - 1 builder for `/gnu/store/h3cbka6s0fvrsq4b56nq0v3vdiggql1d-tini-0.19.0.drv' failed with exit code 1
derivation '/gnu/store/h3cbka6s0fvrsq4b56nq0v3vdiggql1d-tini-0.19.0.drv' offloaded to '127.0.0.1' failed: build of `/gnu/store/h3cbka6s0fvrsq4b56nq0v3vdiggql1d-tini-0.19.0.drv' failed
build of /gnu/store/h3cbka6s0fvrsq4b56nq0v3vdiggql1d-tini-0.19.0.drv failed
View build log at '/var/log/guix/drvs/h3/cbka6s0fvrsq4b56nq0v3vdiggql1d-tini-0.19.0.drv'.
guix build: error: build of `/gnu/store/h3cbka6s0fvrsq4b56nq0v3vdiggql1d-tini-0.19.0.drv' failed

I've disabled building the static-tini binary for now, but thought it'd be good to report this.

The same was also true for 0.18.0.

OK, I found a solution for this: providing the -DCMAKE_INSTALL_RPATH= CMake configuration option. If that's Guix-specific, please feel free to close the issue.

Yeah it's definitely expected that the static build would not have a RPATH (since that's where to look for dynamic dependencies), but I suspect our CMakeLists should declare this. Are you able to repro this? If yes, can you try this patch?

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 332b361..2c14a55 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,7 +82,7 @@ include_directories ("${PROJECT_BINARY_DIR}")
 add_executable (tini src/tini.c)

 add_executable (tini-static src/tini.c)
-set_target_properties (tini-static PROPERTIES LINK_FLAGS "-Wl,--no-export-dynamic -static")
+set_target_properties (tini-static PROPERTIES LINK_FLAGS "-Wl,--no-export-dynamic -static" INSTALL_RPATH "" BUILD_RPATH "")

 # Installation
 install (TARGETS tini DESTINATION bin)

Perhaps this problem is only triggered using Guix's cmake-build-system procedures because it makes uses of CMake's INSTALL_RPATH_USE_LINK_PATH and CMAKE_INSTALL_RPATH ? [0]

I removed the -DCMAKE_INSTALL_RPATH= CMake option workaround in the Guix's tini package definition, confirmed it'd fail to build (reproduce the problem), saved your patch as fix.diff, and tried:

./pre-inst-env guix build --with-patch=tini=./fix.diff tini

And it built! :-)

[0] https://git.savannah.gnu.org/cgit/guix.git/tree/guix/build/cmake-build-system.scm#n60