Configure problem on Linux x86 with GCC 3.x

jean-jacques.gelee at gmx.de jean-jacques.gelee at gmx.de
Fri Mar 21 10:52:50 UTC 2003


Hi Lars,

Many thanks for pointing this out!
I hope this will solve my linux problems, too.

Regards,
Torge

> Hi,
> 
> there has been a open problem with all GCC 3.x on Linux x86 for quite a
> long time. If you run configure the double order is not determined
> correctly. So you still have to set
> 
> #define DOUBLE_WORD_ORDER 1
> 
> manually in the automatically created config.h. Otherwise Squeak will
> produce later a lot of float errors and break down quickly.
> 
> Responsible for the detection of the double order is the
> AC_C_DOUBLE_ORDER macro used in the configure script. This macro is
> defined in acinclude.m4. It tries to detect the double order using the
> following test program:
> 
> main()
>       {
>       double d = 1.0;
>       return *(int*)&d == 0;
>       }
> 
> If you compile it with "gcc -g -O2" as it is normal within configure
> scripts on Linux, the program does not yield the desired results when
> using GCC 3.x. This is because of the "-O2" optimizing option, which
> seems to have a different behavior since GCC 3.0. The reason seems to be
> a mix of options that -O2 stands for. If you, for example, provide
> "-fno-strict-aliasing" or "-fno-schedule-insns2" in addition to "-O2",
> then the result is the originally intended. But only providing the two
> complementary options without "-O2" is not enough to reproduce the
> strange behavior that "-O2" alone leads to.
> 
> However, the problem follows from the double*-to-int*-cast, because a
> pointer to an 8-byte-value is cast to a 4-byte-value. Such a cast has
> actually no defined behavior. So the result can change at different
> optimization levels.
> 
> By means of an union struct one can perform the double order test in a
> consistent way. You just have to replace the test program from above by
> the following in the AC_C_DOUBLE_ORDER macro definition in acinclude.m4:
> 
> 
> main()
>       {
>       union
>            {
>            double d;
>            int i;
>            } u;
>       u.d = 1.0;
>       return u.i == 0;
>       }
> 
> 
> I have tested it and it seems to work fine on Linux 2.4.20 and Solaris
> 2.8 with GCC 2.95.3 and GCC 3.2. Does it work generally or could there
> appear any problems? If not, it would be nice, if Ian could incorporate
> this change into the current UNIX Squeak source distros.
> 
> Lars
> 
> 
> 



More information about the Squeak-dev mailing list