Merge release v1.1.14
diff --git a/COPYRIGHT b/COPYRIGHT
index b1e6217..f7f1a1f 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -25,6 +25,7 @@
 
 Authors/contributors include:
 
+Alex Dowad
 Alexander Monakov
 Anthony G. Basile
 Arvid Picciani
@@ -33,29 +34,37 @@
 Brent Cook
 Chris Spiegel
 Clément Vasseur
+Daniel Micay
 Denys Vlasenko
 Emil Renner Berthing
 Felix Fietkau
 Felix Janda
 Gianluca Anzolin
+Hauke Mehrtens
 Hiltjo Posthuma
 Isaac Dunham
 Jens Gustedt
 Jeremy Huntwork
+Jo-Philipp Wich
 Joakim Sindholt
 John Spencer
 Josiah Worcester
 Justin Cormack
+Khem Raj
+Kylie McClain
 Luca Barbato
 Luka Perkov
 M Farkas-Dyck (Strake)
 Michael Forney
+Natanael Copa
 Nicholas J. Kain
 orc
 Pascal Cuoq
+Petr Hosek
 Pierre Carrier
 Rich Felker
 Richard Pennington
+Shiz
 sin
 Solar Designer
 Stefan Kristiansson
diff --git a/Makefile b/Makefile
index b2a719d..ec54880 100644
--- a/Makefile
+++ b/Makefile
@@ -17,16 +17,22 @@
 libdir = $(prefix)/lib
 syslibdir = /lib
 
