Просмотр исходного кода

alpha: build with -mieee

Formatting a NaN or an infinity killed the process with SIGFPE instead of
printing it. Alpha traps on NaN, infinity and denormals in hardware; -mieee is
what makes gcc insert the trap barriers and the software completion that turn
those into IEEE semantics. uClibc-ng passed the flag nowhere, so every build
for the architecture had this hole.

It stayed hidden because printf's plain decimal path barely touches such a
value, and because hexadecimal float formatting was not being exercised. Once
it was, printf_a and printf_efg went from a wrong result to exit 136: the %a
path scales the value with real arithmetic, and the test feeds -NAN and
-INFINITY as its first two inputs.

Measured under qemu-alpha with a static uClibc-ng from this tree:

  without -mieee   printf_a, printf_efg   SIGFPE
  with -mieee      printf_a   CRC 0x5797c255   expected
                   printf_efg CRC 0x52f6dd6b   expected

Put in Rules.mak next to the other architectures' CPU_CFLAGS rather than left
to whoever configures the build, since it is not a policy choice: without it,
floating point formatting does not work on alpha at all. glibc has built its alpha libc this
way for as long as it has supported the architecture.

Note for whoever looks at alpha next: long double is 8 bytes there, the same
as double, so none of the long double wrapper issues apply.

Signed-off-by: Ramin Moussavi <lordrasmus@gmail.com>
ramin 3 дней назад
Родитель
Сommit
644b0fecf9
1 измененных файлов с 6 добавлено и 0 удалено
  1. 6 0
      Rules.mak

+ 6 - 0
Rules.mak

@@ -380,6 +380,12 @@ $(eval $(call check-ld-var,--sort-section=alignment))
 	CPU_CFLAGS-y+=-m32
 endif
 
+ifeq ($(TARGET_ARCH),alpha)
+	# Without -mieee the hardware traps on NaN, infinity and denormals, so
+	# printing them takes a SIGFPE instead of a string.
+	CPU_CFLAGS-y+=-mieee
+endif
+
 ifeq ($(TARGET_ARCH),sparc)
 	CPU_CFLAGS-$(CONFIG_SPARC_V7)+=-mcpu=v7
 	CPU_CFLAGS-$(CONFIG_SPARC_V8)+=-mcpu=v8