Code organisation of mini-gmp

Torbjorn Granlund tg at
Mon Sep 10 13:20:10 CEST 2012

In mini-gmp, all functions are in the same file.  Most systems will
thereby not do any sort of usage-based linking, i.e., all mini-gmp's
functions will appear in binaries.

This is not very "mini".  And as mini-gmp might slowly grow to include a
larger subset of GMP, its size burden on final binaries might in many
cases be larger than that of GMP!

I think we should consider splitting it up into many files, basically
one-function-per-file.  The mini-gmp.c file would #include them all.
But a mini-gmp.a should be built from separate files.

Now, users have some choices:

(1) #include mini-gmp.c and surely disable any incremental linking
(2) Compile mini-gmp.c into a separate object mini-gmp.o, to perhaps
    get incremental linking on some systems
(3) Link to mini-gmp.a and get incremental linking everywhere.

If we really want to keep mini-gmp as one file (why?) then we should at
least play tricks with conditional inclusion for each and every
function, #if COMPILE_mpz_foo and have the Makefile compile it many
times to create a mini-gmp.a.  And when mini-gmp.c is #included without
any special settings, it should do lots of #define COMPILE_mpz_foo to
enable itself in its entirety.


More information about the gmp-devel mailing list