FS#13592 - Strip shared libraries by default
Attached to Project:
Pacman
Opened by Bruno Tsubouchi Yporti (yportilog) - Saturday, 28 February 2009, 08:25 GMT
Last edited by Allan McRae (Allan) - Monday, 15 March 2010, 00:37 GMT
Opened by Bruno Tsubouchi Yporti (yportilog) - Saturday, 28 February 2009, 08:25 GMT
Last edited by Allan McRae (Allan) - Monday, 15 March 2010, 00:37 GMT
|
Details
Strip all symbols from shared libraries (.so) by default
could be save a lot of disk space and maybe improve
performance(?).
Is there any special reason to not remove all symbols of libraries? Several distribuitions, like Debian and Gentoo, uses this by defualt whithout problems. The difference in size of libraries is quite significant in some cases: 4,4M /usr/lib/libgtk-x11-2.0.so.0.1400.7 (default) 3,6M /usr/lib/libgtk-x11-2.0.so.0.1400.7 (fully stripped) Thanks. |
This task depends upon
Closed by Allan McRae (Allan)
Monday, 15 March 2010, 00:37 GMT
Reason for closing: Implemented
Additional comments about closing: http://projects.archlinux.org/pacman.git /commit/?id=5fe41df8a9eaac288433a54e216f 96b1fe729c01
Monday, 15 March 2010, 00:37 GMT
Reason for closing: Implemented
Additional comments about closing: http://projects.archlinux.org/pacman.git /commit/?id=5fe41df8a9eaac288433a54e216f 96b1fe729c01
http://projects.archlinux.org/?p=pacman.git;a=blob;f=scripts/makepkg.sh.in;h=52e80d17e296ab22ad1503ca3ae690d4d516e829;hb=HEAD#l830
What is the output of : file -biz /usr/lib/libgtk-x11-2.0.so.0.1400.7 ?
Look this:
/usr/lib/libgtk-x11-2.0.so.0.1400.7: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped (Default)
/usr/lib/libgtk-x11-2.0.so.0.1400.7: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped (after strip)
Gentoo x86 stable
/usr/lib/libgtk-x11-2.0.so.0.1200.11: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped
Debian 5.0 stable
libgtk-x11-2.0.so.0.1200.11: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, stripped
http://www.linuxfromscratch.org/pipermail/lfs-dev/2001-May/014565.html
So if we do change something, we should only do it on shared libs and not static libs.
Regards.
References I found:
http://www.happy-monkey.net/pocket/ch03.html#d0e705 (not an authoritative source...)
"Using --strip-unneeded shrinks the file size, but leaves the symbols needed for relocation intact which is something that shared libraries need to function properly."
Like I said, several stable distributions use this strip mode in shared libraries without problems. I think this will not cause problems on Archlinux.
Regards.
binaries: strip <file>
static libraries: strip -g <file>
shared libraries: strip --strip-unneeded <file> (by default)
The --strip-unneeded flag is not portable to BSD (http://www.gsp.com/cgi-bin/man.cgi?section=1&topic=strip) and probably not on OS X given that does not even have --strip-debug. So this would need to be done in configure.ac.
I am happy for this change to be made. Patches welcome.
strip-debug for static libraries (don't use strip-unneeded, will be destroy static libs when linking)
strip-unneeded for shared libraries
The only exception here is glibc, don't use strip-unneeded because can cause problems when use pthreads, but maybe this was a old historic problem when glibc uses LinuxThreads, now with NPTL don't know the status. I think that is safe to do only a strip-debug for glibc libs, and don't strip the dynamic linker/loader ld-linux.
But i personally prefer to don't strip glibc at all.
My two cents.
From the man and info pages, I can not actually figure out what level of stripping does "strip <file>" do? I would be happy to change this to strip-all for binaries. I used that in my LFS builds and everything was fine.
I think the sprit-all can be the default. If the developer put something like this: options=(strip_carefully).
Normal strip:
cd $pkgdir
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
cd -
strip_carefully:
cd $pkgdir
find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null
cd -
ref:
ftp://ftp.slackware.com/pub/slackware/slackware-current/source/l/glibc/glibc.SlackBuild
ftp://ftp.slackware.com/pub/slackware/slackware-current/source/d/nasm/nasm.SlackBuild
ftp://ftp.slackware.com/pub/slackware/slackware-current/source/d/gcc/gcc.SlackBuild
This is how I want it implemented:
Three new variables in makepkg.conf STRIP_BINARIES, STRIP_STATIC, STRIP_SHARED. Their default values should be "--strip-all", "--strip-debug", "--strip-unneeded" respectively.
In configure.ac, in the "Host-dependant definitions" section, for darwin these values should be set to "", "-S", "-S" (as currently in makepkg) as I do not think the long options work there. cygwin should work with the default values, as should BSD strip, but it is worth confirming this and adding overrides as necessary.