In previous posts I described my effort to bring GCC to HelenOS. This post briefly summarizes porting of yet another GCC dependency: MPFR library. It comes a bit late as the progress was already reported on last HelenOS meeting but the meeting report did not contain the actual commands, so here are they.
Again, we will use the configure-for-helenos.sh script to wrap the configuration of MPFR.
Before you can compile MPFR, you have to have the GMP compiled. I created a special directory to keep the compiled libraries and corresponding headers in
$COAST with some directory where you want to actually keep it).
This time, the command looks like this:
~/bin/configure-for-helenos.sh \ -d ~/helenos/gcc-port \ --arch-arg=--host= \ --link-with-cc \ --cflags="-DCHAR_BIT=8 -D_MPFR_H_HAVE_FILE \ -DFLOAT_H_YES_I_REALLY_WANT_LIMITS \ -D_MPFR_H_HAVE_INTMAX_T" \ -- \ ./configure \ --with-gmp-lib=$COAST/gmp/ia32/lib/ \ --with-gmp-include=$COAST/gmp/ia32/include/ \ --disable-shared
I think that most of the arguments are self-explanatory. The macros
_MPFR_H_HAVE_INTMAX_T are needed to trick the configuration script into thinking that something is actually available.
FLOAT_H_YES_I_REALLY_WANT_LIMITS requires a bit longer explanation. The header
float.h shall define few constants describing precision of the
long double types. The
float.h in HelenOS defines nothing like that and the
configure fails because of that. Thus I needed to define these constants somehow but it seems to me that it is actually GCC that is supposed to define them properly. Thus, I have put into
float.h values that my (native) GCC printed but to ensure anybody who wants to use them has to state it explicitly, they are under a
#ifdef guard. See revision 1744 for details.
With all these tricks, it is possible to successfully compile MPFR, including all tests. Running
make && make check
shall end with failure when launching the tests. I.e. the output shall contain
make: *** [check-TESTS] Error 1
near the very end.
You may try to copy the tests from
tests/ directory to HelenOS and run them there. You need to copy all the executables (
find -executable works extremely well) and also the data files (
*.dat*). I recommend creating a batch script for that, because it is very boring to manually run all the 161 tests. To simplify testing, I have added a
-c to the
batch command that ensures that all commands are executed despite errors in some of them. That is very handy because all the tests are run. I also recommend to run the batch script through telnet session because the output is pretty long and scrolling is somehow missing in our terminal.
Not all tests passed. There is a problem in printing (missing implementation for
%Lf) and few others. For completeness, below is output from failed tests.
>tfprintf Error in test 8, got '% a. 15, b. -1, c. %td' Error in test #8: mpfr_vfprintf printed 22 characters instead of 20 bdsh: Command failed (exit code 1) >tget_flt Error for mpfr_get_flt(2^128*(1-2^(-25)),RNDZ) expected 0.00000000e+00, got 3.40282347e+38 bdsh: Command failed (exit code 1) >tget_set_d64 bdsh: Command failed (exit code 77) >tget_sj Error in check_sj for y = 1.1111111111111111111111111111111111111111111111111111111111111011000e62 in MPFR_RNDN Got %jd instead of %jd. bdsh: Command failed (exit code 1) >tprintf bdsh: Command failed (unexpectedly terminated) >tset_sj ERROR for mpfr_set_uj and j=571432452 and p=2 X=0.11E30 Y=0.10E30 bdsh: Command failed (exit code 1) >tsprintf Error in mpfr_vsprintf (s, "%.*Zi, %R*e, %Lf", ...); expected: "00000010610209857723, -1.2345678875e+07, 0.032258" got: "00000010610209857723, -1.2345678875e+07, %Lf" bdsh: Command failed (exit code 1)
tout_str from the test list because I always have to manually kill it.
I will investigate the causes later, currently I am pretty happy that it is possible to compile MPFR at least into this state.
Next dependency is MPC that I am also able to compile but the tests fail miserably. However, the amount of compiled libraries is growing and it is quite challenging... well, strike that, it is plainly annoying ... to keep track of them. So, now I am working on yet another wrapper to simplify these tasks a bit. It is not yet finished but so far, it is highly inspired by makepkg (package builder for Arch Linux). Once it is in reasonable shape to be used, I will post here more details. Thanks for reading!