[erlang-questions] Checking for FPE on glibc 2.7

Mikael Pettersson mikpe@REDACTED
Tue Jan 1 20:53:52 CET 2008


Sergei Golovan writes:
 > Hi!
 > 
 > When building Erlang/OTP R12-B using glibc 2.7 (Debian GNU/Linux on
 > x86 architecture) I've noticed that checking floating point exceptions
 > fails, making HiPE build unavailable.
 > 
 > Looking closer at the checking rotines shows the following
 > compile-time error messages:
 > 
 > % gcc fpe-test-12.c
 > In file included from /usr/include/asm/sigcontext.h:7,
 >                  from fpe-test-12.c:268:
 > /usr/include/asm-i386/sigcontext.h:19: error: redefinition of 'struct _fpreg'
 > /usr/include/asm-i386/sigcontext.h:24: error: redefinition of 'struct _fpxreg'
 > /usr/include/asm-i386/sigcontext.h:30: error: redefinition of 'struct _xmmreg'
 > /usr/include/asm-i386/sigcontext.h:34: error: redefinition of 'struct _fpstate'
 > /usr/include/asm-i386/sigcontext.h:58: error: redefinition of 'struct
 > sigcontext'
 > 
 > Appears that in glibc 2.7 file /usr/include/bits/sigcontext.h already
 > contains the definitions of these structures.
 > 
 > But simple commenting out "#include <asm/sigcontext.h>" in line 268
 > doesn't help because it leaves X86_FXSR_MAGIC undefined. After
 > replacing it by 0x0000 (its definition from sigcontext.h) all works
 > fine. Moreover, the changed test works in older glibc as well.
 > 
 > Could someone look into this problem and help me to resolve this issue
 > properly? Or my changes are acceptable?

Something like the patch below perhaps?

I've tested it on Linux i386 with glibc-2.3.6 (FC4), glibc-2.4 (FC5), and
glibc-2.5 (FC6). In all cases R12B-0 built and worked Ok, and enabled FP
exceptions and HiPE.

I don't have immediate access to glibc-2.6 or glibc-2.7 systems, but if I
get confirmation that R12B-0 plus this patch builds and works on those,
and that FP exceptions and HiPE remain enabled, then I'd be inclined to
add the patch to R12B-1. To avoid breaking older systems, the
#include <asm/sigcontext.h> can be conditional on glibc < 2.4 or so.

Is the glibc-2.7 problem Debian specific? I seem to recall seeing reports
that R12B-0 works Ok on the glibc-2.7 based F8.

/Mikael

--- otp_src_R12B-0/erts/configure.in.~1~	2007-11-28 17:50:44.000000000 +0100
+++ otp_src_R12B-0/erts/configure.in	2008-01-01 20:00:07.000000000 +0100
@@ -2026,7 +2026,10 @@ static __inline__ int check_fpe(double f
 #if (defined(__linux__) && (defined(__i386__) || defined(__x86_64__) || defined(__sparc__) || defined(__powerpc__))) || (defined(__DARWIN__) && (defined(__i386__) || defined(__x86_64__) || defined(__ppc__))) || (defined(__FreeBSD__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__OpenBSD__) && defined(__x86_64__)) || (defined(__sun__) && defined(__x86_64__))
 
 #if defined(__linux__) && defined(__i386__)
-#include <asm/sigcontext.h>
+//#include <asm/sigcontext.h>
+#if !defined(X86_FXSR_MAGIC)
+#define X86_FXSR_MAGIC 0x0000
+#endif
 #elif defined(__FreeBSD__) && defined(__i386__)
 #include <sys/types.h>
 #include <machine/npx.h>
--- otp_src_R12B-0/erts/configure.~1~	2007-12-04 15:30:08.000000000 +0100
+++ otp_src_R12B-0/erts/configure	2008-01-01 20:00:26.000000000 +0100
@@ -18561,7 +18561,10 @@ static __inline__ int check_fpe(double f
 #if (defined(__linux__) && (defined(__i386__) || defined(__x86_64__) || defined(__sparc__) || defined(__powerpc__))) || (defined(__DARWIN__) && (defined(__i386__) || defined(__x86_64__) || defined(__ppc__))) || (defined(__FreeBSD__) && (defined(__i386__) || defined(__x86_64__))) || (defined(__OpenBSD__) && defined(__x86_64__)) || (defined(__sun__) && defined(__x86_64__))
 
 #if defined(__linux__) && defined(__i386__)
-#include <asm/sigcontext.h>
+//#include <asm/sigcontext.h>
+#if !defined(X86_FXSR_MAGIC)
+#define X86_FXSR_MAGIC 0x0000
+#endif
 #elif defined(__FreeBSD__) && defined(__i386__)
 #include <sys/types.h>
 #include <machine/npx.h>
--- otp_src_R12B-0/erts/emulator/sys/unix/sys_float.c.~1~	2007-11-26 19:58:57.000000000 +0100
+++ otp_src_R12B-0/erts/emulator/sys/unix/sys_float.c	2008-01-01 20:00:57.000000000 +0100
@@ -463,7 +463,10 @@ static void skip_sse2_insn(erts_mcontext
 #if (defined(__linux__) && (defined(__i386__) || defined(__x86_64__) || defined(__sparc__) || defined(__powerpc__))) || (defined(__DARWIN__) && (defined(__i386__) || defined(__x86_64__) || defined(__ppc__))) || (defined(__FreeBSD__) && (defined(__x86_64__) || defined(__i386__))) || (defined(__OpenBSD__) && defined(__x86_64__)) || (defined(__sun__) && defined(__x86_64__))
 
 #if defined(__linux__) && defined(__i386__)
-#include <asm/sigcontext.h>
+//#include <asm/sigcontext.h>
+#if !defined(X86_FXSR_MAGIC)
+#define X86_FXSR_MAGIC 0x0000
+#endif
 #elif defined(__FreeBSD__) && defined(__x86_64__)
 #include <sys/types.h>
 #include <machine/fpu.h>



More information about the erlang-questions mailing list