-BASE_SRCS = $(sort $(wildcard $(srcdir)/src/*/*.c))
+SRC_DIRS = $(addprefix $(srcdir)/,src/* crt ldso)
+BASE_GLOBS = $(addsuffix /*.c,$(SRC_DIRS))
+ARCH_GLOBS = $(addsuffix /$(ARCH)/*.[csS],$(SRC_DIRS))
+BASE_SRCS = $(sort $(wildcard $(BASE_GLOBS)))
+ARCH_SRCS = $(sort $(wildcard $(ARCH_GLOBS)))
 BASE_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(BASE_SRCS)))
-ARCH_SRCS = $(wildcard $(srcdir)/src/*/$(ARCH)/*.[csS])
 ARCH_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(ARCH_SRCS)))
 REPLACED_OBJS = $(sort $(subst /$(ARCH)/,/,$(ARCH_OBJS)))
-LDSO_SRCS = $(sort $(wildcard $(srcdir)/ldso/*.c))
-LDSO_OBJS = $(patsubst $(srcdir)/%,obj/%.lo,$(basename $(LDSO_SRCS)))
-OBJS = $(addprefix obj/, $(filter-out $(REPLACED_OBJS), $(sort $(BASE_OBJS) $(ARCH_OBJS))))
-AOBJS = $(OBJS)
-LOBJS = $(OBJS:.o=.lo)
+ALL_OBJS = $(addprefix obj/, $(filter-out $(REPLACED_OBJS), $(sort $(BASE_OBJS) $(ARCH_OBJS))))
+
+LIBC_OBJS = $(filter obj/src/%,$(ALL_OBJS))
+LDSO_OBJS = $(filter obj/ldso/%,$(ALL_OBJS:%.o=%.lo))
+CRT_OBJS = $(filter obj/crt/%,$(ALL_OBJS))
+
+AOBJS = $(LIBC_OBJS)
+LOBJS = $(LIBC_OBJS:.o=.lo)
 GENH = obj/include/bits/alltypes.h
 GENH_INT = obj/src/internal/version.h
 IMPH = $(addprefix $(srcdir)/, src/internal/stdio_impl.h src/internal/pthread_impl.h src/internal/libc.h)
@@ -56,7 +62,7 @@
 
 EMPTY_LIB_NAMES = m rt pthread crypt util xnet resolv dl
 EMPTY_LIBS = $(EMPTY_LIB_NAMES:%=lib/lib%.a)
-CRT_LIBS = lib/crt1.o lib/Scrt1.o lib/rcrt1.o lib/crti.o lib/crtn.o
+CRT_LIBS = $(addprefix lib/,$(notdir $(CRT_OBJS)))
 STATIC_LIBS = lib/libc.a
 SHARED_LIBS = lib/libc.so
 TOOL_LIBS = lib/musl-gcc.specs
@@ -71,26 +77,22 @@
 -include config.mak
 
 ifeq ($(ARCH),)
-$(error Please set ARCH in config.mak before running make.)
-endif
+
+all:
+	@echo "Please set ARCH in config.mak before running make."
+	@exit 1
+
+else
 
 all: $(ALL_LIBS) $(ALL_TOOLS)
 
-OBJ_DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_LIBS) $(ALL_TOOLS) $(OBJS) $(LDSO_OBJS) $(GENH) $(GENH_INT))) $(addprefix obj/, crt crt/$(ARCH) include))
+OBJ_DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(GENH) $(GENH_INT))) obj/include)
 
-$(ALL_LIBS) $(ALL_TOOLS) $(CRT_LIBS:lib/%=obj/crt/%) $(OBJS) $(LOBJS) $(GENH) $(GENH_INT): | $(OBJ_DIRS)
+$(ALL_LIBS) $(ALL_TOOLS) $(ALL_OBJS) $(ALL_OBJS:%.o=%.lo) $(GENH) $(GENH_INT): | $(OBJ_DIRS)
 
 $(OBJ_DIRS):
 	mkdir -p $@
 
-install: install-libs install-headers install-tools
-
-clean:
-	rm -rf obj lib
-
-distclean: clean
-	rm -f config.mak
-
 obj/include/bits/alltypes.h: $(srcdir)/arch/$(ARCH)/bits/alltypes.h.in $(srcdir)/include/alltypes.h.in $(srcdir)/tools/mkalltypes.sed
 	sed -f $(srcdir)/tools/mkalltypes.sed $(srcdir)/arch/$(ARCH)/bits/alltypes.h.in $(srcdir)/include/alltypes.h.in > $@
 
@@ -126,7 +128,7 @@
 	ldso/dlstart.c ldso/dynlink.c
 $(NOSSP_SRCS:%.c=obj/%.o) $(NOSSP_SRCS:%.c=obj/%.lo): CFLAGS_ALL += $(CFLAGS_NOSSP)
 
-$(CRT_LIBS:lib/%=obj/crt/%): CFLAGS_ALL += -DCRT
+$(CRT_OBJS): CFLAGS_ALL += -DCRT
 
 $(LOBJS) $(LDSO_OBJS): CFLAGS_ALL += -fPIC
 
@@ -170,15 +172,12 @@
 	rm -f $@
 	$(AR) rc $@
 
+lib/%.o: obj/crt/$(ARCH)/%.o
+	cp $< $@
+
 lib/%.o: obj/crt/%.o
 	cp $< $@
 
-lib/crti.o: obj/crt/$(ARCH)/crti.o
-	cp $< $@
-
-lib/crtn.o: obj/crt/$(ARCH)/crtn.o
-	cp $< $@
-
 lib/musl-gcc.specs: $(srcdir)/tools/musl-gcc.specs.sh config.mak
 	sh $< "$(includedir)" "$(libdir)" "$(LDSO_PATHNAME)" > $@
 
@@ -220,10 +219,20 @@
 
 install-tools: $(ALL_TOOLS:obj/%=$(DESTDIR)$(bindir)/%)
 
+install: install-libs install-headers install-tools
+
 musl-git-%.tar.gz: .git
 	 git --git-dir=$(srcdir)/.git archive --format=tar.gz --prefix=$(patsubst %.tar.gz,%,$@)/ -o $@ $(patsubst musl-git-%.tar.gz,%,$@)
 
 musl-%.tar.gz: .git
 	 git --git-dir=$(srcdir)/.git archive --format=tar.gz --prefix=$(patsubst %.tar.gz,%,$@)/ -o $@ v$(patsubst musl-%.tar.gz,%,$@)
 
+endif
+
+clean:
+	rm -rf obj lib
+
+distclean: clean
+	rm -f config.mak
+
 .PHONY: all clean install install-libs install-headers install-tools
diff --git a/VERSION b/VERSION
index 9ea63db..e9bc149 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.1.13
+1.1.14
diff --git a/WHATSNEW b/WHATSNEW
index 935c0bb..62daa1c 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -1678,3 +1678,16 @@
 - possibly misaligned pointer globals on arm (from an asm source file)
 - mips dynamic linker failed to provide info needed by debugger
 - mips cancellation asm wrongly assumed validity of $gp register value
+
+
+
+1.1.14 release notes
+
+regressions fixed:
+- treatment of empty string argument as error by puts and fputs
+- make clean and distclean failure in unconfigured trees
+- sh/fdpic dynamic linker entry point hang due to wrong code
+- armhf (and arm softfp model) build failure with clang
+
+other bugs fixed:
+- wrongly clamping (rather than failing) excessive rounds in crypt-sha*
diff --git a/configure b/configure
index 248c450..0955ce6 100755
--- a/configure
+++ b/configure
@@ -302,8 +302,10 @@
 mips64*|powerpc64*) fail "$0: unsupported target \"$target\"" ;;
 arm*) ARCH=arm ;;
 aarch64*) ARCH=aarch64 ;;
+i?86-nt32*) ARCH=nt32 ;;
 i?86*) ARCH=i386 ;;
 x86_64-x32*|x32*|x86_64*x32) ARCH=x32 ;;
+x86_64-nt64*) ARCH=nt64 ;;
 x86_64*) ARCH=x86_64 ;;
 mips*) ARCH=mips ;;
 microblaze*) ARCH=microblaze ;;
@@ -588,6 +590,20 @@
 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"
+else
+printf "no\n"
+CFLAGS_AUTO="$CFLAGS_AUTO -DBROKEN_VFP_ASM"
+CFLAGS_AUTO="${CFLAGS_AUTO# }"
+fi
+fi
 fi
 
 if test "$ARCH" = "aarch64" ; then
@@ -655,6 +671,16 @@
 fail "$0: error: unsupported long double type"
 fi
 
+#
+# Some build systems globally pass in broken CFLAGS like -ffast-math
+# for all packages. On recent GCC we can detect this and error out
+# early rather than producing a seriously-broken math library.
+#
+if trycppif "__FAST_MATH__" \
+  "$CFLAGS_C99FSE $CPPFLAGS $CFLAGS" ; then
+fail "$0: error: compiler has broken floating point; check CFLAGS"
+fi
+
 printf "creating config.mak... "
 
 cmdline=$(quote "$0")
diff --git a/crt/rcrt1.c b/crt/rcrt1.c
index e763d0a..be01715 100644
--- a/crt/rcrt1.c
+++ b/crt/rcrt1.c
@@ -1,4 +1,3 @@
-#define SHARED
 #define START "_start"
 #define _dlstart_c _start_c
 #include "../ldso/dlstart.c"
diff --git a/ldso/dlstart.c b/ldso/dlstart.c
index 4482d52..4dbe178 100644
--- a/ldso/dlstart.c
+++ b/ldso/dlstart.c
@@ -5,6 +5,8 @@
 #define START "_dlstart"
 #endif
 
+#define SHARED
+
 #include "crt_arch.h"
 
 #ifndef GETFUNCSYM
diff --git a/src/crypt/crypt_sha256.c b/src/crypt/crypt_sha256.c
index d5f0b78..e885dc6 100644
--- a/src/crypt/crypt_sha256.c
+++ b/src/crypt/crypt_sha256.c
@@ -230,7 +230,7 @@
 		if (u < ROUNDS_MIN)
 			r = ROUNDS_MIN;
 		else if (u > ROUNDS_MAX)
-			r = ROUNDS_MAX;
+			return 0;
 		else
 			r = u;
 		/* needed when rounds is zero prefixed or out of bounds */
diff --git a/src/crypt/crypt_sha512.c b/src/crypt/crypt_sha512.c
index 1294e98..39970ca 100644
--- a/src/crypt/crypt_sha512.c
+++ b/src/crypt/crypt_sha512.c
@@ -252,7 +252,7 @@
 		if (u < ROUNDS_MIN)
 			r = ROUNDS_MIN;
 		else if (u > ROUNDS_MAX)
-			r = ROUNDS_MAX;
+			return 0;
 		else
 			r = u;
 		/* needed when rounds is zero prefixed or out of bounds */
diff --git a/src/math/arm/fabsf.c b/src/math/arm/fabsf.c
index 28153a6..4a217c9 100644
--- a/src/math/arm/fabsf.c
+++ b/src/math/arm/fabsf.c
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#if __ARM_PCS_VFP
+#if __ARM_PCS_VFP && !BROKEN_VFP_ASM
 
 float fabsf(float x)
 {
diff --git a/src/math/arm/sqrt.c b/src/math/arm/sqrt.c
index c9c0008..874af96 100644
--- a/src/math/arm/sqrt.c
+++ b/src/math/arm/sqrt.c
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#if __VFP_FP__ && !__SOFTFP__
+#if __ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)
 
 double sqrt(double x)
 {
diff --git a/src/math/arm/sqrtf.c b/src/math/arm/sqrtf.c
index e657665..3269329 100644
--- a/src/math/arm/sqrtf.c
+++ b/src/math/arm/sqrtf.c
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#if __VFP_FP__ && !__SOFTFP__
+#if (__ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)) && !BROKEN_VFP_ASM
 
 float sqrtf(float x)
 {
diff --git a/src/misc/getopt.c b/src/misc/getopt.c
index 9217983..8290aef 100644
--- a/src/misc/getopt.c
+++ b/src/misc/getopt.c
@@ -17,9 +17,9 @@
 	FILE *f = stderr;
 	b = __lctrans_cur(b);
 	flockfile(f);
-	fwrite(a, strlen(a), 1, f)
+	fputs(a, f)>=0
 	&& fwrite(b, strlen(b), 1, f)
-	&& fwrite(c, l, 1, f)
+	&& fwrite(c, 1, l, f)==l
 	&& putc('\n', f);
 	funlockfile(f);
 }
diff --git a/src/stdio/fputs.c b/src/stdio/fputs.c
index 4737f44..1cf344f 100644
--- a/src/stdio/fputs.c
+++ b/src/stdio/fputs.c
@@ -3,7 +3,8 @@
 
 int fputs(const char *restrict s, FILE *restrict f)
 {
-	return (int)fwrite(s, strlen(s), 1, f) - 1;
+	size_t l = strlen(s);
+	return (fwrite(s, 1, l, f)==l) - 1;
 }
 
 weak_alias(fputs, fputs_unlocked);