-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove libtool preserved temporary RPATH/RUNPATH from "shared object" ELF binaries (libraries/executables) #6094
Conversation
shouldn't we put
|
What about just call sed on this files directly from build script on every package? If file exist run sed. If file doesn't exist do nothing. Would this do any harm? Probably not? And it would cover all packages at once without changing them manually. |
The I’m hoping that half of these identified will be resolved upstream. So given the current < 20, I would not be keen on “all” as this particular hacky fix is only relevant to CMake has its own fix |
I’m good with this approach. It makes sense given my plan with Part 5 of this series is to go with a FATAL ERROR if RPATH/RUNPATH are set (or set incorrectly.) I’d like to complete the Part 2 commits first to make sure that there aren’t any other formats / versions to be catered for. |
So the Part 1 and Part 2 are done (and all addons that I use - chrome dependancies need work) 20 fixes required:
Will proceed to create a libtool_remove_rpath() as suggested in #6094 (comment) for the 17 x libtool sed fixes only packages/libraries to review so far for Part 4 are:
|
08b4c6b
to
4bccef0
Compare
|
Added remaining 19 addons - identified via
Following 10 updates came from Generic-legacy |
rebase required |
This function can be used on "autotools" and "configure" packages. Use libtool_remove_rpath() to remove hardcode rpath when --disable-rpath is not supported by "configure". usage: `libtool_remove_rpath libtool` If there are multiple libtool scripts or they are in subdirectories, then you may need to run this function using the path to libtool or run the function multiple times. If binaries and shared objects installed by the package to target have incorrect or system libraries then this function can be used. After using the function, these example command below should NOT have a RPATH/RUNPATH. e.g. (before using the fucntion) $ readelf --dynamic ${filename} | grep PATH RPATH Library runpath: [.....] RUNPATH Library runpath: [.....] Before using this function; check if the package supports --disable-rpath (and that it works.) Work with upstream and have a working --disable-rpath added to the package.
Remove all test programs installed by install-test-programs=true except modetest Do not "not use" the ninja install and replace this with a simple "cp modetest" as ninja strips the unnecessary build rpath during the install.
Rebase based to fix xf86-video-intel/package.mk |
This is Part 1 of the RPATH cleanup
/lib
- to remove incorrect RPATH/RUNPATH/sbin
,/bin
- to remove incorrect RPATH/RUNPATHcheck-rpaths
ldd
system search path=
includes variants of hardware / hwcaps library pathsBackground
The buildhost cross compile hardcoded library paths e.g.
/build/LibreELEC.kernel11/build.LibreELEC-iMX6.arm-11.0-devel/toolchain/armv7a-libreelec-linux-gnueabihf/sysroot/usr/lib
are being included in binaries and libraries.This was discovered by accident when I rebooted my system (which is a buildhost) with glib2.32 in the build...-Generic directory after doing a test build of my development branch with a non matching glibc (GLIB_2.33).
systemd
refused to start as it was using the RPATH "shared object" - notLD_LIBRARY_PATH
. RPATH always comes beforeLD_LIBRARY_PATH
As discussed in the Fedora Packaging Guidelines - ...Since the Linux dynamic linker is usually smarter than a hardcoded path, we usually do not permit the use of rpath in Fedora.... This has not caused issue in LE - given that the JEOS is read only, and that the /lib is a point in time static when the image is generated. Though when
-rpath
or-R
and the subsequentRPATH
/RUNPATH
are included in the ELF binaries/libraries and this hardcoded location information is examined byld.so
in the beginning of the execution causing the error discovered. The article Shared Libraries: Understanding Dynamic Loading by Amir Rachum is a good read to understand how dynamic loading of shared libraries works in Linux systemsThe following library search path order is used for the RPATH, LD_LIBRARY_PATH, and RUNPATH:
Detail of the PR
This PR updates the "shared object" ELF binaries (libraries) to not have RPATH or RUNPATH (when it is not necessary.)
RUNPATH Library runpath: [/usr/lib]
RUNPATH Library runpath: [/build/LibreELEC.kernel11/build.LibreELEC-iMX6.arm-11.0-devel/toolchain/armv7a-libreelec-linux-gnueabihf/sysroot/usr/lib]
In the below example
libcurl
has the build path included in the shared object. This is not correct nor ideal.A further solution to be put in place (for the whole build) is the inclusion of something similar to the
check-rpaths
tool fromrpmdevtools
Reading
CMAKE_SKIP_RPATH
Results
After the PR - the output of the
/usr/lib
shows only the following RPATH/RUNPATHgconv
,llvm
, andpulse
use RPATH/RUNPATH will be undertaken in part 4 before these are changed / updatedshow the trace of
libcurl
which correctly finds all its dependancies (without the need to use theLD_LIBRARY_PATH
- as expected)