aboutsummaryrefslogtreecommitdiffstats
path: root/Mk/Scripts
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2015-10-20 01:04:33 +0800
committerbdrewery <bdrewery@FreeBSD.org>2015-10-20 01:04:33 +0800
commit4f88e881e834d7c42b821863969c1b6705cbb87a (patch)
tree1944aa3ab6f05c0fbdb0f8a2bd23689da67d073c /Mk/Scripts
parentdef832dc18905f180acef81dc6a7c8b7f9fed815 (diff)
downloadfreebsd-ports-gnome-4f88e881e834d7c42b821863969c1b6705cbb87a.tar.gz
freebsd-ports-gnome-4f88e881e834d7c42b821863969c1b6705cbb87a.tar.zst
freebsd-ports-gnome-4f88e881e834d7c42b821863969c1b6705cbb87a.zip
Add some work-in-progress scripts for splitting symbols out into PREFIX/lib/debug.
This is only missing the bsd.port.mk pieces to hook it up fully. A blocker for hooking that up has been sub-packages, even though some implementation could be made without them. For now just commit what I have so it is not forgotten. Obtained from: OneFS Sponsored by: EMC / Isilon Storage Division With hat: portmgr
Diffstat (limited to 'Mk/Scripts')
-rw-r--r--Mk/Scripts/check-stagedir.sh6
-rw-r--r--Mk/Scripts/generate-symbols.sh46
2 files changed, 50 insertions, 2 deletions
diff --git a/Mk/Scripts/check-stagedir.sh b/Mk/Scripts/check-stagedir.sh
index c1a5baf88f43..0fbb230cb707 100644
--- a/Mk/Scripts/check-stagedir.sh
+++ b/Mk/Scripts/check-stagedir.sh
@@ -93,13 +93,15 @@ setup_plist_seds() {
unset PLIST_SUB_SED
# Used for generate_plist
sed_files_gen="s!^${PREFIX}/!!g; ${sed_plist_sub} \
- ${sed_portdocsexamples} /^share\/licenses/d;"
+ ${sed_portdocsexamples} /^share\/licenses/d; \
+ \#${LOCALBASE}/lib/debug#d;"
sed_dirs_gen="s!^${PREFIX}/!!g; ${sed_plist_sub} s,^,@dir ,; \
${sed_portdocsexamples} \
/^@dir share\/licenses/d;"
# These prevent ignoring DOCS/EXAMPLES dirs with sed_portdocsexamples
- sed_files="s!^${PREFIX}/!!g; ${sed_plist_sub} /^share\/licenses/d;"
+ sed_files="s!^${PREFIX}/!!g; ${sed_plist_sub} /^share\/licenses/d; \
+ \#${LOCALBASE}/lib/debug#d;"
sed_dirs="s!^${PREFIX}/!!g; ${sed_plist_sub} s,^,@dir ,; \
/^@dir share\/licenses/d;"
diff --git a/Mk/Scripts/generate-symbols.sh b/Mk/Scripts/generate-symbols.sh
new file mode 100644
index 000000000000..cdad53635f93
--- /dev/null
+++ b/Mk/Scripts/generate-symbols.sh
@@ -0,0 +1,46 @@
+#! /bin/sh
+# $FreeBSD$
+# Maintainer: portmgr@FreeBSD.org
+
+msg() {
+ echo "====> $@"
+}
+
+msg "Finding symbols"
+
+# Find all ELF files, strip them, and move symbols to PREFIX/usr/lib/debug/ORIG_PATH
+ELF_FILES=$(mktemp -t elf_files)
+LF=$(printf '\nX')
+LF=${LF%X}
+find ${STAGEDIR} -type f \
+ -exec /usr/bin/file -nNF "${LF}" {} + | while read f; do
+ read output
+ case "${output}" in
+ ELF\ *\ executable,\ *FreeBSD*,\ not\ stripped*|\
+ ELF\ *\ shared\ object,\ *FreeBSD*,\ not\ stripped*)
+ echo "${f}"
+ ;;
+ esac
+done > ${ELF_FILES}
+
+# Create all of the /usr/local/lib/* dirs
+lib_dir="${STAGEDIR}.debug${PREFIX}/lib/debug"
+sed -e "s,^${STAGEDIR}${PREFIX}/,${lib_dir}/," -e 's,/[^/]*$,,' \
+ ${ELF_FILES} | sort -u | xargs mkdir -p
+
+while read staged_elf_file; do
+ elf_file_name="${staged_elf_file##*/}"
+ lib_dir_dest="${lib_dir}/${staged_elf_file#${STAGEDIR}${PREFIX}/}"
+ # Strip off filename
+ lib_dir_dest="${lib_dir_dest%/*}"
+ # Save symbols to f.debug
+ objcopy --only-keep-debug "${staged_elf_file}" \
+ "${lib_dir_dest}/${elf_file_name}.debug"
+ # Strip and add a reference to f.debug for finding the symbols.
+ objcopy --strip-debug --strip-unneeded \
+ --add-gnu-debuglink="${lib_dir_dest}/${elf_file_name}.debug" \
+ "${staged_elf_file}"
+ msg "Saved symbols for ${staged_elf_file}"
+done < ${ELF_FILES}
+
+rm -f ${ELF_FILES}