diff --git a/configure b/configure
index 539c9fc..4a8aafd 100755
--- a/configure
+++ b/configure
@@ -31,6 +31,7 @@ Optional features:
   --enable-optimize=...   optimize listed components for speed over size [auto]
   --enable-debug          build with debugging information [disabled]
   --enable-warnings       build with recommended warnings flags [disabled]
+  --enable-depends        build with include dependency information [disabled]
   --enable-visibility     use global visibility options to optimize PIC [auto]
   --enable-wrapper=...    build given musl toolchain wrapper [auto]
   --disable-shared        inhibit building shared library [enabled]
@@ -134,6 +135,7 @@ build=
 target=
 optimize=auto
 debug=no
+depends=no
 warnings=no
 visibility=auto
 shared=auto
@@ -161,6 +163,8 @@ case "$arg" in
 --disable-optimize) optimize=no ;;
 --enable-debug|--enable-debug=yes) debug=yes ;;
 --disable-debug|--enable-debug=no) debug=no ;;
+--enable-depends|--enable-depends=yes) depends=yes ;;
+--disable-depends|--enable-depends=no) depends=no ;;
 --enable-warnings|--enable-warnings=yes) warnings=yes ;;
 --disable-warnings|--enable-warnings=no) warnings=no ;;
 --enable-visibility|--enable-visibility=yes) visibility=yes ;;
@@ -312,10 +316,14 @@ printf "%s\n" "$target"
 #
 case "$target" in
 # Catch these early to simplify matching for 32-bit archs
+arm64*) ARCH=aarch64 ;;
 arm*) ARCH=arm ;;
+thumb*) ARCH=arm ;;
+cortex*) ARCH=arm ;;
 aarch64*) ARCH=aarch64 ;;
 i?86-nt32*) ARCH=nt32 ;;
 i?86*) ARCH=i386 ;;
+x86_32*) ARCH=i386 ;;
 x86_64-x32*|x32*|x86_64*x32) ARCH=x32 ;;
 x86_64-nt64*) ARCH=nt64 ;;
 x86_64*) ARCH=x86_64 ;;
@@ -325,6 +333,8 @@ microblaze*) ARCH=microblaze ;;
 or1k*) ARCH=or1k ;;
 powerpc64*) ARCH=powerpc64 ;;
 powerpc*) ARCH=powerpc ;;
+ppc64*) ARCH=powerpc64 ;;
+ppc*) ARCH=powerpc ;;
 sh[1-9bel-]*|sh|superh*) ARCH=sh ;;
 s390x*) ARCH=s390x ;;
 unknown) fail "$0: unable to detect target arch; try $0 --target=..." ;;
@@ -718,6 +728,11 @@ fail "$0: error: unsupported long double type"
 fi
 
 #
+# Enable depends if requested.
+#
+test "$depends" = yes && CFLAGS_AUTO="$CFLAGS_AUTO -MD -MP"
+
+#
 # 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.
diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index 35a90ae..d8951f7 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -980,33 +980,55 @@ static struct dso *load_library(const char *name, struct dso *needed_by)
 		if (fd == -1) {
 			if (!sys_path) {
 				char *prefix = 0;
+				size_t prefix0_len;
 				size_t prefix_len;
 				if (ldso.name[0]=='/') {
 					char *s, *t, *z;
 					for (s=t=z=ldso.name; *s; s++)
 						if (*s=='/') z=t, t=s;
+					prefix0_len = t-ldso.name;
 					prefix_len = z-ldso.name;
 					if (prefix_len < PATH_MAX)
 						prefix = ldso.name;
 				}
 				if (!prefix) {
 					prefix = "";
+					prefix0_len = 0;
 					prefix_len = 0;
 				}
-				char etc_ldso_path[prefix_len + 1
-					+ sizeof "/etc/ld-musl-" LDSO_ARCH ".path"];
-				snprintf(etc_ldso_path, sizeof etc_ldso_path,
-					"%.*s/etc/ld-musl-" LDSO_ARCH ".path",
-					(int)prefix_len, prefix);
-				FILE *f = fopen(etc_ldso_path, "rbe");
-				if (f) {
-					if (getdelim(&sys_path, (size_t[1]){0}, 0, f) <= 0) {
-						free(sys_path);
+				if (prefix0_len) {
+					char ldso_path[prefix0_len + 1
+						+ sizeof "/ld-musl.path"];
+					snprintf(ldso_path, sizeof ldso_path,
+						"%.*s/ld-musl.path",
+						(int)prefix0_len, prefix);
+					FILE *f = fopen(ldso_path, "rbe");
+					if (f) {
+						if (getdelim(&sys_path, (size_t[1]){0}, 0, f) <= 0) {
+							free(sys_path);
+							sys_path = 0;
+						}
+						fclose(f);
+					} else if (errno != ENOENT) {
+						sys_path = 0;
+					}
+				}
+				if (!sys_path) {
+					char etc_ldso_path[prefix_len + 1
+						+ sizeof "/etc/ld-musl-" LDSO_ARCH ".path"];
+					snprintf(etc_ldso_path, sizeof etc_ldso_path,
+						"%.*s/etc/ld-musl-" LDSO_ARCH ".path",
+						(int)prefix_len, prefix);
+					FILE *f = fopen(etc_ldso_path, "rbe");
+					if (f) {
+						if (getdelim(&sys_path, (size_t[1]){0}, 0, f) <= 0) {
+							free(sys_path);
+							sys_path = "";
+						}
+						fclose(f);
+					} else if (errno != ENOENT) {
 						sys_path = "";
 					}
-					fclose(f);
-				} else if (errno != ENOENT) {
-					sys_path = "";
 				}
 			}
 			if (!sys_path) sys_path = "/lib:/usr/local/lib:/usr/lib";
diff --git a/src/math/powerpc64/fmax.c b/src/math/powerpc64/fmax.c
index 992df7f..0098442 100644
--- a/src/math/powerpc64/fmax.c
+++ b/src/math/powerpc64/fmax.c
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#ifdef __VSX__
+#if !defined(__clang__) && defined(__VSX__)
 
 double fmax(double x, double y)
 {
diff --git a/src/math/powerpc64/fmaxf.c b/src/math/powerpc64/fmaxf.c
index 345a234..b38ab9b 100644
--- a/src/math/powerpc64/fmaxf.c
+++ b/src/math/powerpc64/fmaxf.c
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#ifdef __VSX__
+#if !defined(__clang__) && defined(__VSX__)
 
 float fmaxf(float x, float y)
 {
diff --git a/src/math/powerpc64/fmin.c b/src/math/powerpc64/fmin.c
index adf71ba..1ab080d 100644
--- a/src/math/powerpc64/fmin.c
+++ b/src/math/powerpc64/fmin.c
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#ifdef __VSX__
+#if !defined(__clang__) && defined(__VSX__)
 
 double fmin(double x, double y)
 {
diff --git a/src/math/powerpc64/fminf.c b/src/math/powerpc64/fminf.c
index faf0e47..fcbd0cd 100644
--- a/src/math/powerpc64/fminf.c
+++ b/src/math/powerpc64/fminf.c
@@ -1,6 +1,6 @@
 #include <math.h>
 
-#ifdef __VSX__
+#if !defined(__clang__) && defined(__VSX__)
 
 float fminf(float x, float y)
 {
diff --git a/src/setjmp/arm/longjmp.s b/src/setjmp/arm/longjmp.s
index 6191ab2..c779306 100644
--- a/src/setjmp/arm/longjmp.s
+++ b/src/setjmp/arm/longjmp.s
@@ -7,6 +7,7 @@ _longjmp:
 longjmp:
 	mov ip,r0
 	movs r0,r1
+  it eq
 	moveq r0,#1
 	ldmia ip!, {v1,v2,v3,v4,v5,v6,sl,fp}
 	ldmia ip!, {r2,lr}
diff --git a/src/thread/arm/atomics.s b/src/thread/arm/atomics.s
index 101ad39..04bac25 100644
--- a/src/thread/arm/atomics.s
+++ b/src/thread/arm/atomics.s
@@ -43,6 +43,7 @@ __a_cas_dummy:
 	mov r3,r0
 	ldr r0,[r2]
 	subs r0,r3,r0
+  it eq
 	streq r1,[r2]
 	bx lr
 
@@ -55,7 +56,9 @@ __a_cas_v6:
 	mcr p15,0,r0,c7,c10,5
 1:	ldrex r0,[r2]
 	subs r0,r3,r0
+  it eq
 	strexeq r0,r1,[r2]
+  it eq
 	teqeq r0,#1
 	beq 1b
 	mcr p15,0,r0,c7,c10,5
@@ -70,7 +73,9 @@ __a_cas_v7:
 	dmb ish
 1:	ldrex r0,[r2]
 	subs r0,r3,r0
+  it eq
 	strexeq r0,r1,[r2]
+  it eq
 	teqeq r0,#1
 	beq 1b
 	dmb ish
diff --git a/src/thread/arm/syscall_cp.s b/src/thread/arm/syscall_cp.s
index a5730c0..399700b 100644
--- a/src/thread/arm/syscall_cp.s
+++ b/src/thread/arm/syscall_cp.s
@@ -15,6 +15,7 @@ __syscall_cp_asm:
 __cp_begin:
 	ldr r0,[r0]
 	cmp r0,#0
+  it ne
 	blne __cp_cancel
 	mov r7,r1
 	mov r0,r2
