Skip to contentSkip to conversation

classes/cmake: Use relative RPATHs

PATCH New Joshua Watt 1 participant 1 message Nov 21, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 classes/cmake: Use relative RPATHs

In most cases, the RPATH is stripped out when the ELF file is packages, but by then the damage is done from a reproducible perspective because this absolute path is hashed as part of the build-id generated at link time ([1] has a good explanation). Fortunately, newer cmake has an option to generated relative RPATHs that use $ORIGIN to set the path, so set it in the toolchain file.

[1]: https://gitlab.kitware.com/cmake/cmake/issues/18413

---
 meta/classes/cmake.bbclass | 3 +++
 1 file changed, 3 insertions(+)
meta/classes/cmake.bbclass +3 -0
index 291f1e8d448..8ccb1eefc7d 100644
@@ -120,6 +120,9 @@ set( ENV{QT_CONF_PATH} ${WORKDIR}/qt.conf )
 # directory as rpath by default
 set( CMAKE_INSTALL_RPATH ${OECMAKE_RPATH} )
 
+# Use RPATHs relative to build directory for reproducibility
+set( CMAKE_BUILD_RPATH_USE_ORIGIN ON )
+
 # Use our cmake modules
 list(APPEND CMAKE_MODULE_PATH "${STAGING_DATADIR}/cmake/Modules/")
 
Signature · 1 line
2.23.0