diff options
authorRich Felker <>2016-02-19 01:20:07 +0000
committerRich Felker <>2016-02-19 01:20:07 +0000
commit71c334f951d9ffa4d8bdc71bdd49628e5ae4512b (patch)
parented97dfd979c054b8c598875410529077dad84c02 (diff)
work around regression building for armhf with clang (compiler bug)
commit e4355bd6bec89688e8c739cd7b4c76e675643dca moved the math asm from external source files to inline asm, but unfortunately, all current releases of clang use the wrong inline asm constraint codes for float and double ("w" and "P" instead of "t" and "w", respectively). this patch adds detection for the bug in configure, and, for now, just disables the affected asm on broken clang versions.
3 files changed, 16 insertions, 2 deletions
diff --git a/configure b/configure
index 0e365856..5a92ea01 100755
--- a/configure
+++ b/configure
@@ -588,6 +588,20 @@ fi
if test "$ARCH" = "arm" ; then
trycppif __ARMEB__ "$t" && SUBARCH=${SUBARCH}eb
trycppif __ARM_PCS_VFP "$t" && SUBARCH=${SUBARCH}hf
+# Versions of clang up until at least 3.8 have the wrong constraint codes
+# for floating point operands to inline asm. Detect this so the affected
+# source files can just disable the asm.
+if test "$cc_family" = clang ; then
+printf "checking whether clang's vfp asm constraints work... "
+echo 'float f(float x) { __asm__("":"+t"(x)); return x; }' > "$tmpc"
+if $CC $CFLAGS_C99FSE $CPPFLAGS $CFLAGS -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then
+printf "yes\n"
+printf "no\n"
if test "$ARCH" = "aarch64" ; then
diff --git a/src/math/arm/fabsf.c b/src/math/arm/fabsf.c
index 28153a61..4a217c98 100644
--- a/src/math/arm/fabsf.c
+++ b/src/math/arm/fabsf.c
@@ -1,6 +1,6 @@
#include <math.h>
-#if __ARM_PCS_VFP
float fabsf(float x)
diff --git a/src/math/arm/sqrtf.c b/src/math/arm/sqrtf.c
index 98858ecd..32693293 100644
--- a/src/math/arm/sqrtf.c
+++ b/src/math/arm/sqrtf.c
@@ -1,6 +1,6 @@
#include <math.h>
-#if __ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)
+#if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && !BROKEN_VFP_ASM
float sqrtf(float x)