From: Shiz <hi@shiz.me>
To: musl@lists.openwall.com
Subject: [PATCH 2/2] build: overhaul wrapper script system for multiple wrapper support
Date: Fri, 29 May 2015 18:55:12 +0200 [thread overview]
Message-ID: <1432918512-27823-1-git-send-email-hi@shiz.me> (raw)
In-Reply-To: <1432918126-27741-1-git-send-email-hi@shiz.me>
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
next prev parent reply other threads:[~2015-05-29 16:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-29 16:48 [PATCH 1/2] add musl-clang, a wrapper for system clang installs Shiz
2015-05-29 16:55 ` Shiz [this message]
2015-06-01 3:18 ` [PATCH 2/2] build: overhaul wrapper script system for multiple wrapper support Rich Felker
2015-06-01 14:15 ` Shiz
2015-06-01 14:47 ` Rich Felker
2015-06-01 15:39 ` Shiz
2015-06-01 16:03 ` Rich Felker
2015-05-29 17:03 ` [PATCH 1/2] add musl-clang, a wrapper for system clang installs Rich Felker
2015-05-29 17:11 ` Shiz
2015-05-29 17:13 ` Rich Felker
2015-05-29 17:35 ` Shiz
2015-05-29 18:43 ` [PATCH v2] " Shiz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1432918512-27823-1-git-send-email-hi@shiz.me \
--to=hi@shiz.me \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).