diff options
author | Shiz <hi@shiz.me> | 2015-06-28 23:08:19 +0200 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2015-07-06 23:34:14 +0000 |
commit | b3cd7d13fe630ba1847326242525298e361018c1 (patch) | |
tree | c9de5727a40240894dfb3fa9c290d8a955f24f21 | |
parent | 2a780aa3050b86d888489361f04220bfb58890a1 (diff) | |
download | musl-b3cd7d13fe630ba1847326242525298e361018c1.tar.gz musl-b3cd7d13fe630ba1847326242525298e361018c1.tar.xz musl-b3cd7d13fe630ba1847326242525298e361018c1.zip |
build: overhaul wrapper script system for multiple wrapper support
this overhauls part of the build system in order to support multiple toolchain wrapper scripts, as opposed to solely the musl-gcc wrapper as before. it thereby replaces --enable-gcc-wrapper with --enable-wrapper=..., which has the options 'auto' (the default, detect whether to use wrappers), 'all' (build and install all wrappers), 'no' (don't build any) and finally the options named after the individual compiler scripts (currently only 'gcc' is available) to build and install only that wrapper. the old --enable-gcc-wrapper is removed from --help, but still available. it also modifies the wrappers to use the C compiler specified to the build system as 'inner' compiler, when applicable. as wrapper detection works by probing this compiler, it may not work with any other.
-rw-r--r-- | Makefile | 4 | ||||
-rwxr-xr-x | configure | 56 |
2 files changed, 39 insertions, 21 deletions
diff --git a/Makefile b/Makefile index 2eb7b308..a1c19284 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,8 @@ TOOL_LIBS = lib/musl-gcc.specs ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS) ALL_TOOLS = tools/musl-gcc +WRAPCC_GCC = gcc + LDSO_PATHNAME = $(syslibdir)/ld-musl-$(ARCH)$(SUBARCH).so.1 -include config.mak @@ -155,7 +157,7 @@ lib/musl-gcc.specs: tools/musl-gcc.specs.sh config.mak sh $< "$(includedir)" "$(libdir)" "$(LDSO_PATHNAME)" > $@ tools/musl-gcc: config.mak - printf '#!/bin/sh\nexec "$${REALGCC:-gcc}" "$$@" -specs "%s/musl-gcc.specs"\n' "$(libdir)" > $@ + printf '#!/bin/sh\nexec "$${REALGCC:-$(WRAPCC_GCC)}" "$$@" -specs "%s/musl-gcc.specs"\n' "$(libdir)" > $@ chmod +x $@ $(DESTDIR)$(bindir)/%: tools/% diff --git a/configure b/configure index 7b29ae40..b6b6f894 100755 --- a/configure +++ b/configure @@ -28,7 +28,7 @@ Optional features: --enable-debug build with debugging information [disabled] --enable-warnings build with recommended warnings flags [disabled] --enable-visibility use global visibility options to optimize PIC [auto] - --enable-gcc-wrapper build musl-gcc toolchain wrapper [auto] + --enable-wrapper=... build given musl toolchain wrapper [auto] --disable-shared inhibit building shared library [enabled] --disable-static inhibit building static library [enabled] @@ -123,6 +123,8 @@ bindir='$(exec_prefix)/bin' libdir='$(prefix)/lib' includedir='$(prefix)/include' syslibdir='/lib' +tools= +tool_libs= target= optimize=auto debug=no @@ -131,6 +133,7 @@ visibility=auto shared=auto static=yes wrapper=auto +gcc_wrapper=no for arg ; do case "$arg" in @@ -154,7 +157,11 @@ case "$arg" in --disable-warnings|--enable-warnings=no) warnings=no ;; --enable-visibility|--enable-visibility=yes) visibility=yes ;; --disable-visibility|--enable-visibility=no) visibility=no ;; ---enable-gcc-wrapper|--enable-gcc-wrapper=yes) wrapper=yes ;; +--enable-wrapper|--enable-wrapper=yes) wrapper=detect ;; +--enable-wrapper=all) wrapper=yes ; gcc_wrapper=yes ;; +--enable-wrapper=gcc) wrapper=yes ; gcc_wrapper=yes ;; +--disable-wrapper|--enable-wrapper=no) wrapper=no ;; +--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=*) ;; --host=*|--target=*) target=${arg#*=} ;; @@ -215,36 +222,44 @@ tryldflag LDFLAGS_TRY -Werror=unknown-warning-option tryldflag LDFLAGS_TRY -Werror=unused-command-line-argument # -# Need to know if the compiler is gcc to decide whether to build the -# musl-gcc wrapper, and for critical bug detection in some gcc versions. +# Need to know if the compiler is gcc or clang to decide which toolchain +# wrappers to build. # -printf "checking whether compiler is gcc... " -if fnmatch '*gcc\ version*' "$(LC_ALL=C $CC -v 2>&1)" ; then -cc_is_gcc=yes -else -cc_is_gcc=no +printf "checking for C compiler family... " +cc_ver="$(LC_ALL=C $CC -v 2>&1)" +cc_family=unknown +if fnmatch '*gcc\ version*' "$cc_ver" ; then +cc_family=gcc fi -echo "$cc_is_gcc" +echo "$cc_family" # -# Only build musl-gcc wrapper if toolchain does not already target musl +# Figure out toolchain wrapper to build # +if test "$wrapper" = auto -o "$wrapper" = detect ; then +printf "checking for toolchain wrapper to build... " +if test "$cc_family" = gcc ; then +gcc_wrapper=yes if test "$wrapper" = auto ; then -printf "checking whether to build musl-gcc wrapper... " -if test "$cc_is_gcc" = yes ; then -wrapper=yes while read line ; do -case "$line" in */ld-musl-*) wrapper=no ;; esac +case "$line" in */ld-musl-*) gcc_wrapper=no ;; esac done <<EOF $($CC -dumpspecs) EOF +fi +test "$gcc_wrapper" = yes && echo "gcc" else -wrapper=no +echo "none" +if test "$wrapper" = detect ; then +fail "$0: could not find an appropriate toolchain wrapper" +fi fi -echo "$wrapper" fi - +if test "$gcc_wrapper" = yes ; then +tools="$tools tools/musl-gcc" +tool_libs="$tool_libs lib/musl-gcc.specs" +fi # # Find the target architecture @@ -580,11 +595,12 @@ LDFLAGS = $LDFLAGS_AUTO $LDFLAGS CROSS_COMPILE = $CROSS_COMPILE LIBCC = $LIBCC OPTIMIZE_GLOBS = $OPTIMIZE_GLOBS +ALL_TOOLS = $tools +TOOL_LIBS = $tool_libs EOF test "x$static" = xno && echo "STATIC_LIBS =" test "x$shared" = xno && echo "SHARED_LIBS =" -test "x$wrapper" = xno && echo "ALL_TOOLS =" -test "x$wrapper" = xno && echo "TOOL_LIBS =" +test "x$cc_family" = xgcc && echo 'WRAPCC_GCC = $(CC)' exec 1>&3 3>&- printf "done\n" |