phobos build issue with dmd-2.102.2

thinkunix thinkunix at zoho.com
Thu Mar 9 06:45:09 UTC 2023


Hello all,

I have an older system I am trying to build dmd-2.102.2 on from source:

stock Slackware 14.0 x86_64
binutils 2.22.52.0.2, gcc 4.7.1, glibc 2.15, kernel 3.2.x, and
dmd-2.102.1 installed (which I built from source on this system)

I started with dmd-2.067.1, bootstrapped it with only a C++ compiler,
mainly to see if it could done.  It built no problem.  I then used
the dmd just built to build newer versions.  This worked fine up
through dmd-2.102.1.

I have a script that builds dmd, druntime, phobos, and some D tools,
in that order.  I patterned it after instructions in the wiki:
[https://wiki.dlang.org/Building_under_Posix] using the
"make -f posix.mak" build commands for all steps.

Attempting to build dmd-2.102.2, it builds dmd and druntime OK,
but fails building phobos in unittest code, specifically in
phobos-2.102.2/std/math/exponential.d.

...(I removed duplicate 'Error' lines)...

std/math/exponential.d(3782): Error: number `0x0.8p-126f` is not 
representable as a `float`
std/math/exponential.d(3784): Error: number `0x0.555556p-126f` is not 
representable as a `float`
std/math/exponential.d(3795): Error: number `0x0.8p-1022` is not 
representable as a `double`
std/math/exponential.d(3797): Error: number `0x0.5555555555555p-1022` is 
not representable as a `double`
make: *** [generated/linux/release/64/libphobos2.a] Error 1


It appears related to this commit:
https://github.com/dlang/phobos/commit/a76836b5a66f2e6f89026f48b0a53100d4b65a75

I ran the same build script for dmd-2.102.2 on another system and
everything built OK:

Slackware 14.1 x86_64 heavily modified
binutils 2.25.1, gcc 4.9.4, glibc 2.17, kernel 3.16.x, and
dmd-2.102.1 installed (also built from source)

I was thinking this might be a glibc or binutils issue since
versions are different between the two systems.  I ran the
following tests on both systems:

```c
/* C99: testfloat.c */
/* compile:  gcc -std=c99 testfloat.c */
#include <stdio.h>
int main()
{
         float f = 0x0.8p-126f;
         printf("f: %0lg\n", f);
         return 0;
}
```

The C program is compiled with the system's C compiler.
It prints the same output on both systems:
$ gcc -std=c99 testfloat.c; ./a.out
f: 5.87747e-39

Then I tried the D version, using the existing dmd-2.102.1:

```d
// testfloat.d
import std.stdio;
int main()
{
         float f = 0x0.8p-126f;
         writeln("f: ", f);
         return 0;
}
```

Slackware 14.1 host prints, same as the C version:
f: 5.87747e-39

Slackware 14.0 host returns an error:
$ rdmd testfloat.d
testfloat.d(5): Error: number `0x0.8p-126f` is not representable as a 
`float`
testfloat.d(5):        https://dlang.org/spec/lex.html#floatliteral
Failed: ["/usr/bin/dmd", "-v", "-o-", "testfloat.d", "-I."]


Comparing the build logs the only difference I found was in the
phobos build.  Slackware 14.1 has extra options, that I did not add.
I'm not sure where these are coming from:

         -shared -defaultlib= -debuglib= -L-lpthread -L-lm

../dmd/generated/linux/release/64/dmd  -conf= -I../dmd/druntime/import 
-w -de -preview=dip1000 -preview=dtorfields -preview=fieldwise -m64 
-fPIC -O -release -shared -defaultlib= -debuglib= -L-lpthread -L-lm 
-ofgenerated/linux/release/64/libphobos2.so.0.102.2 
-L-soname=libphobos2.so.0.102 
../dmd/druntime/../generated/linux/release/64/libdruntime.so.a -L-ldl 
std/array.d std/ascii.d ...massive line
trimmed...

The Slackware 14.0 only has -lib, none of the other options.
The rest of this huge line is the same.

../dmd/generated/linux/release/64/dmd  -conf= -I../dmd/druntime/import 
-w -de -preview=dip1000 -preview=dtorfields -preview=fieldwise -m64 
-fPIC -O -release -lib -ofgenerated/linux/release/64/libphobos2.a 
../dmd/druntime/../generated/linux/release/64/libdruntime.a std/array.d 
std/ascii.d  ...massive line trimmed...


This is mainly an academic exercise, but I would like to understand
why the phobos build fails on the older system.

thanks,
scot


More information about the Digitalmars-d-learn mailing list