diff --git a/configure b/configure index f32d6cd4fc7..f4e1d41276a 100755 --- a/configure +++ b/configure @@ -583,6 +583,7 @@ valopt jemalloc-root "" "set directory where libjemalloc_pic.a is located" valopt build "${DEFAULT_BUILD}" "GNUs ./configure syntax LLVM build triple" valopt android-cross-path "/opt/ndk_standalone" "Android NDK standalone path" valopt release-channel "dev" "the name of the release channel to build" +valopt musl-root "/usr/local" "MUSL root installation directory" # Many of these are saved below during the "writing configuration" step # (others are conditionally saved). @@ -1058,6 +1059,13 @@ do fi ;; + + *-musl) + if [ ! -f $CFG_MUSL_ROOT/lib/libc.a ] + then + err "musl libc $CFG_MUSL_ROOT/lib/libc.a not found" + fi + ;; *) ;; esac diff --git a/mk/cfg/aarch64-apple-ios.mk b/mk/cfg/aarch64-apple-ios.mk index 0219ab96057..7767129a5e2 100644 --- a/mk/cfg/aarch64-apple-ios.mk +++ b/mk/cfg/aarch64-apple-ios.mk @@ -20,16 +20,12 @@ CFG_GCCISH_CFLAGS_aarch64-apple-ios := -Wall -Werror -fPIC $(CFG_IOS_SDK_FLAGS_a CFG_GCCISH_CXXFLAGS_aarch64-apple-ios := -fno-rtti $(CFG_IOS_SDK_FLAGS_aarch64-apple-ios) -I$(CFG_IOS_SDK_aarch64-apple-ios)/usr/include/c++/4.2.1 CFG_GCCISH_LINK_FLAGS_aarch64-apple-ios := -lpthread -syslibroot $(CFG_IOS_SDK_aarch64-apple-ios) -Wl,-no_compact_unwind CFG_GCCISH_DEF_FLAG_aarch64-apple-ios := -Wl,-exported_symbols_list, -CFG_GCCISH_PRE_LIB_FLAGS_aarch64-apple-ios := -CFG_GCCISH_POST_LIB_FLAGS_aarch64-apple-ios := -CFG_DEF_SUFFIX_aarch64-apple-ios := .darwin.def CFG_LLC_FLAGS_aarch64-apple-ios := -mattr=+neon,+cyclone,+fp-armv8 CFG_INSTALL_NAME_aarch64-apple-ios = -Wl,-install_name,@rpath/$(1) CFG_LIBUV_LINK_FLAGS_aarch64-apple-ios = CFG_EXE_SUFFIX_aarch64-apple-ios := CFG_WINDOWSY_aarch64-apple-ios := CFG_UNIXY_aarch64-apple-ios := 1 -CFG_PATH_MUNGE_aarch64-apple-ios := true CFG_LDPATH_aarch64-apple-ios := CFG_RUN_aarch64-apple-ios = $(2) CFG_RUN_TARG_aarch64-apple-ios = $(call CFG_RUN_aarch64-apple-ios,,$(2)) diff --git a/mk/cfg/aarch64-linux-android.mk b/mk/cfg/aarch64-linux-android.mk index a6f7f2ba1d6..d7a1405c3d0 100644 --- a/mk/cfg/aarch64-linux-android.mk +++ b/mk/cfg/aarch64-linux-android.mk @@ -13,15 +13,11 @@ CFG_GCCISH_CFLAGS_aarch64-linux-android := -Wall -g -fPIC -D__aarch64__ -DANDROI CFG_GCCISH_CXXFLAGS_aarch64-linux-android := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_aarch64-linux-android := -shared -fPIC -ldl -g -lm -lsupc++ CFG_GCCISH_DEF_FLAG_aarch64-linux-android := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_aarch64-linux-android := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_aarch64-linux-android := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_aarch64-linux-android := .android.def CFG_LLC_FLAGS_aarch64-linux-android := CFG_INSTALL_NAME_aarch64-linux-android = CFG_EXE_SUFFIX_aarch64-linux-android := CFG_WINDOWSY_aarch64-linux-android := CFG_UNIXY_aarch64-linux-android := 1 -CFG_PATH_MUNGE_aarch64-linux-android := true CFG_LDPATH_aarch64-linux-android := CFG_RUN_aarch64-linux-android= CFG_RUN_TARG_aarch64-linux-android= diff --git a/mk/cfg/aarch64-unknown-linux-gnu.mk b/mk/cfg/aarch64-unknown-linux-gnu.mk index fade0266549..6637423e495 100644 --- a/mk/cfg/aarch64-unknown-linux-gnu.mk +++ b/mk/cfg/aarch64-unknown-linux-gnu.mk @@ -13,15 +13,11 @@ CFG_GCCISH_CFLAGS_aarch64-unknown-linux-gnu := -Wall -g -fPIC -D__aarch64__ $(CF CFG_GCCISH_CXXFLAGS_aarch64-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_aarch64-unknown-linux-gnu := -shared -fPIC -g CFG_GCCISH_DEF_FLAG_aarch64-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_aarch64-unknown-linux-gnu := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_aarch64-unknown-linux-gnu := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_aarch64-unknown-linux-gnu := .linux.def CFG_LLC_FLAGS_aarch64-unknown-linux-gnu := CFG_INSTALL_NAME_aarch64-unknown-linux-gnu = CFG_EXE_SUFFIX_aarch64-unknown-linux-gnu := CFG_WINDOWSY_aarch64-unknown-linux-gnu := CFG_UNIXY_aarch64-unknown-linux-gnu := 1 -CFG_PATH_MUNGE_aarch64-unknown-linux-gnu := true CFG_LDPATH_aarch64-unknown-linux-gnu := CFG_RUN_aarch64-unknown-linux-gnu=$(2) CFG_RUN_TARG_aarch64-unknown-linux-gnu=$(call CFG_RUN_aarch64-unknown-linux-gnu,,$(2)) diff --git a/mk/cfg/arm-linux-androideabi.mk b/mk/cfg/arm-linux-androideabi.mk index 471220e2b66..fdd38ba75fe 100644 --- a/mk/cfg/arm-linux-androideabi.mk +++ b/mk/cfg/arm-linux-androideabi.mk @@ -12,15 +12,11 @@ CFG_GCCISH_CFLAGS_arm-linux-androideabi := -Wall -g -fPIC -D__arm__ -DANDROID -D CFG_GCCISH_CXXFLAGS_arm-linux-androideabi := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_arm-linux-androideabi := -shared -fPIC -ldl -g -lm -lsupc++ CFG_GCCISH_DEF_FLAG_arm-linux-androideabi := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_arm-linux-androideabi := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_arm-linux-androideabi := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_arm-linux-androideabi := .android.def CFG_LLC_FLAGS_arm-linux-androideabi := CFG_INSTALL_NAME_arm-linux-androideabi = CFG_EXE_SUFFIX_arm-linux-androideabi := CFG_WINDOWSY_arm-linux-androideabi := CFG_UNIXY_arm-linux-androideabi := 1 -CFG_PATH_MUNGE_arm-linux-androideabi := true CFG_LDPATH_arm-linux-androideabi := CFG_RUN_arm-linux-androideabi= CFG_RUN_TARG_arm-linux-androideabi= diff --git a/mk/cfg/arm-unknown-linux-gnueabi.mk b/mk/cfg/arm-unknown-linux-gnueabi.mk index b4c604b26ba..9a91097458e 100644 --- a/mk/cfg/arm-unknown-linux-gnueabi.mk +++ b/mk/cfg/arm-unknown-linux-gnueabi.mk @@ -13,15 +13,11 @@ CFG_GCCISH_CFLAGS_arm-unknown-linux-gnueabi := -Wall -g -fPIC -D__arm__ -mfpu=vf CFG_GCCISH_CXXFLAGS_arm-unknown-linux-gnueabi := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_arm-unknown-linux-gnueabi := -shared -fPIC -g CFG_GCCISH_DEF_FLAG_arm-unknown-linux-gnueabi := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_arm-unknown-linux-gnueabi := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_arm-unknown-linux-gnueabi := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_arm-unknown-linux-gnueabi := .linux.def CFG_LLC_FLAGS_arm-unknown-linux-gnueabi := CFG_INSTALL_NAME_arm-unknown-linux-gnueabi = CFG_EXE_SUFFIX_arm-unknown-linux-gnueabi := CFG_WINDOWSY_arm-unknown-linux-gnueabi := CFG_UNIXY_arm-unknown-linux-gnueabi := 1 -CFG_PATH_MUNGE_arm-unknown-linux-gnueabi := true CFG_LDPATH_arm-unknown-linux-gnueabi := CFG_RUN_arm-unknown-linux-gnueabi=$(2) CFG_RUN_TARG_arm-unknown-linux-gnueabi=$(call CFG_RUN_arm-unknown-linux-gnueabi,,$(2)) diff --git a/mk/cfg/arm-unknown-linux-gnueabihf.mk b/mk/cfg/arm-unknown-linux-gnueabihf.mk index 4f02de0f6b5..0bd661ea00d 100644 --- a/mk/cfg/arm-unknown-linux-gnueabihf.mk +++ b/mk/cfg/arm-unknown-linux-gnueabihf.mk @@ -13,15 +13,11 @@ CFG_GCCISH_CFLAGS_arm-unknown-linux-gnueabihf := -Wall -g -fPIC -D__arm__ $(CFLA CFG_GCCISH_CXXFLAGS_arm-unknown-linux-gnueabihf := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_arm-unknown-linux-gnueabihf := -shared -fPIC -g CFG_GCCISH_DEF_FLAG_arm-unknown-linux-gnueabihf := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_arm-unknown-linux-gnueabihf := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_arm-unknown-linux-gnueabihf := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_arm-unknown-linux-gnueabihf := .linux.def CFG_LLC_FLAGS_arm-unknown-linux-gnueabihf := CFG_INSTALL_NAME_ar,-unknown-linux-gnueabihf = CFG_EXE_SUFFIX_arm-unknown-linux-gnueabihf := CFG_WINDOWSY_arm-unknown-linux-gnueabihf := CFG_UNIXY_arm-unknown-linux-gnueabihf := 1 -CFG_PATH_MUNGE_arm-unknown-linux-gnueabihf := true CFG_LDPATH_arm-unknown-linux-gnueabihf := CFG_RUN_arm-unknown-linux-gnueabihf=$(2) CFG_RUN_TARG_arm-unknown-linux-gnueabihf=$(call CFG_RUN_arm-unknown-linux-gnueabihf,,$(2)) diff --git a/mk/cfg/armv7-apple-ios.mk b/mk/cfg/armv7-apple-ios.mk index aee4e64addf..d4696976574 100644 --- a/mk/cfg/armv7-apple-ios.mk +++ b/mk/cfg/armv7-apple-ios.mk @@ -19,15 +19,11 @@ CFG_GCCISH_CFLAGS_armv7-apple-ios := -Wall -Werror -g -fPIC $(CFG_IOS_SDK_FLAGS_ CFG_GCCISH_CXXFLAGS_armv7-apple-ios := -fno-rtti $(CFG_IOS_SDK_FLAGS_armv7-apple-ios) -I$(CFG_IOS_SDK_armv7-apple-ios)/usr/include/c++/4.2.1 CFG_GCCISH_LINK_FLAGS_armv7-apple-ios := -lpthread -syslibroot $(CFG_IOS_SDK_armv7-apple-ios) -Wl,-no_compact_unwind CFG_GCCISH_DEF_FLAG_armv7-apple-ios := -Wl,-exported_symbols_list, -CFG_GCCISH_PRE_LIB_FLAGS_armv7-apple-ios := -CFG_GCCISH_POST_LIB_FLAGS_armv7-apple-ios := -CFG_DEF_SUFFIX_armv7-apple-ios := .darwin.def CFG_LLC_FLAGS_armv7-apple-ios := -mattr=+vfp3,+v7,+neon -march=arm CFG_INSTALL_NAME_armv7-apple-ios = -Wl,-install_name,@rpath/$(1) CFG_EXE_SUFFIX_armv7-apple-ios := CFG_WINDOWSY_armv7-apple-ios := CFG_UNIXY_armv7-apple-ios := 1 -CFG_PATH_MUNGE_armv7-apple-ios := true CFG_LDPATH_armv7-apple-ios := CFG_RUN_armv7-apple-ios = $(2) CFG_RUN_TARG_armv7-apple-ios = $(call CFG_RUN_armv7-apple-ios,,$(2)) diff --git a/mk/cfg/armv7s-apple-ios.mk b/mk/cfg/armv7s-apple-ios.mk index 7540bd44de8..96ca0764894 100644 --- a/mk/cfg/armv7s-apple-ios.mk +++ b/mk/cfg/armv7s-apple-ios.mk @@ -19,15 +19,11 @@ CFG_GCCISH_CFLAGS_armv7s-apple-ios := -Wall -Werror -g -fPIC $(CFG_IOS_SDK_FLAGS CFG_GCCISH_CXXFLAGS_armv7s-apple-ios := -fno-rtti $(CFG_IOS_SDK_FLAGS_armv7s-apple-ios) -I$(CFG_IOS_SDK_armv7s-apple-ios)/usr/include/c++/4.2.1 CFG_GCCISH_LINK_FLAGS_armv7s-apple-ios := -lpthread -syslibroot $(CFG_IOS_SDK_armv7s-apple-ios) -Wl,-no_compact_unwind CFG_GCCISH_DEF_FLAG_armv7s-apple-ios := -Wl,-exported_symbols_list, -CFG_GCCISH_PRE_LIB_FLAGS_armv7s-apple-ios := -CFG_GCCISH_POST_LIB_FLAGS_armv7s-apple-ios := -CFG_DEF_SUFFIX_armv7s-apple-ios := .darwin.def CFG_LLC_FLAGS_armv7s-apple-ios := -mattr=+vfp4,+v7,+neon CFG_INSTALL_NAME_armv7s-apple-ios = -Wl,-install_name,@rpath/$(1) CFG_EXE_SUFFIX_armv7s-apple-ios := CFG_WINDOWSY_armv7s-apple-ios := CFG_UNIXY_armv7s-apple-ios := 1 -CFG_PATH_MUNGE_armv7s-apple-ios := true CFG_LDPATH_armv7s-apple-ios := CFG_RUN_armv7s-apple-ios = $(2) CFG_RUN_TARG_armv7s-apple-ios = $(call CFG_RUN_armv7s-apple-ios,,$(2)) diff --git a/mk/cfg/i386-apple-ios.mk b/mk/cfg/i386-apple-ios.mk index e84bf49d407..373e2e3b65d 100644 --- a/mk/cfg/i386-apple-ios.mk +++ b/mk/cfg/i386-apple-ios.mk @@ -18,15 +18,11 @@ CFG_GCCISH_CFLAGS_i386-apple-ios := -Wall -Werror -g -fPIC -m32 $(CFG_IOSSIM_FLA CFG_GCCISH_CXXFLAGS_i386-apple-ios := -fno-rtti $(CFG_IOSSIM_FLAGS_i386-apple-ios) -I$(CFG_IOSSIM_SDK_i386-apple-ios)/usr/include/c++/4.2.1 CFG_GCCISH_LINK_FLAGS_i386-apple-ios := -lpthread -m32 -Wl,-no_compact_unwind -m32 -Wl,-syslibroot $(CFG_IOSSIM_SDK_i386-apple-ios) CFG_GCCISH_DEF_FLAG_i386-apple-ios := -Wl,-exported_symbols_list, -CFG_GCCISH_PRE_LIB_FLAGS_i386-apple-ios := -CFG_GCCISH_POST_LIB_FLAGS_i386-apple-ios := -CFG_DEF_SUFFIX_i386-apple-ios := .darwin.def CFG_LLC_FLAGS_i386-apple-ios = CFG_INSTALL_NAME_i386-apple-ios = -Wl,-install_name,@rpath/$(1) CFG_EXE_SUFFIX_i386-apple-ios := CFG_WINDOWSY_i386-apple-ios := CFG_UNIXY_i386-apple-ios := 1 -CFG_PATH_MUNGE_i386-apple-ios = :true CFG_LDPATH_i386-apple-ios = CFG_RUN_i386-apple-ios = $(2) CFG_RUN_TARG_i386-apple-ios = $(call CFG_RUN_i386-apple-ios,,$(2)) diff --git a/mk/cfg/i686-apple-darwin.mk b/mk/cfg/i686-apple-darwin.mk index e935ce053e0..7ebb492bb21 100644 --- a/mk/cfg/i686-apple-darwin.mk +++ b/mk/cfg/i686-apple-darwin.mk @@ -12,15 +12,11 @@ CFG_GCCISH_CFLAGS_i686-apple-darwin := -Wall -Werror -g -fPIC -m32 -arch i386 $( CFG_GCCISH_CXXFLAGS_i686-apple-darwin := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_i686-apple-darwin := -dynamiclib -pthread -framework CoreServices -m32 CFG_GCCISH_DEF_FLAG_i686-apple-darwin := -Wl,-exported_symbols_list, -CFG_GCCISH_PRE_LIB_FLAGS_i686-apple-darwin := -CFG_GCCISH_POST_LIB_FLAGS_i686-apple-darwin := -CFG_DEF_SUFFIX_i686-apple-darwin := .darwin.def CFG_LLC_FLAGS_i686-apple-darwin := CFG_INSTALL_NAME_i686-apple-darwin = -Wl,-install_name,@rpath/$(1) CFG_EXE_SUFFIX_i686-apple-darwin := CFG_WINDOWSY_i686-apple-darwin := CFG_UNIXY_i686-apple-darwin := 1 -CFG_PATH_MUNGE_i686-apple-darwin := true CFG_LDPATH_i686-apple-darwin := CFG_RUN_i686-apple-darwin=$(2) CFG_RUN_TARG_i686-apple-darwin=$(call CFG_RUN_i686-apple-darwin,,$(2)) diff --git a/mk/cfg/i686-pc-windows-gnu.mk b/mk/cfg/i686-pc-windows-gnu.mk index 357a321688b..174671a9a88 100644 --- a/mk/cfg/i686-pc-windows-gnu.mk +++ b/mk/cfg/i686-pc-windows-gnu.mk @@ -13,15 +13,11 @@ CFG_GCCISH_CFLAGS_i686-pc-windows-gnu := -Wall -Werror -g -m32 -D_WIN32_WINNT=0x CFG_GCCISH_CXXFLAGS_i686-pc-windows-gnu := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_i686-pc-windows-gnu := -shared -g -m32 CFG_GCCISH_DEF_FLAG_i686-pc-windows-gnu := -CFG_GCCISH_PRE_LIB_FLAGS_i686-pc-windows-gnu := -CFG_GCCISH_POST_LIB_FLAGS_i686-pc-windows-gnu := -CFG_DEF_SUFFIX_i686-pc-windows-gnu := .windows.def CFG_LLC_FLAGS_i686-pc-windows-gnu := CFG_INSTALL_NAME_i686-pc-windows-gnu = CFG_EXE_SUFFIX_i686-pc-windows-gnu := .exe CFG_WINDOWSY_i686-pc-windows-gnu := 1 CFG_UNIXY_i686-pc-windows-gnu := -CFG_PATH_MUNGE_i686-pc-windows-gnu := CFG_LDPATH_i686-pc-windows-gnu := CFG_RUN_i686-pc-windows-gnu=$(2) CFG_RUN_TARG_i686-pc-windows-gnu=$(call CFG_RUN_i686-pc-windows-gnu,,$(2)) diff --git a/mk/cfg/i686-unknown-linux-gnu.mk b/mk/cfg/i686-unknown-linux-gnu.mk index 1cc9c143e8d..88c0907f63b 100644 --- a/mk/cfg/i686-unknown-linux-gnu.mk +++ b/mk/cfg/i686-unknown-linux-gnu.mk @@ -12,15 +12,11 @@ CFG_GCCISH_CFLAGS_i686-unknown-linux-gnu := -Wall -Werror -g -fPIC -m32 $(CFLAGS CFG_GCCISH_CXXFLAGS_i686-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_i686-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m32 CFG_GCCISH_DEF_FLAG_i686-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_i686-unknown-linux-gnu := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_i686-unknown-linux-gnu := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_i686-unknown-linux-gnu := .linux.def CFG_LLC_FLAGS_i686-unknown-linux-gnu := CFG_INSTALL_NAME_i686-unknown-linux-gnu = CFG_EXE_SUFFIX_i686-unknown-linux-gnu = CFG_WINDOWSY_i686-unknown-linux-gnu := CFG_UNIXY_i686-unknown-linux-gnu := 1 -CFG_PATH_MUNGE_i686-unknown-linux-gnu := true CFG_LDPATH_i686-unknown-linux-gnu := CFG_RUN_i686-unknown-linux-gnu=$(2) CFG_RUN_TARG_i686-unknown-linux-gnu=$(call CFG_RUN_i686-unknown-linux-gnu,,$(2)) diff --git a/mk/cfg/mips-unknown-linux-gnu.mk b/mk/cfg/mips-unknown-linux-gnu.mk index c5d84966f85..ba5f6d0e756 100644 --- a/mk/cfg/mips-unknown-linux-gnu.mk +++ b/mk/cfg/mips-unknown-linux-gnu.mk @@ -12,15 +12,11 @@ CFG_GCCISH_CFLAGS_mips-unknown-linux-gnu := -Wall -g -fPIC -mips32r2 -msoft-floa CFG_GCCISH_CXXFLAGS_mips-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_mips-unknown-linux-gnu := -shared -fPIC -g -mips32r2 -msoft-float -mabi=32 CFG_GCCISH_DEF_FLAG_mips-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_mips-unknown-linux-gnu := .linux.def CFG_LLC_FLAGS_mips-unknown-linux-gnu := CFG_INSTALL_NAME_mips-unknown-linux-gnu = CFG_EXE_SUFFIX_mips-unknown-linux-gnu := CFG_WINDOWSY_mips-unknown-linux-gnu := CFG_UNIXY_mips-unknown-linux-gnu := 1 -CFG_PATH_MUNGE_mips-unknown-linux-gnu := true CFG_LDPATH_mips-unknown-linux-gnu := CFG_RUN_mips-unknown-linux-gnu= CFG_RUN_TARG_mips-unknown-linux-gnu= diff --git a/mk/cfg/mipsel-unknown-linux-gnu.mk b/mk/cfg/mipsel-unknown-linux-gnu.mk index eb2f300abff..539038c7434 100644 --- a/mk/cfg/mipsel-unknown-linux-gnu.mk +++ b/mk/cfg/mipsel-unknown-linux-gnu.mk @@ -12,15 +12,11 @@ CFG_GCCISH_CFLAGS_mipsel-unknown-linux-gnu := -Wall -g -fPIC -mips32 -mabi=32 $( CFG_GCCISH_CXXFLAGS_mipsel-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_mipsel-unknown-linux-gnu := -shared -fPIC -g -mips32 CFG_GCCISH_DEF_FLAG_mipsel-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_mipsel-unknown-linux-gnu := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_mipsel-unknown-linux-gnu := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_mipsel-unknown-linux-gnu := .linux.def CFG_LLC_FLAGS_mipsel-unknown-linux-gnu := CFG_INSTALL_NAME_mipsel-unknown-linux-gnu = CFG_EXE_SUFFIX_mipsel-unknown-linux-gnu := CFG_WINDOWSY_mipsel-unknown-linux-gnu := CFG_UNIXY_mipsel-unknown-linux-gnu := 1 -CFG_PATH_MUNGE_mipsel-unknown-linux-gnu := true CFG_LDPATH_mipsel-unknown-linux-gnu := CFG_RUN_mipsel-unknown-linux-gnu= CFG_RUN_TARG_mipsel-unknown-linux-gnu= diff --git a/mk/cfg/powerpc-unknown-linux-gnu.mk b/mk/cfg/powerpc-unknown-linux-gnu.mk index fd37bd663f7..dda957673eb 100644 --- a/mk/cfg/powerpc-unknown-linux-gnu.mk +++ b/mk/cfg/powerpc-unknown-linux-gnu.mk @@ -13,15 +13,11 @@ CFG_GCCISH_CFLAGS_powerpc-unknown-linux-gnu := -Wall -Werror -g -fPIC -m32 $(CFL CFG_GCCISH_CXXFLAGS_powerpc-unknown-linux-gnu := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_powerpc-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m32 CFG_GCCISH_DEF_FLAG_powerpc-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_powerpc-unknown-linux-gnu := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_powerpc-unknown-linux-gnu := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_powerpc-unknown-linux-gnu := .linux.def CFG_LLC_FLAGS_powerpc-unknown-linux-gnu := CFG_INSTALL_NAME_powerpc-unknown-linux-gnu = CFG_EXE_SUFFIX_powerpc-unknown-linux-gnu = CFG_WINDOWSY_powerpc-unknown-linux-gnu := CFG_UNIXY_powerpc-unknown-linux-gnu := 1 -CFG_PATH_MUNGE_powerpc-unknown-linux-gnu := true CFG_LDPATH_powerpc-unknown-linux-gnu := CFG_RUN_powerpc-unknown-linux-gnu=$(2) CFG_RUN_TARG_powerpc-unknown-linux-gnu=$(call CFG_RUN_powerpc-unknown-linux-gnu,,$(2)) diff --git a/mk/cfg/x86_64-apple-darwin.mk b/mk/cfg/x86_64-apple-darwin.mk index dbd67542ab7..4c68d3dcf37 100644 --- a/mk/cfg/x86_64-apple-darwin.mk +++ b/mk/cfg/x86_64-apple-darwin.mk @@ -12,15 +12,11 @@ CFG_GCCISH_CFLAGS_x86_64-apple-darwin := -Wall -Werror -g -fPIC -m64 -arch x86_6 CFG_GCCISH_CXXFLAGS_x86_64-apple-darwin := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_x86_64-apple-darwin := -dynamiclib -pthread -framework CoreServices -m64 CFG_GCCISH_DEF_FLAG_x86_64-apple-darwin := -Wl,-exported_symbols_list, -CFG_GCCISH_PRE_LIB_FLAGS_x86_64-apple-darwin := -CFG_GCCISH_POST_LIB_FLAGS_x86_64-apple-darwin := -CFG_DEF_SUFFIX_x86_64-apple-darwin := .darwin.def CFG_LLC_FLAGS_x86_64-apple-darwin := CFG_INSTALL_NAME_x86_64-apple-darwin = -Wl,-install_name,@rpath/$(1) CFG_EXE_SUFFIX_x86_64-apple-darwin := CFG_WINDOWSY_x86_64-apple-darwin := CFG_UNIXY_x86_64-apple-darwin := 1 -CFG_PATH_MUNGE_x86_64-apple-darwin := true CFG_LDPATH_x86_64-apple-darwin := CFG_RUN_x86_64-apple-darwin=$(2) CFG_RUN_TARG_x86_64-apple-darwin=$(call CFG_RUN_x86_64-apple-darwin,,$(2)) diff --git a/mk/cfg/x86_64-apple-ios.mk b/mk/cfg/x86_64-apple-ios.mk index b3f05a895a4..dd6080fdb0b 100644 --- a/mk/cfg/x86_64-apple-ios.mk +++ b/mk/cfg/x86_64-apple-ios.mk @@ -20,16 +20,12 @@ CFG_GCCISH_CFLAGS_x86_64-apple-ios := -Wall -Werror -fPIC $(CFG_IOSSIM_FLAGS_x86 CFG_GCCISH_CXXFLAGS_x86_64-apple-ios := -fno-rtti $(CFG_IOSSIM_FLAGS_x86_64-apple-ios) -I$(CFG_IOSSIM_SDK_x86_64-apple-ios)/usr/include/c++/4.2.1 CFG_GCCISH_LINK_FLAGS_x86_64-apple-ios := -lpthread -Wl,-no_compact_unwind -m64 -Wl,-syslibroot $(CFG_IOSSIM_SDK_x86_64-apple-ios) CFG_GCCISH_DEF_FLAG_x86_64-apple-ios := -Wl,-exported_symbols_list, -CFG_GCCISH_PRE_LIB_FLAGS_x86_64-apple-ios := -CFG_GCCISH_POST_LIB_FLAGS_x86_64-apple-ios := -CFG_DEF_SUFFIX_x86_64-apple-ios := .darwin.def CFG_LLC_FLAGS_x86_64-apple-ios := CFG_INSTALL_NAME_x86_64-apple-ios = -Wl,-install_name,@rpath/$(1) CFG_LIBUV_LINK_FLAGS_x86_64-apple-ios := CFG_EXE_SUFFIX_x86_64-apple-ios := CFG_WINDOWSY_x86_64-apple-ios := CFG_UNIXY_x86_64-apple-ios := 1 -CFG_PATH_MUNGE_x86_64-apple-ios := true CFG_LDPATH_x86_64-apple-ios := CFG_RUN_x86_64-apple-ios = $(2) CFG_RUN_TARG_x86_64-apple-ios = $(call CFG_RUN_x86_64-apple-ios,,$(2)) diff --git a/mk/cfg/x86_64-pc-windows-gnu.mk b/mk/cfg/x86_64-pc-windows-gnu.mk index e9e5f04ea54..4118ea26c07 100644 --- a/mk/cfg/x86_64-pc-windows-gnu.mk +++ b/mk/cfg/x86_64-pc-windows-gnu.mk @@ -13,15 +13,11 @@ CFG_GCCISH_CFLAGS_x86_64-pc-windows-gnu := -Wall -Werror -g -m64 -D_WIN32_WINNT= CFG_GCCISH_CXXFLAGS_x86_64-pc-windows-gnu := -fno-rtti $(CXXFLAGS) CFG_GCCISH_LINK_FLAGS_x86_64-pc-windows-gnu := -shared -g -m64 CFG_GCCISH_DEF_FLAG_x86_64-pc-windows-gnu := -CFG_GCCISH_PRE_LIB_FLAGS_x86_64-pc-windows-gnu := -CFG_GCCISH_POST_LIB_FLAGS_x86_64-pc-windows-gnu := -CFG_DEF_SUFFIX_x86_64-pc-windows-gnu := .windows.def CFG_LLC_FLAGS_x86_64-pc-windows-gnu := CFG_INSTALL_NAME_x86_64-pc-windows-gnu = CFG_EXE_SUFFIX_x86_64-pc-windows-gnu := .exe CFG_WINDOWSY_x86_64-pc-windows-gnu := 1 CFG_UNIXY_x86_64-pc-windows-gnu := -CFG_PATH_MUNGE_x86_64-pc-windows-gnu := CFG_LDPATH_x86_64-pc-windows-gnu := CFG_RUN_x86_64-pc-windows-gnu=$(2) CFG_RUN_TARG_x86_64-pc-windows-gnu=$(call CFG_RUN_x86_64-pc-windows-gnu,,$(2)) diff --git a/mk/cfg/x86_64-unknown-bitrig.mk b/mk/cfg/x86_64-unknown-bitrig.mk index ad34988cb1b..dd6d19f7491 100644 --- a/mk/cfg/x86_64-unknown-bitrig.mk +++ b/mk/cfg/x86_64-unknown-bitrig.mk @@ -11,15 +11,11 @@ CFG_JEMALLOC_CFLAGS_x86_64-unknown-bitrig := -m64 -I/usr/include $(CFLAGS) CFG_GCCISH_CFLAGS_x86_64-unknown-bitrig := -Wall -Werror -fPIC -m64 -I/usr/include $(CFLAGS) CFG_GCCISH_LINK_FLAGS_x86_64-unknown-bitrig := -shared -pic -pthread -m64 $(LDFLAGS) CFG_GCCISH_DEF_FLAG_x86_64-unknown-bitrig := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-bitrig := -Wl,-pic -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-bitrig := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_x86_64-unknown-bitrig := .bsd.def CFG_LLC_FLAGS_x86_64-unknown-bitrig := CFG_INSTALL_NAME_x86_64-unknown-bitrig = CFG_EXE_SUFFIX_x86_64-unknown-bitrig := CFG_WINDOWSY_x86_64-unknown-bitrig := CFG_UNIXY_x86_64-unknown-bitrig := 1 -CFG_PATH_MUNGE_x86_64-unknown-bitrig := CFG_LDPATH_x86_64-unknown-bitrig := CFG_RUN_x86_64-unknown-bitrig=$(2) CFG_RUN_TARG_x86_64-unknown-bitrig=$(call CFG_RUN_x86_64-unknown-bitrig,,$(2)) diff --git a/mk/cfg/x86_64-unknown-dragonfly.mk b/mk/cfg/x86_64-unknown-dragonfly.mk index 9665b5c7802..4015293826e 100644 --- a/mk/cfg/x86_64-unknown-dragonfly.mk +++ b/mk/cfg/x86_64-unknown-dragonfly.mk @@ -11,15 +11,11 @@ CFG_JEMALLOC_CFLAGS_x86_64-unknown-dragonfly := -m64 -I/usr/include -I/usr/local CFG_GCCISH_CFLAGS_x86_64-unknown-dragonfly := -Wall -Werror -g -fPIC -m64 -I/usr/include -I/usr/local/include $(CFLAGS) CFG_GCCISH_LINK_FLAGS_x86_64-unknown-dragonfly := -shared -fPIC -g -pthread -lrt -m64 CFG_GCCISH_DEF_FLAG_x86_64-unknown-dragonfly := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-dragonfly := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-dragonfly := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_x86_64-unknown-dragonfly := .bsd.def CFG_LLC_FLAGS_x86_64-unknown-dragonfly := CFG_INSTALL_NAME_x86_64-unknown-dragonfly = CFG_EXE_SUFFIX_x86_64-unknown-dragonfly := CFG_WINDOWSY_x86_64-unknown-dragonfly := CFG_UNIXY_x86_64-unknown-dragonfly := 1 -CFG_PATH_MUNGE_x86_64-unknown-dragonfly := CFG_LDPATH_x86_64-unknown-dragonfly := CFG_RUN_x86_64-unknown-dragonfly=$(2) CFG_RUN_TARG_x86_64-unknown-dragonfly=$(call CFG_RUN_x86_64-unknown-dragonfly,,$(2)) diff --git a/mk/cfg/x86_64-unknown-freebsd.mk b/mk/cfg/x86_64-unknown-freebsd.mk index 4e847ea78a7..1bd43168b4f 100644 --- a/mk/cfg/x86_64-unknown-freebsd.mk +++ b/mk/cfg/x86_64-unknown-freebsd.mk @@ -11,15 +11,11 @@ CFG_JEMALLOC_CFLAGS_x86_64-unknown-freebsd := -I/usr/local/include $(CFLAGS) CFG_GCCISH_CFLAGS_x86_64-unknown-freebsd := -Wall -Werror -g -fPIC -I/usr/local/include $(CFLAGS) CFG_GCCISH_LINK_FLAGS_x86_64-unknown-freebsd := -shared -fPIC -g -pthread -lrt CFG_GCCISH_DEF_FLAG_x86_64-unknown-freebsd := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-freebsd := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-freebsd := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_x86_64-unknown-freebsd := .bsd.def CFG_LLC_FLAGS_x86_64-unknown-freebsd := CFG_INSTALL_NAME_x86_64-unknown-freebsd = CFG_EXE_SUFFIX_x86_64-unknown-freebsd := CFG_WINDOWSY_x86_64-unknown-freebsd := CFG_UNIXY_x86_64-unknown-freebsd := 1 -CFG_PATH_MUNGE_x86_64-unknown-freebsd := CFG_LDPATH_x86_64-unknown-freebsd := CFG_RUN_x86_64-unknown-freebsd=$(2) CFG_RUN_TARG_x86_64-unknown-freebsd=$(call CFG_RUN_x86_64-unknown-freebsd,,$(2)) diff --git a/mk/cfg/x86_64-unknown-linux-gnu.mk b/mk/cfg/x86_64-unknown-linux-gnu.mk index e5866094ee8..044c687c9fc 100644 --- a/mk/cfg/x86_64-unknown-linux-gnu.mk +++ b/mk/cfg/x86_64-unknown-linux-gnu.mk @@ -12,15 +12,11 @@ CFG_GCCISH_CFLAGS_x86_64-unknown-linux-gnu := -Wall -Werror -g -fPIC -m64 CFG_GCCISH_CXXFLAGS_x86_64-unknown-linux-gnu := -fno-rtti CFG_GCCISH_LINK_FLAGS_x86_64-unknown-linux-gnu := -shared -fPIC -ldl -pthread -lrt -g -m64 CFG_GCCISH_DEF_FLAG_x86_64-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-linux-gnu := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-linux-gnu := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_x86_64-unknown-linux-gnu := .linux.def CFG_LLC_FLAGS_x86_64-unknown-linux-gnu := CFG_INSTALL_NAME_x86_64-unknown-linux-gnu = CFG_EXE_SUFFIX_x86_64-unknown-linux-gnu = CFG_WINDOWSY_x86_64-unknown-linux-gnu := CFG_UNIXY_x86_64-unknown-linux-gnu := 1 -CFG_PATH_MUNGE_x86_64-unknown-linux-gnu := true CFG_LDPATH_x86_64-unknown-linux-gnu := CFG_RUN_x86_64-unknown-linux-gnu=$(2) CFG_RUN_TARG_x86_64-unknown-linux-gnu=$(call CFG_RUN_x86_64-unknown-linux-gnu,,$(2)) diff --git a/mk/cfg/x86_64-unknown-linux-musl.mk b/mk/cfg/x86_64-unknown-linux-musl.mk new file mode 100644 index 00000000000..b3dea6f97cb --- /dev/null +++ b/mk/cfg/x86_64-unknown-linux-musl.mk @@ -0,0 +1,27 @@ +# x86_64-unknown-linux-musl configuration +CC_x86_64-unknown-linux-musl=$(CFG_MUSL_ROOT)/bin/musl-gcc +CXX_x86_64-unknown-linux-musl=notaprogram +CPP_x86_64-unknown-linux-musl=$(CFG_MUSL_ROOT)/bin/musl-gcc -E +AR_x86_64-unknown-linux-musl=$(AR) +CFG_LIB_NAME_x86_64-unknown-linux-musl=lib$(1).so +CFG_STATIC_LIB_NAME_x86_64-unknown-linux-musl=lib$(1).a +CFG_LIB_GLOB_x86_64-unknown-linux-musl=lib$(1)-*.so +CFG_JEMALLOC_CFLAGS_x86_64-unknown-linux-musl := -m64 +CFG_GCCISH_CFLAGS_x86_64-unknown-linux-musl := -Wall -Werror -g -fPIC -m64 +CFG_GCCISH_CXXFLAGS_x86_64-unknown-linux-musl := +CFG_GCCISH_LINK_FLAGS_x86_64-unknown-linux-musl := +CFG_GCCISH_DEF_FLAG_x86_64-unknown-linux-musl := +CFG_LLC_FLAGS_x86_64-unknown-linux-musl := +CFG_INSTALL_NAME_x86_64-unknown-linux-musl = +CFG_EXE_SUFFIX_x86_64-unknown-linux-musl = +CFG_WINDOWSY_x86_64-unknown-linux-musl := +CFG_UNIXY_x86_64-unknown-linux-musl := 1 +CFG_LDPATH_x86_64-unknown-linux-musl := +CFG_RUN_x86_64-unknown-linux-musl=$(2) +CFG_RUN_TARG_x86_64-unknown-linux-musl=$(call CFG_RUN_x86_64-unknown-linux-musl,,$(2)) +CFG_GNU_TRIPLE_x86_64-unknown-linux-musl := x86_64-unknown-linux-musl + +NATIVE_DEPS_libc_T_x86_64-unknown-linux-musl += libc.a +NATIVE_DEPS_std_T_x86_64-unknown-linux-musl += libunwind.a \ + crt1.o crti.o crtn.o +INSTALLED_OBJECTS_x86_64-unknown-linux-musl += crt1.o crti.o crtn.o diff --git a/mk/cfg/x86_64-unknown-openbsd.mk b/mk/cfg/x86_64-unknown-openbsd.mk index 582d75c3eaf..261616ecf1f 100644 --- a/mk/cfg/x86_64-unknown-openbsd.mk +++ b/mk/cfg/x86_64-unknown-openbsd.mk @@ -11,15 +11,11 @@ CFG_JEMALLOC_CFLAGS_x86_64-unknown-openbsd := -m64 -I/usr/include $(CFLAGS) CFG_GCCISH_CFLAGS_x86_64-unknown-openbsd := -Wall -Werror -g -fPIC -m64 -I/usr/include $(CFLAGS) CFG_GCCISH_LINK_FLAGS_x86_64-unknown-openbsd := -shared -fPIC -g -pthread -m64 CFG_GCCISH_DEF_FLAG_x86_64-unknown-openbsd := -Wl,--export-dynamic,--dynamic-list= -CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-openbsd := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-openbsd := -Wl,-no-whole-archive -CFG_DEF_SUFFIX_x86_64-unknown-openbsd := .bsd.def CFG_LLC_FLAGS_x86_64-unknown-openbsd := CFG_INSTALL_NAME_x86_64-unknown-openbsd = CFG_EXE_SUFFIX_x86_64-unknown-openbsd := CFG_WINDOWSY_x86_64-unknown-openbsd := CFG_UNIXY_x86_64-unknown-openbsd := 1 -CFG_PATH_MUNGE_x86_64-unknown-openbsd := CFG_LDPATH_x86_64-unknown-openbsd := CFG_RUN_x86_64-unknown-openbsd=$(2) CFG_RUN_TARG_x86_64-unknown-openbsd=$(call CFG_RUN_x86_64-unknown-openbsd,,$(2)) diff --git a/mk/crates.mk b/mk/crates.mk index e7c6a716f4c..367c25a8a6d 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -123,6 +123,9 @@ ONLY_RLIB_rustc_bitflags := 1 # Documented-by-default crates DOC_CRATES := std alloc collections core libc rustc_unicode +# Installed objects/libraries by default +INSTALLED_OBJECTS := libmorestack.a libcompiler-rt.a + ################################################################################ # You should not need to edit below this line ################################################################################ diff --git a/mk/main.mk b/mk/main.mk index c1ce1051d0a..9ac96aa90f6 100644 --- a/mk/main.mk +++ b/mk/main.mk @@ -399,8 +399,10 @@ endif # Prerequisites for using the stageN compiler to build target artifacts TSREQ$(1)_T_$(2)_H_$(3) = \ $$(HSREQ$(1)_H_$(3)) \ - $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a \ - $$(TLIB$(1)_T_$(2)_H_$(3))/libcompiler-rt.a + $$(foreach obj,$$(INSTALLED_OBJECTS),\ + $$(TLIB$(1)_T_$(2)_H_$(3))/$$(obj)) \ + $$(foreach obj,$$(INSTALLED_OBJECTS_$(2)),\ + $$(TLIB$(1)_T_$(2)_H_$(3))/$$(obj)) # Prerequisites for a working stageN compiler and libraries, for a specific # target diff --git a/mk/prepare.mk b/mk/prepare.mk index 4ded8a7916b..1382d160e13 100644 --- a/mk/prepare.mk +++ b/mk/prepare.mk @@ -140,8 +140,8 @@ prepare-target-$(2)-host-$(3)-$(1)-$(4): prepare-maybe-clean-$(4) \ $$(if $$(findstring $(2),$$(CFG_HOST)), \ $$(foreach crate,$$(HOST_CRATES), \ $$(call PREPARE_LIB,$$(call CFG_LIB_GLOB_$(2),$$(crate)))),) \ - $$(call PREPARE_LIB,libmorestack.a) \ - $$(call PREPARE_LIB,libcompiler-rt.a),),),) + $$(foreach object,$$(INSTALLED_OBJECTS) $$(INSTALLED_OBJECTS_$(2)),\ + $$(call PREPARE_LIB,$$(object))),),),) endef define INSTALL_GDB_DEBUGGER_SCRIPTS_COMMANDS diff --git a/mk/rt.mk b/mk/rt.mk index 70abce8b460..bd6578d3b72 100644 --- a/mk/rt.mk +++ b/mk/rt.mk @@ -74,7 +74,8 @@ $$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.ll $$(MKFILE_DEPS) \ @mkdir -p $$(@D) @$$(call E, compile: $$@) $$(Q)$$(LLC_$$(CFG_BUILD)) $$(CFG_LLC_FLAGS_$(1)) \ - -filetype=obj -mtriple=$$(CFG_LLVM_TARGET_$(1)) -relocation-model=pic -o $$@ $$< + -filetype=obj -mtriple=$$(CFG_LLVM_TARGET_$(1)) \ + -relocation-model=pic -o $$@ $$< $$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.c $$(MKFILE_DEPS) @mkdir -p $$(@D) @@ -110,6 +111,11 @@ $$(RT_OUTPUT_DIR_$(1))/$$(NATIVE_$(2)_$(1)): $$(OBJS_$(2)_$(1)) @$$(call E, link: $$@) $$(Q)$$(AR_$(1)) rcs $$@ $$^ +ifeq ($$(findstring windows,$(1)),windows) +$$(RT_OUTPUT_DIR_$(1))/lib$(2).a: $$(RT_OUTPUT_DIR_$(1))/$$(NATIVE_$(2)_$(1)) + $$(Q)cp $$^ $$@ +endif + endef $(foreach target,$(CFG_TARGET), \ @@ -221,7 +227,7 @@ COMPRT_DEPS := $(wildcard \ $(S)src/compiler-rt/*/*/*/*) endif -COMPRT_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt) +COMPRT_NAME_$(1) := libcompiler-rt.a COMPRT_LIB_$(1) := $$(RT_OUTPUT_DIR_$(1))/$$(COMPRT_NAME_$(1)) COMPRT_BUILD_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/compiler-rt @@ -312,6 +318,19 @@ endif # endif for windowsy endif # endif for ios endif # endif for darwin +################################################################################ +# libc/libunwind for musl +# +# When we're building a musl-like target we're going to link libc/libunwind +# statically into the standard library and liblibc, so we need to make sure +# they're in a location that we can find +################################################################################ + +ifeq ($$(findstring musl,$(1)),musl) +$$(RT_OUTPUT_DIR_$(1))/%: $$(CFG_MUSL_ROOT)/lib/% + cp $$^ $$@ +endif + endef # Instantiate template for all stages/targets diff --git a/mk/rustllvm.mk b/mk/rustllvm.mk index 44225020811..363022e8781 100644 --- a/mk/rustllvm.mk +++ b/mk/rustllvm.mk @@ -25,8 +25,6 @@ endif RUSTLLVM_OBJS_CS_$(1) := $$(addprefix rustllvm/, \ ExecutionEngineWrapper.cpp RustWrapper.cpp PassWrapper.cpp) -RUSTLLVM_DEF_$(1) := $(1)/rustllvm/rustllvm$(CFG_DEF_SUFFIX_$(1)) - RUSTLLVM_INCS_$(1) = $$(LLVM_EXTRA_INCDIRS_$(1)) \ -iquote $$(LLVM_INCDIR_$(1)) \ -iquote $$(S)src/rustllvm/include diff --git a/mk/target.mk b/mk/target.mk index 8cc74a9cbfb..319f44fd35b 100644 --- a/mk/target.mk +++ b/mk/target.mk @@ -35,7 +35,9 @@ CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4) := \ $$(foreach dep,$$(RUST_DEPS_$(4)), \ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep)) \ $$(foreach dep,$$(NATIVE_DEPS_$(4)), \ - $$(RT_OUTPUT_DIR_$(2))/$$(call CFG_STATIC_LIB_NAME_$(2),$$(dep))) + $$(RT_OUTPUT_DIR_$(2))/$$(call CFG_STATIC_LIB_NAME_$(2),$$(dep))) \ + $$(foreach dep,$$(NATIVE_DEPS_$(4)_T_$(2)), \ + $$(RT_OUTPUT_DIR_$(2))/$$(dep)) endef $(foreach host,$(CFG_HOST), \ @@ -143,14 +145,7 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/: $$(TLIB$(1)_T_$(2)_H_$(3))/: mkdir -p $$@ -$$(TLIB$(1)_T_$(2)_H_$(3))/libcompiler-rt.a: \ - $$(RT_OUTPUT_DIR_$(2))/$$(call CFG_STATIC_LIB_NAME_$(2),compiler-rt) \ - | $$(TLIB$(1)_T_$(2)_H_$(3))/ $$(SNAPSHOT_RUSTC_POST_CLEANUP) - @$$(call E, cp: $$@) - $$(Q)cp $$< $$@ - -$$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a: \ - $$(RT_OUTPUT_DIR_$(2))/$$(call CFG_STATIC_LIB_NAME_$(2),morestack) \ +$$(TLIB$(1)_T_$(2)_H_$(3))/%: $$(RT_OUTPUT_DIR_$(2))/% \ | $$(TLIB$(1)_T_$(2)_H_$(3))/ $$(SNAPSHOT_RUSTC_POST_CLEANUP) @$$(call E, cp: $$@) $$(Q)cp $$< $$@ diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index f5505b6e83a..a648e51497e 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -170,6 +170,9 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool { format!("ignore-{}", config.stage_id.split('-').next().unwrap()) } + fn ignore_env(config: &Config) -> String { + format!("ignore-{}", util::get_env(&config.target).unwrap_or("")) + } fn ignore_gdb(config: &Config, line: &str) -> bool { if config.mode != common::DebugInfoGdb { return false; @@ -231,6 +234,7 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool { !parse_name_directive(ln, &ignore_target(config)) && !parse_name_directive(ln, &ignore_architecture(config)) && !parse_name_directive(ln, &ignore_stage(config)) && + !parse_name_directive(ln, &ignore_env(config)) && !(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) && !(config.target != config.host && parse_name_directive(ln, "ignore-cross-compile")) && !ignore_gdb(config, ln) && diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 3d4aebad9d6..33d4f761eea 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -1233,7 +1233,20 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps, let mut crate_type = if aux_props.no_prefer_dynamic { Vec::new() } else { - vec!("--crate-type=dylib".to_string()) + // We primarily compile all auxiliary libraries as dynamic libraries + // to avoid code size bloat and large binaries as much as possible + // for the test suite (otherwise including libstd statically in all + // executables takes up quite a bit of space). + // + // For targets like MUSL, however, there is no support for dynamic + // libraries so we just go back to building a normal library. Note, + // however, that if the library is built with `force_host` then it's + // ok to be a dylib as the host should always support dylibs. + if config.target.contains("musl") && !aux_props.force_host { + vec!("--crate-type=lib".to_string()) + } else { + vec!("--crate-type=dylib".to_string()) + } }; crate_type.extend(extra_link_args.clone().into_iter()); let aux_args = diff --git a/src/compiletest/util.rs b/src/compiletest/util.rs index a8b26cb3ef7..184d62db451 100644 --- a/src/compiletest/util.rs +++ b/src/compiletest/util.rs @@ -60,6 +60,10 @@ pub fn get_arch(triple: &str) -> &'static str { panic!("Cannot determine Architecture from triple"); } +pub fn get_env(triple: &str) -> Option<&str> { + triple.split('-').nth(3) +} + pub fn make_new_path(path: &str) -> String { assert!(cfg!(windows)); // Windows just uses PATH as the library search path, so we have to diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 9d1d8a7ac24..86a04a0687a 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -211,7 +211,9 @@ mod imp { } // -lpthread needs to occur after -ljemalloc, the earlier argument isn't enough - #[cfg(all(not(windows), not(target_os = "android")))] + #[cfg(all(not(windows), + not(target_os = "android"), + not(target_env = "musl")))] #[link(name = "pthread")] extern {} diff --git a/src/liblibc/lib.rs b/src/liblibc/lib.rs index 4fbcdaa378e..999e7c643e5 100644 --- a/src/liblibc/lib.rs +++ b/src/liblibc/lib.rs @@ -140,11 +140,15 @@ pub use funcs::bsd43::*; // On NaCl, these libraries are static. Thus it would be a Bad Idea to link them // in when creating a test crate. -#[cfg(not(any(windows, all(target_os = "nacl", test))))] +#[cfg(not(any(windows, target_env = "musl", all(target_os = "nacl", test))))] #[link(name = "c")] #[link(name = "m")] extern {} +#[cfg(all(target_env = "musl", not(test)))] +#[link(name = "c", kind = "static")] +extern {} + // libnacl provides functions that require a trip through the IRT to work. // ie: _exit, mmap, nanosleep, etc. Anything that would otherwise require a trip // to the kernel. diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 050ccd64712..072761f2754 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -621,6 +621,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig { let arch = &sess.target.target.arch; let wordsz = &sess.target.target.target_pointer_width; let os = &sess.target.target.target_os; + let env = &sess.target.target.target_env; let fam = match sess.target.target.options.is_like_windows { true => InternedString::new("windows"), @@ -634,8 +635,8 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig { mk(InternedString::new("target_family"), fam), mk(InternedString::new("target_arch"), intern(arch)), mk(InternedString::new("target_endian"), intern(end)), - mk(InternedString::new("target_pointer_width"), - intern(wordsz)) + mk(InternedString::new("target_pointer_width"), intern(wordsz)), + mk(InternedString::new("target_env"), intern(env)), ]; if sess.opts.debug_assertions { ret.push(attr::mk_word_item(InternedString::new("debug_assertions"))); diff --git a/src/librustc_back/target/aarch64_apple_ios.rs b/src/librustc_back/target/aarch64_apple_ios.rs index 2ceb34e68b7..dd6bc672a03 100644 --- a/src/librustc_back/target/aarch64_apple_ios.rs +++ b/src/librustc_back/target/aarch64_apple_ios.rs @@ -22,6 +22,7 @@ pub fn target() -> Target { target_pointer_width: "64".to_string(), arch: "aarch64".to_string(), target_os: "ios".to_string(), + target_env: "".to_string(), options: TargetOptions { features: "+neon,+fp-armv8,+cyclone".to_string(), eliminate_frame_pointer: false, diff --git a/src/librustc_back/target/aarch64_linux_android.rs b/src/librustc_back/target/aarch64_linux_android.rs index 64b0e0cfd6b..fcc901fc81f 100644 --- a/src/librustc_back/target/aarch64_linux_android.rs +++ b/src/librustc_back/target/aarch64_linux_android.rs @@ -24,6 +24,7 @@ pub fn target() -> Target { target_pointer_width: "64".to_string(), arch: "aarch64".to_string(), target_os: "android".to_string(), + target_env: "".to_string(), options: base, } } diff --git a/src/librustc_back/target/aarch64_unknown_linux_gnu.rs b/src/librustc_back/target/aarch64_unknown_linux_gnu.rs index a3ef6372f06..18e67d066d0 100644 --- a/src/librustc_back/target/aarch64_unknown_linux_gnu.rs +++ b/src/librustc_back/target/aarch64_unknown_linux_gnu.rs @@ -19,6 +19,7 @@ pub fn target() -> Target { llvm_target: "aarch64-unknown-linux-gnu".to_string(), target_endian: "little".to_string(), target_pointer_width: "64".to_string(), + target_env: "gnu".to_string(), arch: "aarch64".to_string(), target_os: "linux".to_string(), options: base, diff --git a/src/librustc_back/target/arm_linux_androideabi.rs b/src/librustc_back/target/arm_linux_androideabi.rs index fad93441431..57712d18cba 100644 --- a/src/librustc_back/target/arm_linux_androideabi.rs +++ b/src/librustc_back/target/arm_linux_androideabi.rs @@ -31,6 +31,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "arm".to_string(), target_os: "android".to_string(), + target_env: "gnu".to_string(), options: base, } } diff --git a/src/librustc_back/target/arm_unknown_linux_gnueabi.rs b/src/librustc_back/target/arm_unknown_linux_gnueabi.rs index 32eccaf54b0..30015c4a7e6 100644 --- a/src/librustc_back/target/arm_unknown_linux_gnueabi.rs +++ b/src/librustc_back/target/arm_unknown_linux_gnueabi.rs @@ -23,6 +23,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "arm".to_string(), target_os: "linux".to_string(), + target_env: "gnueabi".to_string(), options: TargetOptions { features: "+v6".to_string(), diff --git a/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs b/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs index eff3601250f..8f8c7114e6e 100644 --- a/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs +++ b/src/librustc_back/target/arm_unknown_linux_gnueabihf.rs @@ -23,6 +23,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "arm".to_string(), target_os: "linux".to_string(), + target_env: "gnueabihf".to_string(), options: TargetOptions { features: "+v6,+vfp2".to_string(), diff --git a/src/librustc_back/target/armv7_apple_ios.rs b/src/librustc_back/target/armv7_apple_ios.rs index 41376421886..3b55993659d 100644 --- a/src/librustc_back/target/armv7_apple_ios.rs +++ b/src/librustc_back/target/armv7_apple_ios.rs @@ -19,6 +19,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "arm".to_string(), target_os: "ios".to_string(), + target_env: "".to_string(), options: TargetOptions { features: "+v7,+vfp3,+neon".to_string(), .. opts(Arch::Armv7) diff --git a/src/librustc_back/target/armv7s_apple_ios.rs b/src/librustc_back/target/armv7s_apple_ios.rs index ef16aefdbd9..5a67e3fe127 100644 --- a/src/librustc_back/target/armv7s_apple_ios.rs +++ b/src/librustc_back/target/armv7s_apple_ios.rs @@ -19,6 +19,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "arm".to_string(), target_os: "ios".to_string(), + target_env: "".to_string(), options: TargetOptions { features: "+v7,+vfp4,+neon".to_string(), .. opts(Arch::Armv7s) diff --git a/src/librustc_back/target/i386_apple_ios.rs b/src/librustc_back/target/i386_apple_ios.rs index afe63d006cf..a9a073e2a8c 100644 --- a/src/librustc_back/target/i386_apple_ios.rs +++ b/src/librustc_back/target/i386_apple_ios.rs @@ -23,6 +23,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "x86".to_string(), target_os: "ios".to_string(), + target_env: "".to_string(), options: opts(Arch::I386) } } diff --git a/src/librustc_back/target/i686_apple_darwin.rs b/src/librustc_back/target/i686_apple_darwin.rs index fcea900283d..47b329982d4 100644 --- a/src/librustc_back/target/i686_apple_darwin.rs +++ b/src/librustc_back/target/i686_apple_darwin.rs @@ -26,6 +26,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "x86".to_string(), target_os: "macos".to_string(), + target_env: "".to_string(), options: base, } } diff --git a/src/librustc_back/target/i686_pc_windows_gnu.rs b/src/librustc_back/target/i686_pc_windows_gnu.rs index 249f2d440e6..9e2aa20085c 100644 --- a/src/librustc_back/target/i686_pc_windows_gnu.rs +++ b/src/librustc_back/target/i686_pc_windows_gnu.rs @@ -30,6 +30,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "x86".to_string(), target_os: "windows".to_string(), + target_env: "gnu".to_string(), options: options, } } diff --git a/src/librustc_back/target/i686_unknown_dragonfly.rs b/src/librustc_back/target/i686_unknown_dragonfly.rs index 4450d8d6778..ecabe71ad4c 100644 --- a/src/librustc_back/target/i686_unknown_dragonfly.rs +++ b/src/librustc_back/target/i686_unknown_dragonfly.rs @@ -22,6 +22,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "x86".to_string(), target_os: "dragonfly".to_string(), + target_env: "".to_string(), options: base, } } diff --git a/src/librustc_back/target/i686_unknown_linux_gnu.rs b/src/librustc_back/target/i686_unknown_linux_gnu.rs index f21f6adfb4c..21094ad905e 100644 --- a/src/librustc_back/target/i686_unknown_linux_gnu.rs +++ b/src/librustc_back/target/i686_unknown_linux_gnu.rs @@ -22,6 +22,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "x86".to_string(), target_os: "linux".to_string(), + target_env: "gnu".to_string(), options: base, } } diff --git a/src/librustc_back/target/linux_base.rs b/src/librustc_back/target/linux_base.rs index d267bc77e49..823a4a81fa4 100644 --- a/src/librustc_back/target/linux_base.rs +++ b/src/librustc_back/target/linux_base.rs @@ -19,12 +19,16 @@ pub fn opts() -> TargetOptions { morestack: true, linker_is_gnu: true, has_rpath: true, - pre_link_args: vec!( - // GNU-style linkers will use this to omit linking to libraries which - // don't actually fulfill any relocations, but only for libraries which - // follow this flag. Thus, use it before specifying libraries to link to. + pre_link_args: vec![ + // We want to be able to strip as much executable code as possible + // from the linker command line, and this flag indicates to the + // linker that it can avoid linking in dynamic libraries that don't + // actually satisfy any symbols up to that point (as with many other + // resolutions the linker does). This option only applies to all + // following libraries so we're sure to pass it as one of the first + // arguments. "-Wl,--as-needed".to_string(), - ), + ], position_independent_executables: true, .. Default::default() } diff --git a/src/librustc_back/target/mips_unknown_linux_gnu.rs b/src/librustc_back/target/mips_unknown_linux_gnu.rs index 8acc248e234..4662ff1958b 100644 --- a/src/librustc_back/target/mips_unknown_linux_gnu.rs +++ b/src/librustc_back/target/mips_unknown_linux_gnu.rs @@ -22,6 +22,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "mips".to_string(), target_os: "linux".to_string(), + target_env: "gnu".to_string(), options: super::linux_base::opts() } } diff --git a/src/librustc_back/target/mipsel_unknown_linux_gnu.rs b/src/librustc_back/target/mipsel_unknown_linux_gnu.rs index 604c62eb69f..80e38c5ddea 100644 --- a/src/librustc_back/target/mipsel_unknown_linux_gnu.rs +++ b/src/librustc_back/target/mipsel_unknown_linux_gnu.rs @@ -22,6 +22,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "mips".to_string(), target_os: "linux".to_string(), + target_env: "gnu".to_string(), options: super::linux_base::opts() } diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 07528df97f1..3a79ae3e7c0 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -59,32 +59,6 @@ mod dragonfly_base; mod bitrig_base; mod openbsd_base; -mod armv7_apple_ios; -mod armv7s_apple_ios; -mod i386_apple_ios; - -mod arm_linux_androideabi; -mod arm_unknown_linux_gnueabi; -mod arm_unknown_linux_gnueabihf; -mod aarch64_apple_ios; -mod aarch64_linux_android; -mod aarch64_unknown_linux_gnu; -mod i686_apple_darwin; -mod i686_pc_windows_gnu; -mod i686_unknown_dragonfly; -mod i686_unknown_linux_gnu; -mod mips_unknown_linux_gnu; -mod mipsel_unknown_linux_gnu; -mod powerpc_unknown_linux_gnu; -mod x86_64_apple_darwin; -mod x86_64_apple_ios; -mod x86_64_pc_windows_gnu; -mod x86_64_unknown_freebsd; -mod x86_64_unknown_dragonfly; -mod x86_64_unknown_bitrig; -mod x86_64_unknown_linux_gnu; -mod x86_64_unknown_openbsd; - /// Everything `rustc` knows about how to compile for a specific target. /// /// Every field here must be specified, and has no default value. @@ -100,6 +74,8 @@ pub struct Target { pub target_pointer_width: String, /// OS name to use for conditional compilation. pub target_os: String, + /// Environment name to use for conditional compilation. + pub target_env: String, /// Architecture to use for ABI considerations. Valid options: "x86", "x86_64", "arm", /// "aarch64", "mips", and "powerpc". "mips" includes "mipsel". pub arch: String, @@ -115,14 +91,22 @@ pub struct Target { pub struct TargetOptions { /// Linker to invoke. Defaults to "cc". pub linker: String, - /// Linker arguments that are unconditionally passed *before* any user-defined libraries. + /// Linker arguments that are unconditionally passed *before* any + /// user-defined libraries. pub pre_link_args: Vec, - /// Linker arguments that are unconditionally passed *after* any user-defined libraries. + /// Linker arguments that are unconditionally passed *after* any + /// user-defined libraries. pub post_link_args: Vec, - /// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults to "default". + /// Objects to link before and after all others, always found within the + /// sysroot folder. + pub pre_link_objects: Vec, + pub post_link_objects: Vec, + /// Default CPU to pass to LLVM. Corresponds to `llc -mcpu=$cpu`. Defaults + /// to "default". pub cpu: String, - /// Default target features to pass to LLVM. These features will *always* be passed, and cannot - /// be disabled even via `-C`. Corresponds to `llc -mattr=$features`. + /// Default target features to pass to LLVM. These features will *always* be + /// passed, and cannot be disabled even via `-C`. Corresponds to `llc + /// -mattr=$features`. pub features: String, /// Whether dynamic linking is available on this target. Defaults to false. pub dynamic_linking: bool, @@ -207,6 +191,8 @@ impl Default for TargetOptions { has_rpath: false, no_compiler_rt: false, position_independent_executables: false, + pre_link_objects: Vec::new(), + post_link_objects: Vec::new(), } } } @@ -250,6 +236,8 @@ impl Target { target_pointer_width: get_req_field("target-pointer-width"), arch: get_req_field("arch"), target_os: get_req_field("os"), + target_env: obj.find("env").and_then(|s| s.as_string()) + .map(|s| s.to_string()).unwrap_or(String::new()), options: Default::default(), }; @@ -329,6 +317,7 @@ impl Target { macro_rules! load_specific { ( $($name:ident),+ ) => ( { + $(mod $name;)* let target = target.replace("-", "_"); if false { } $( @@ -358,6 +347,7 @@ impl Target { arm_unknown_linux_gnueabi, arm_unknown_linux_gnueabihf, aarch64_unknown_linux_gnu, + x86_64_unknown_linux_musl, arm_linux_androideabi, aarch64_linux_android, diff --git a/src/librustc_back/target/powerpc_unknown_linux_gnu.rs b/src/librustc_back/target/powerpc_unknown_linux_gnu.rs index 5e0b7bcf3ef..3a2b4bd1606 100644 --- a/src/librustc_back/target/powerpc_unknown_linux_gnu.rs +++ b/src/librustc_back/target/powerpc_unknown_linux_gnu.rs @@ -21,6 +21,7 @@ pub fn target() -> Target { target_pointer_width: "32".to_string(), arch: "powerpc".to_string(), target_os: "linux".to_string(), + target_env: "gnu".to_string(), options: base, } } diff --git a/src/librustc_back/target/x86_64_apple_darwin.rs b/src/librustc_back/target/x86_64_apple_darwin.rs index 0b3b2bea62d..89a67da2d8b 100644 --- a/src/librustc_back/target/x86_64_apple_darwin.rs +++ b/src/librustc_back/target/x86_64_apple_darwin.rs @@ -25,6 +25,7 @@ pub fn target() -> Target { target_pointer_width: "64".to_string(), arch: "x86_64".to_string(), target_os: "macos".to_string(), + target_env: "".to_string(), options: base, } } diff --git a/src/librustc_back/target/x86_64_apple_ios.rs b/src/librustc_back/target/x86_64_apple_ios.rs index 9df2ccca500..74491629ed8 100644 --- a/src/librustc_back/target/x86_64_apple_ios.rs +++ b/src/librustc_back/target/x86_64_apple_ios.rs @@ -21,6 +21,7 @@ pub fn target() -> Target { target_pointer_width: "64".to_string(), arch: "x86_64".to_string(), target_os: "ios".to_string(), + target_env: "".to_string(), options: opts(Arch::X86_64) } } diff --git a/src/librustc_back/target/x86_64_pc_windows_gnu.rs b/src/librustc_back/target/x86_64_pc_windows_gnu.rs index 6b3054656fe..bea7d16e9df 100644 --- a/src/librustc_back/target/x86_64_pc_windows_gnu.rs +++ b/src/librustc_back/target/x86_64_pc_windows_gnu.rs @@ -27,6 +27,7 @@ pub fn target() -> Target { target_pointer_width: "64".to_string(), arch: "x86_64".to_string(), target_os: "windows".to_string(), + target_env: "gnu".to_string(), options: base, } } diff --git a/src/librustc_back/target/x86_64_unknown_bitrig.rs b/src/librustc_back/target/x86_64_unknown_bitrig.rs index 7b7877c0c69..201c56b2e15 100644 --- a/src/librustc_back/target/x86_64_unknown_bitrig.rs +++ b/src/librustc_back/target/x86_64_unknown_bitrig.rs @@ -23,6 +23,7 @@ pub fn target() -> Target { target_pointer_width: "64".to_string(), arch: "x86_64".to_string(), target_os: "bitrig".to_string(), + target_env: "".to_string(), options: base, } } diff --git a/src/librustc_back/target/x86_64_unknown_dragonfly.rs b/src/librustc_back/target/x86_64_unknown_dragonfly.rs index 676aaecc2fc..c590f0297b9 100644 --- a/src/librustc_back/target/x86_64_unknown_dragonfly.rs +++ b/src/librustc_back/target/x86_64_unknown_dragonfly.rs @@ -24,6 +24,7 @@ pub fn target() -> Target { target_pointer_width: "64".to_string(), arch: "x86_64".to_string(), target_os: "dragonfly".to_string(), + target_env: "".to_string(), options: base, } } diff --git a/src/librustc_back/target/x86_64_unknown_freebsd.rs b/src/librustc_back/target/x86_64_unknown_freebsd.rs index 3275cb07b5a..0d8ea90a2ab 100644 --- a/src/librustc_back/target/x86_64_unknown_freebsd.rs +++ b/src/librustc_back/target/x86_64_unknown_freebsd.rs @@ -24,6 +24,7 @@ pub fn target() -> Target { target_pointer_width: "64".to_string(), arch: "x86_64".to_string(), target_os: "freebsd".to_string(), + target_env: "".to_string(), options: base, } } diff --git a/src/librustc_back/target/x86_64_unknown_linux_gnu.rs b/src/librustc_back/target/x86_64_unknown_linux_gnu.rs index 49c4ad4aea9..ba945afc564 100644 --- a/src/librustc_back/target/x86_64_unknown_linux_gnu.rs +++ b/src/librustc_back/target/x86_64_unknown_linux_gnu.rs @@ -24,6 +24,7 @@ pub fn target() -> Target { target_pointer_width: "64".to_string(), arch: "x86_64".to_string(), target_os: "linux".to_string(), + target_env: "gnu".to_string(), options: base, } } diff --git a/src/librustc_back/target/x86_64_unknown_linux_musl.rs b/src/librustc_back/target/x86_64_unknown_linux_musl.rs new file mode 100644 index 00000000000..3debad2e8f2 --- /dev/null +++ b/src/librustc_back/target/x86_64_unknown_linux_musl.rs @@ -0,0 +1,84 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use target::Target; + +pub fn target() -> Target { + let mut base = super::linux_base::opts(); + base.cpu = "x86-64".to_string(); + base.pre_link_args.push("-m64".to_string()); + + // Make sure that the linker/gcc really don't pull in anything, including + // default objects, libs, etc. + base.pre_link_args.push("-nostdlib".to_string()); + base.pre_link_args.push("-static".to_string()); + + // At least when this was tested, the linker would not add the + // `GNU_EH_FRAME` program header to executables generated, which is required + // when unwinding to locate the unwinding information. I'm not sure why this + // argument is *not* necessary for normal builds, but it can't hurt! + base.pre_link_args.push("-Wl,--eh-frame-hdr".to_string()); + + // There's a whole bunch of circular dependencies when dealing with MUSL + // unfortunately. To put this in perspective libc is statically linked to + // liblibc and libunwind is statically linked to libstd: + // + // * libcore depends on `fmod` which is in libc (transitively in liblibc). + // liblibc, however, depends on libcore. + // * compiler-rt has personality symbols that depend on libunwind, but + // libunwind is in libstd which depends on compiler-rt. + // + // Recall that linkers discard libraries and object files as much as + // possible, and with all the static linking and archives flying around with + // MUSL the linker is super aggressively stripping out objects. For example + // the first case has fmod stripped from liblibc (it's in its own object + // file) so it's not there when libcore needs it. In the second example all + // the unused symbols from libunwind are stripped (each is in its own object + // file in libstd) before we end up linking compiler-rt which depends on + // those symbols. + // + // To deal with these circular dependencies we just force the compiler to + // link everything as a group, not stripping anything out until everything + // is processed. The linker will still perform a pass to strip out object + // files but it won't do so until all objects/archives have been processed. + base.pre_link_args.push("-Wl,-(".to_string()); + base.post_link_args.push("-Wl,-)".to_string()); + + // When generating a statically linked executable there's generally some + // small setup needed which is listed in these files. These are provided by + // a musl toolchain and are linked by default by the `musl-gcc` script. Note + // that `gcc` also does this by default, it just uses some different files. + // + // Each target directory for musl has these object files included in it so + // they'll be included from there. + base.pre_link_objects.push("crt1.o".to_string()); + base.pre_link_objects.push("crti.o".to_string()); + base.post_link_objects.push("crtn.o".to_string()); + + // MUSL support doesn't currently include dynamic linking, so there's no + // need for dylibs or rpath business. Additionally `-pie` is incompatible + // with `-static`, so we can't pass `-pie`. + base.dynamic_linking = false; + base.has_rpath = false; + base.position_independent_executables = false; + + Target { + data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\ + f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\ + s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(), + llvm_target: "x86_64-unknown-linux-musl".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "64".to_string(), + arch: "x86_64".to_string(), + target_os: "linux".to_string(), + target_env: "musl".to_string(), + options: base, + } +} diff --git a/src/librustc_back/target/x86_64_unknown_openbsd.rs b/src/librustc_back/target/x86_64_unknown_openbsd.rs index d2667dcd1dd..7f64259adf9 100644 --- a/src/librustc_back/target/x86_64_unknown_openbsd.rs +++ b/src/librustc_back/target/x86_64_unknown_openbsd.rs @@ -23,6 +23,7 @@ pub fn target() -> Target { target_pointer_width: "64".to_string(), arch: "x86_64".to_string(), target_os: "openbsd".to_string(), + target_env: "".to_string(), options: base, } } diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index b53be98a06c..c72072f0696 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -794,13 +794,21 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool, let pname = get_cc_prog(sess); let mut cmd = Command::new(&pname[..]); + let root = sess.target_filesearch(PathKind::Native).get_lib_path(); cmd.args(&sess.target.target.options.pre_link_args); + for obj in &sess.target.target.options.pre_link_objects { + cmd.arg(root.join(obj)); + } + link_args(&mut cmd, sess, dylib, tmpdir.path(), trans, obj_filename, out_filename); - cmd.args(&sess.target.target.options.post_link_args); if !sess.target.target.options.no_compiler_rt { cmd.arg("-lcompiler-rt"); } + for obj in &sess.target.target.options.post_link_objects { + cmd.arg(root.join(obj)); + } + cmd.args(&sess.target.target.options.post_link_args); if sess.opts.debugging_opts.print_link_args { println!("{:?}", &cmd); diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index ef72cbc96e1..8b90fce6fc4 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -125,7 +125,9 @@ mod tests { use path::Path; #[test] - #[cfg_attr(any(windows, target_os = "android"), ignore)] // FIXME #8818, #10379 + #[cfg_attr(any(windows, + target_os = "android", // FIXME #10379 + target_env = "musl"), ignore)] fn test_loading_cosine() { // The math library does not need to be loaded since it is already // statically linked in diff --git a/src/libstd/rt/libunwind.rs b/src/libstd/rt/libunwind.rs index 4b754bd5f58..8f75ae5ef5c 100644 --- a/src/libstd/rt/libunwind.rs +++ b/src/libstd/rt/libunwind.rs @@ -97,10 +97,15 @@ pub type _Unwind_Exception_Cleanup_Fn = extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception); -#[cfg(any(target_os = "linux", target_os = "freebsd"))] +#[cfg(any(all(target_os = "linux", not(target_env = "musl")), + target_os = "freebsd"))] #[link(name = "gcc_s")] extern {} +#[cfg(all(target_os = "linux", target_env = "musl", not(test)))] +#[link(name = "unwind", kind = "static")] +extern {} + #[cfg(any(target_os = "android", target_os = "openbsd"))] #[link(name = "gcc")] extern {} diff --git a/src/libstd/rtdeps.rs b/src/libstd/rtdeps.rs index 96c4bcec853..a7f3bc2bdc8 100644 --- a/src/libstd/rtdeps.rs +++ b/src/libstd/rtdeps.rs @@ -24,7 +24,7 @@ extern {} // // On Linux, librt and libdl are indirect dependencies via std, // and binutils 2.22+ won't add them automatically -#[cfg(target_os = "linux")] +#[cfg(all(target_os = "linux", not(target_env = "musl")))] #[link(name = "dl")] #[link(name = "pthread")] extern {} diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 281ac37e671..cfab9d1c51a 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -342,7 +342,10 @@ fn min_stack_size(attr: *const libc::pthread_attr_t) -> usize { static mut __pthread_get_minstack: Option = None; INIT.call_once(|| { - let lib = DynamicLibrary::open(None).unwrap(); + let lib = match DynamicLibrary::open(None) { + Ok(l) => l, + Err(..) => return, + }; unsafe { if let Ok(f) = lib.symbol("__pthread_get_minstack") { __pthread_get_minstack = Some(mem::transmute::<*const (), F>(f)); diff --git a/src/libstd/sys/unix/time.rs b/src/libstd/sys/unix/time.rs index d2f51678d49..f59eb2c0301 100644 --- a/src/libstd/sys/unix/time.rs +++ b/src/libstd/sys/unix/time.rs @@ -82,7 +82,8 @@ mod inner { // OpenBSD provide it via libc #[cfg(not(any(target_os = "android", target_os = "bitrig", - target_os = "openbsd")))] + target_os = "openbsd", + target_env = "musl")))] #[link(name = "rt")] extern {} diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index d028a169b64..bb2832b8746 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -356,6 +356,7 @@ mod imp { use sys_common::thread_local as os; extern { + #[linkage = "extern_weak"] static __dso_handle: *mut u8; #[linkage = "extern_weak"] static __cxa_thread_atexit_impl: *const (); diff --git a/src/test/bench/noise.rs b/src/test/bench/noise.rs index efbb5dfb549..81a6fb8ff6d 100644 --- a/src/test/bench/noise.rs +++ b/src/test/bench/noise.rs @@ -101,8 +101,8 @@ impl Noise2DContext { fn main() { let symbols = [' ', '░', '▒', '▓', '█', '█']; - let mut pixels = [0f32; 256*256]; - let n2d = Noise2DContext::new(); + let mut pixels = Box::new([0f32; 256*256]); + let n2d = Box::new(Noise2DContext::new()); for _ in 0..100 { for y in 0..256 { diff --git a/src/test/bench/shootout-reverse-complement.rs b/src/test/bench/shootout-reverse-complement.rs index 7c9f33678a3..55b2b1e2e32 100644 --- a/src/test/bench/shootout-reverse-complement.rs +++ b/src/test/bench/shootout-reverse-complement.rs @@ -50,17 +50,17 @@ use std::ptr::copy; use std::thread; struct Tables { - table8: [u8; 1 << 8], - table16: [u16; 1 << 16] + table8: Box<[u8; 1 << 8]>, + table16: Box<[u16; 1 << 16]>, } impl Tables { fn new() -> Tables { - let mut table8 = [0;1 << 8]; + let mut table8 = Box::new([0;1 << 8]); for (i, v) in table8.iter_mut().enumerate() { *v = Tables::computed_cpl8(i as u8); } - let mut table16 = [0;1 << 16]; + let mut table16 = Box::new([0;1 << 16]); for (i, v) in table16.iter_mut().enumerate() { *v = (table8[i & 255] as u16) << 8 | table8[i >> 8] as u16; diff --git a/src/test/run-pass-fulldeps/issue-13560.rs b/src/test/run-pass-fulldeps/issue-13560.rs index 1541e809b61..fc9f241af7f 100644 --- a/src/test/run-pass-fulldeps/issue-13560.rs +++ b/src/test/run-pass-fulldeps/issue-13560.rs @@ -12,6 +12,7 @@ // aux-build:issue-13560-2.rs // aux-build:issue-13560-3.rs // ignore-stage1 +// ignore-musl // Regression test for issue #13560, the test itself is all in the dependent // libraries. The fail which previously failed to compile is the one numbered 3. diff --git a/src/test/run-pass/issue-12133-3.rs b/src/test/run-pass/issue-12133-3.rs index 79a53078545..66201ff901f 100644 --- a/src/test/run-pass/issue-12133-3.rs +++ b/src/test/run-pass/issue-12133-3.rs @@ -11,6 +11,7 @@ // aux-build:issue-12133-rlib.rs // aux-build:issue-12133-dylib.rs // aux-build:issue-12133-dylib2.rs +// ignore-musl // pretty-expanded FIXME #23616 diff --git a/src/test/run-pass/linkage-visibility.rs b/src/test/run-pass/linkage-visibility.rs index 74da4273b6a..98a7ce55540 100644 --- a/src/test/run-pass/linkage-visibility.rs +++ b/src/test/run-pass/linkage-visibility.rs @@ -11,6 +11,7 @@ // aux-build:linkage-visibility.rs // ignore-android: FIXME(#10379) // ignore-windows: std::dynamic_lib does not work on Windows well +// ignore-musl #![feature(std_misc)] diff --git a/src/test/run-pass/out-of-stack-new-thread-no-split.rs b/src/test/run-pass/out-of-stack-new-thread-no-split.rs index 0d0a5bee8a4..2c6e55b57b0 100644 --- a/src/test/run-pass/out-of-stack-new-thread-no-split.rs +++ b/src/test/run-pass/out-of-stack-new-thread-no-split.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//ignore-android -//ignore-freebsd -//ignore-ios -//ignore-dragonfly -//ignore-bitrig +// ignore-android +// ignore-freebsd +// ignore-ios +// ignore-dragonfly +// ignore-bitrig +// ignore-musl #![feature(asm)] diff --git a/src/test/run-pass/sepcomp-extern.rs b/src/test/run-pass/sepcomp-extern.rs index 973c61712c3..f21b787dab7 100644 --- a/src/test/run-pass/sepcomp-extern.rs +++ b/src/test/run-pass/sepcomp-extern.rs @@ -14,8 +14,8 @@ // Test accessing external items from multiple compilation units. +extern crate sepcomp_extern_lib; -#[link(name = "sepcomp_extern_lib")] extern { #[allow(ctypes)] fn foo() -> usize;