[prev in list] [next in list] [prev in thread] [next in thread]
List: musl
Subject: [musl] [PATCH 2/2] build: overhaul wrapper script system for multiple wrapper support
From: Shiz <hi () shiz ! me>
Date: 2015-05-29 16:55:12
Message-ID: 1432918512-27823-1-git-send-email-hi () shiz ! me
[Download RAW message or body]
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 'clang'
and 'gcc' are 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.
---
Makefile | 7 +++++--
configure | 67 +++++++++++++++++++++++++++++++++++++++++++--------------------
2 files changed, 51 insertions(+), 23 deletions(-)
diff --git a/Makefile b/Makefile
index 0537c6a..a5c25a6 100644
--- a/Makefile
+++ b/Makefile
@@ -51,6 +51,9 @@ TOOL_LIBS = lib/musl-gcc.specs
ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS)
ALL_TOOLS = tools/musl-gcc tools/musl-clang tools/ld.musl-clang
+WRAPCC_GCC = gcc
+WRAPCC_CLANG = clang
+
LDSO_PATHNAME = $(syslibdir)/ld-musl-$(ARCH)$(SUBARCH).so.1
-include config.mak
@@ -153,11 +156,11 @@ 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 $@
tools/%-clang: tools/%-clang.in config.mak
- sed -e 's!@INCDIR@!$(includedir)!g' -e 's!@LIBDIR@!$(libdir)!g' -e \
's!@LDSO@!$(LDSO_PATHNAME)!g' $< > $@ + sed -e 's!@CC@!$(WRAPCC_CLANG)!g' -e \
's!@INCDIR@!$(includedir)!g' -e 's!@LIBDIR@!$(libdir)!g' -e \
's!@LDSO@!$(LDSO_PATHNAME)!g' $< > $@ chmod +x $@
$(DESTDIR)$(bindir)/%: tools/%
diff --git a/configure b/configure
index 7b29ae4..a5296e6 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]
@@ -130,7 +130,8 @@ warnings=no
visibility=auto
shared=auto
static=yes
-wrapper=auto
+gcc_wrapper=auto
+clang_wrapper=auto
for arg ; do
case "$arg" in
@@ -154,8 +155,13 @@ 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 ;;
---disable-gcc-wrapper|--enable-gcc-wrapper=no) wrapper=no ;;
+--enable-wrapper|--enable-wrapper=yes) gcc_wrapper=auto ; clang_wrapper=auto ;;
+--enable-wrapper=all) gcc_wrapper=yes ; clang_wrapper=yes ;;
+--enable-wrapper=clang) gcc_wrapper=no ; clang_wrapper=yes ;;
+--enable-wrapper=gcc) gcc_wrapper=yes ; clang_wrapper=no ;;
+--disable-wrapper|--enable-wrapper=no) gcc_wrapper=no ; clang_wrapper=no ;;
+--enable-gcc-wrapper|--enable-gcc-wrapper=yes) gcc_wrapper=yes ;;
+--disable-gcc-wrapper|--enable-gcc-wrapper=no) gcc_wrapper=no ;;
--enable-*|--disable-*|--with-*|--without-*|--*dir=*|--build=*) ;;
--host=*|--target=*) target=${arg#*=} ;;
-* ) echo "$0: unknown option $arg" ;;
@@ -215,35 +221,47 @@ 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
+if fnmatch '*clang\ version*' "$cc_ver" ; then
+cc_family=clang
fi
-echo "$cc_is_gcc"
+echo "$cc_family"
#
-# Only build musl-gcc wrapper if toolchain does not already target musl
+# Only build wrapper if toolchain does not already target musl
#
-if test "$wrapper" = auto ; then
+if test "$gcc_wrapper" = auto ; then
printf "checking whether to build musl-gcc wrapper... "
-if test "$cc_is_gcc" = yes ; then
-wrapper=yes
+if test "$cc_family" = gcc ; then
+gcc_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
else
-wrapper=no
+gcc_wrapper=no
fi
-echo "$wrapper"
+echo "$gcc_wrapper"
fi
+if test "$clang_wrapper" = auto ; then
+printf "checking whether to build musl-clang wrapper... "
+if test "$cc_family" = clang ; then
+clang_wrapper=yes
+else
+clang_wrapper=no
+fi
+echo "$clang_wrapper"
+fi
#
@@ -583,8 +601,15 @@ OPTIMIZE_GLOBS = $OPTIMIZE_GLOBS
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$gcc_wrapper" = xyes -a "x$cc_family" = xgcc && echo 'WRAPCC_GCC = $(CC)'
+test "x$clang_wrapper" = xyes -a "x$cc_family" = xclang && echo 'WRAPCC_CLANG = \
$(CC)' +printf "ALL_TOOLS ="
+test "x$gcc_wrapper" = xyes && printf " tools/musl-gcc"
+test "x$clang_wrapper" = xyes && printf " tools/musl-clang tools/ld.musl-clang"
+echo
+printf "TOOL_LIBS ="
+test "x$gcc_wrapper" = xyes && printf " lib/musl-gcc.specs"
+echo
exec 1>&3 3>&-
printf "done\n"
--
2.3.6
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic