diff -u musl-1.1.12/configure musl-1.1.12.alt/configure --- musl-1.1.12/configure 2015-10-19 19:12:57.000000000 -0400 +++ musl-1.1.12.alt/configure 2015-11-04 18:08:50.676855247 -0500 @@ -22,6 +22,7 @@ System types: --target=TARGET configure to run on target TARGET [detected] --host=HOST same as --target + --arch=ARCH use alternate ARCH-specific source files for TARGET Optional features: --enable-optimize=... optimize listed components for speed over size [auto] @@ -166,6 +167,7 @@ --enable-gcc-wrapper|--enable-gcc-wrapper=yes) wrapper=yes ; gcc_wrapper=yes ;; --disable-gcc-wrapper|--enable-gcc-wrapper=no) wrapper=no ;; --enable-*|--disable-*|--with-*|--without-*|--*dir=*|--build=*) ;; +--arch=*) ARCH=${arg#*=} ;; --host=*|--target=*) target=${arg#*=} ;; -* ) echo "$0: unknown option $arg" ;; CC=*) CC=${arg#*=} ;; @@ -280,7 +282,7 @@ # # Convert to just ARCH # -case "$target" in +test -z "$ARCH" && case "$target" in # Catch these early to simplify matching for 32-bit archs mips64*|powerpc64*) fail "$0: unsupported target \"$target\"" ;; arm*) ARCH=arm ;; @@ -504,6 +506,10 @@ CFLAGS_AUTO="${CFLAGS_AUTO# }" fi +# detect PE targets +test -z "$PE_TARGET" && "$CC" -dM -E - < /dev/null \ + | grep __PE__ >/dev/null && PE_TARGET=yes + # Some patched GCC builds have these defaults messed up... tryldflag LDFLAGS_AUTO -Wl,--hash-style=both @@ -513,7 +519,7 @@ # runtime library; implementation error is also a possibility. tryldflag LDFLAGS_AUTO -Wl,--no-undefined -test "$shared" = "no" || { +test "$shared" = "no" || test "$PE_TARGET" = "yes" || { # Disable dynamic linking if ld is broken and can't do -Bsymbolic-functions LDFLAGS_DUMMY= tryldflag LDFLAGS_DUMMY -Wl,-Bsymbolic-functions || { @@ -523,6 +529,19 @@ } } +# PE/ELF-specific LDFLAGS +test "$shared" = "no" || { + +test "$PE_TARGET" = "yes" && "$CC" -dM -E - < /dev/null \ + | grep __SIZEOF_POINTER__ | grep 4 >/dev/null && underscore='_' + +test "$PE_TARGET" = "yes" && \ + LDFLAGS_IMG_FMT="-Wl,-e,${underscore}__libc_entry_point -Wl,--subsystem,windows" + +test "$PE_TARGET" = "yes" || \ + LDFLAGS_IMG_FMT="-Wl,-e,_dlstart -Wl,-Bsymbolic-functions" +} + # Find compiler runtime library test -z "$LIBCC" && tryldflag LIBCC -lgcc && tryldflag LIBCC -lgcc_eh test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt @@ -634,7 +653,7 @@ CFLAGS_MEMOPS = $CFLAGS_MEMOPS CFLAGS_NOSSP = $CFLAGS_NOSSP CPPFLAGS = $CPPFLAGS -LDFLAGS = $LDFLAGS_AUTO $LDFLAGS +LDFLAGS = $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_IMG_FMT CROSS_COMPILE = $CROSS_COMPILE LIBCC = $LIBCC OPTIMIZE_GLOBS = $OPTIMIZE_GLOBS diff -u musl-1.1.12/Makefile musl-1.1.12.alt/Makefile --- musl-1.1.12/Makefile 2015-10-19 19:12:57.000000000 -0400 +++ musl-1.1.12.alt/Makefile 2015-11-04 17:48:16.764815762 -0500 @@ -133,6 +133,9 @@ %.o: $(ARCH)/%.s $(AS_CMD) $(CFLAGS_ALL_STATIC) +%.o: $(ARCH)/%.c $(GENH) $(IMPH) + $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $< + %.o: %.c $(GENH) $(IMPH) $(CC) $(CFLAGS_ALL_STATIC) -c -o $@ $< @@ -142,12 +145,14 @@ %.lo: $(ARCH)/%.s $(AS_CMD) $(CFLAGS_ALL_SHARED) +%.lo: $(ARCH)/%.c $(GENH) $(IMPH) + $(CC) $(CFLAGS_ALL_SHARED) -c -o $@ $< + %.lo: %.c $(GENH) $(IMPH) $(CC) $(CFLAGS_ALL_SHARED) -c -o $@ $< lib/libc.so: $(LOBJS) $(CC) $(CFLAGS_ALL_SHARED) $(LDFLAGS) -nostdlib -shared \ - -Wl,-e,_dlstart -Wl,-Bsymbolic-functions \ -o $@ $(LOBJS) $(LIBCC) lib/libc.a: $(OBJS)