Open rodarima opened 4 years ago
I marked this as stale due to inactivity. → More info
I ran into the same issue with debug files while attempting to package julia-bin
. Rather than checking if the file is executable (in my case they are), which would require manually chmod'ing, could we do something along of the lines of:
1) Allow specifying a list of files for autoPatchElf to ignore.
2) And/or rather than exiting on error, print a warning and continue.
For (2), this change was sufficient:
--- a/pkgs/build-support/setup-hooks/auto-patchelf.sh
+++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh
@@ -189,6 +189,16 @@ addAutoPatchelfSearchPath() {
\( -name '*.so' -o -name '*.so.*' \) -print0)
}
+# TODO need to first check that the DYNAMIC section exists before
+# extracting the size.
+hasEmptyDynamic() {
+ file="$1"
+ hex='0[xX][0-9a-fA-F]\{16\}'
+ line1='DYNAMIC[ \t0-9A-z]*'
+ dynsize="$(readelf -l "$file" | grep "$line1" -A1 | grep -v "$line1" | grep -o "$hex" | head -n 1)"
+ [ "$dynsize" = "0x0000000000000000" ]
+}
+
autoPatchelf() {
local norecurse=
@@ -217,6 +227,7 @@ autoPatchelf() {
while IFS= read -r -d $'\0' file; do
isELF "$file" || continue
+ hasEmptyDynamic "$file" && continue
segmentHeaders="$(LANG=C $READELF -l "$file")"
# Skip if the ELF file doesn't have segment headers (eg. object files).
# not using grep -q, because it can cause Broken pipe
Which just parses the output of readelf
to get the size of the DYNAMIC
section. If it's 0/empty, then skip, a) because there's nothing to do, but b) because patchelf
can't handle empty DYNAMIC
sections.
I think you could similarly get rid of the "strange: no string table" messages from auto-patchelf.sh and elsewhere from calling patchelf
on ELF's with empty DYNAMIC
sections.
Maybe a cleaner option is for patchelf
to exit silently without error if the dynamic section is empty (not sure if that's a feature or bug).
Tagging @DavHau since you seem to familiar with this code :).
I marked this as stale due to inactivity. → More info
I also have problem with autopatchelf choking on debug files
The debug symbols in libmpi.so for Intel MPI are distributed in a separate file libmpi.dbg with an (wrong?) ELF header. For what I can tell, the auto-patchelf hook finds any file and attempts to determine if it has a valid executable ELF header.
The .dbg file has an incorrect header for readelf:
Also the patchelf attempt fails:
I was looking for a way to exclude this file from
autoPatchelfHook
. Can we just patch files with the executable bit set adding-executable
to the find filters? So I could easilychmod -x libmpi.dbg
to exclude it.