Why does gcc require gmp?

Like anyone who has ever created gcc from a source, it knows that gmp is a gcc dependency. Why is this? In other words, what does gcc actually use for this?

+4
source share
1 answer

Check out this answer to a similar (but not the same) question.

GMP is needed inside the compiler (at compile time), especially for constant bending. Some language standards (in particular, some recent versions of Fortran) require, for example, 1234567891234567*1234567891 calculated by arbitrary precision.

Even C is much happier with bigints for constantly folding: this is the only way to get the correct result for the expression (perhaps obtained after some extension of the macro, even if you do not specify it explicitly in the source code), for example (123456789087651234*65125412651209128612+187451)%10000000141 or (140000000000041*150000000000061+134500000000139)%250000000000111 .

I forgot that the C or C ++ standard speaks of such constant expressions. Calculation of them correctly, of course, is not so. But Fortran requires that they be correctly calculated, and this requires large numbers. My second example contains only 64-bit bar fitting, but you need bignums to correctly calculate the result ...

In addition, GCC, when cross-compiling requires more precision on the integer number of the host. Consider obviously cross-compiling from a 32-bit 64-bit machine, of course you want constant folding to compute all 64 bits!

In addition, some smart optimizations (especially polyhedral optimizations , such as Cloog or PPL , which are used by GCC), may be required, during one optimization run and internally, bigint arithmetic to be exact. More generally, optimization is symbolic processing, and symbolic processing usually requires bignums . During such optimizations, quite large numbers may appear, even if the source code has only fairly small constants.

+6
source

All Articles