From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7824 Path: news.gmane.org!not-for-mail From: Shiz Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH 2/2] build: overhaul wrapper script system for multiple wrapper support Date: Fri, 29 May 2015 18:55:12 +0200 Message-ID: <1432918512-27823-1-git-send-email-hi@shiz.me> References: <1432918126-27741-1-git-send-email-hi@shiz.me> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1432918564 5859 80.91.229.3 (29 May 2015 16:56:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 29 May 2015 16:56:04 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7836-gllmg-musl=m.gmane.org@lists.openwall.com Fri May 29 18:56:04 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YyNZW-0003B1-3X for gllmg-musl@m.gmane.org; Fri, 29 May 2015 18:55:50 +0200 Original-Received: (qmail 23814 invoked by uid 550); 29 May 2015 16:55:48 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 23765 invoked from network); 29 May 2015 16:55:41 -0000 X-Virus-Scanned: amavisd-new at shiz.me X-Mailer: git-send-email 2.4.1 In-Reply-To: <1432918126-27741-1-git-send-email-hi@shiz.me> Xref: news.gmane.org gmane.linux.lib.musl.general:7824 Archived-At: 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 <&3 3>&- printf "done\n" -- 2.3.6