[tlbuild] Stripping the luatex binary

Philipp Stephani st_philipp at yahoo.de
Fri Apr 1 19:02:48 CEST 2011


Am 01.04.2011 um 11:18 schrieb Peter Breitenlohner:

> On Thu, 31 Mar 2011, Philipp Stephani wrote:
> 
>> Yes. Both ld and strip on both Linux and OS X (probably inherited by BSD)
>> have the options -S (strip debugging symbols) and -x (strip local
>> symbols).  The long options such as --strip-debug are only available for
>> the GNU toolchain.
> 
> Hi Philipp,
> 
> first some background:
> 
> (1) the current TL build system uses Autoconf, Automake, and Libtool.
> 
> (2) luatex and pdftex use the libtool library libkpathsea, usually from the
> TL build tree but in principle an installed (static or shared) version could
> also be used.
> 
> (3) thus "libtool --mode=link" is used to build the binaries, for luatex
> with '--export-dynamic' but for pdftex without, and "libtool --mode=install"
> to install them.

The OS X libtool has neither --mode nor --export-dynamic flags, nor does the linker. Do you use a custom libtool and/or linker?

> 
> (4) Autoconf likes to compile with '-g' unless the user specifies CFLAGS (or
> CXXFLAGS).
> 
> (5) the programs are stripped upon installation when this is done via "make
> install-strip" and it seems this is always done with '-s'.

Do you mean -S (capital S)? If so, that's fine and also supported by OS X strip and ld.

> 
> To see how all this works for i686-linux-gnu (and probably linux in general)
> I have inspected the unstripped versions in the build tree as well as the
> stripped installed ones with 'nm' and grepped for 'write_png':
> 
> 	unstripped luatex or pdftex:	one 'T write_png'
> 	stripped luatex or pdftex:	nothing
> 
> Next I have grepped the output of 'strings':
> 
> 	unstripped or stripped luatex:	two times 'write_png'
> 	unstripped or stripped pdftex:	nothing

On some x86-64 bit Linux system, nm says "no symbols" for both lua and luatex. Maybe the loader ABI is again different for 64-bit Linux systems.

> 
> My conclusion: the '--export-dynamic' causes libtool to tell the GNU ld to
> keep the global symbols, e.g. 'write_png', as seen by 'strings', and I
> suppose that suffices (untested) to resolve them in dlopen'ed modules.

Yes, this is true on Linux, since extension modules work there out of the box, but probably only on Linux.

> 
> If all that doesn't work for OS X, this is IMHO a libtool + OS X problem

The underlying program (ld) works as expected, and if I compile with "build.sh --nostrip" from the LuaTeX repository, I get a working binary even though the makefile uses libtool to call ld. But LuaTeX uses a custom libtool, maybe that makes a difference.

> (either the OS X ld doesn't have the required capabilities

No special capabilities are required since all symbols are exported by default. It works (at least with the binary from the LuaTeX repository) if you call strip with -S -x. Libtool itself doesn't seem to call strip at all (at least when compiled with LuaTeX's build script).
To summarize: On OS X, call "ld -S -x -o luatex", or call "strip -S -x luatex" afterward, but not "strip luatex". I think I have to figure out what libtool actually does...


More information about the tlbuild mailing list