[Slackbuilds-users] Stripping executables

B Watson yalhcru at gmail.com
Mon Feb 8 20:30:39 UTC 2021


On 2/5/21, spaceman via SlackBuilds-users
<slackbuilds-users at slackbuilds.org> wrote:
> Hi,
>
> For me at least this command:
>
>     find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared ob=
> ject" | grep ELF \
>       | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
>
> Which is used on a number of slackbuilds (rhash and cmus were the two I
> tested) does not appear to strip executables. The resulting file:
>
>     $ file /usr/bin/rhash
>     /usr/bin/rhash: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV)=
> , statically linked, with debug_info, not stripped

There's more than one way to do it. Lots of software, you can just say
"make install-strip" instead of "make install". For cmake, sometimes
it's spelled "make install/strip".

You can also add "-Wl,-s" to the CFLAGS, which tells gcc's linker to
strip everything as it's being linked.

A lot of the time, you can do this:

strip $PKG/usr/bin/* $PKG/usr/lib$LIBDIRSUFFIX/*.so.*

...which will fail if $PKG/usr/bin also contains scripts (shell, perl,
python, etc).

The strip commands from the template are more complex because they're
supposed to be generic (and your proposed replacement is more complex
yet), but you're not required to use them if you've got a simpler
solution for the specific build you're working on.

Same goes for man pages, the template code is designed to handle
symlinks. Probably 90% of the time, there aren't any symlinked man
pages, so it can be replaced with "gzip -9 $PKG/usr/man/man?/*". I
prefer this in my builds, whenever it's possible to use.

Make everything as simple as possible, but no simpler...


More information about the SlackBuilds-users mailing list