]> git.draconx.ca Git - rrace.git/commit
Avoid linking against libXt/libXm string tables.
authorNick Bowler <nbowler@draconx.ca>
Sat, 7 Jan 2023 16:19:27 +0000 (11:19 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sun, 8 Jan 2023 05:46:55 +0000 (00:46 -0500)
commitce1a1f9d40d6230f6e3d7059142cf21776548756
treefbd1f39b9cf61e2d4ef9db9aed121fb0d31a78f0
parentc11496c3a03550e6103036e09eb27a7bffb7957b
Avoid linking against libXt/libXm string tables.

The libXt and libXm libraries contain huge (about 25 kB in total)
constant string tables, and the header files define macros that
offset these tables rather than using normal C strings.

The trouble is, on ELF systems with position-independent libraries,
accessing these tables from a program is very expensive.  Compilers
most commonly emit copy relocations that literally just duplicate
the entire table at runtime into the program's data segment.

As far as I can tell, this completely eliminates any possible advantage
of these tables: you use twice as much memory in a single program, the
copied data is not shareable between processes, and there is extra work
to actually perform these relocations.

Letting the program define its own strings avoids these relocations
and is substantially smaller, because only a handful of strings from
the tables are actually used.

They can still be shared if the program itself is compiled as PIC,
which adds GOT indirection to all accesses to the string table.  But
this actually increases the size of the program more than just using
normal string literals does.

Maybe these made sense to have in the library at some point in the
past, maybe once upon a time C compilers didn't merge string literals
between translation units and these tables were the solution.

I don't think these tables make sense today.  Fortunately, the headers
provide an option to disable this nonsense, at least for our program,
which we can just define in config.h.
configure.ac