ALL_TOOLS = tools/musl-gcc
WRAPCC_GCC = gcc
+WRAPCC_CLANG = clang
LDSO_PATHNAME = $(syslibdir)/ld-musl-$(ARCH)$(SUBARCH).so.1
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!@CC@!$(WRAPCC_CLANG)!g' -e 's!@PREFIX@!$(prefix)!g' -e 's!@INCDIR@!$(includedir)!g' -e 's!@LIBDIR@!$(libdir)!g' -e 's!@LDSO@!$(LDSO_PATHNAME)!g' $< > $@
+ chmod +x $@
+
$(DESTDIR)$(bindir)/%: tools/%
$(INSTALL) -D $< $@
static=yes
wrapper=auto
gcc_wrapper=no
+clang_wrapper=no
for arg ; do
case "$arg" in
--enable-visibility|--enable-visibility=yes) visibility=yes ;;
--disable-visibility|--enable-visibility=no) visibility=no ;;
--enable-wrapper|--enable-wrapper=yes) wrapper=detect ;;
---enable-wrapper=all) wrapper=yes ; gcc_wrapper=yes ;;
+--enable-wrapper=all) wrapper=yes ; gcc_wrapper=yes ; clang_wrapper=yes ;;
--enable-wrapper=gcc) wrapper=yes ; gcc_wrapper=yes ;;
+--enable-wrapper=clang) wrapper=yes ; clang_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 ;;
cc_family=unknown
if fnmatch '*gcc\ version*' "$cc_ver" ; then
cc_family=gcc
+elif fnmatch '*clang\ version*' "$cc_ver" ; then
+cc_family=clang
fi
echo "$cc_family"
elif test "$cc_family" = gcc ; then
gcc_wrapper=yes
echo "gcc"
+elif test "$cc_family" = clang ; then
+clang_wrapper=yes
+echo "clang"
else
echo "none"
if test "$wrapper" = detect ; then
tools="$tools tools/musl-gcc"
tool_libs="$tool_libs lib/musl-gcc.specs"
fi
+if test "$clang_wrapper" = yes ; then
+tools="$tools tools/musl-clang tools/ld.musl-clang"
+fi
#
# Find the target architecture
test "x$static" = xno && echo "STATIC_LIBS ="
test "x$shared" = xno && echo "SHARED_LIBS ="
test "x$cc_family" = xgcc && echo 'WRAPCC_GCC = $(CC)'
+test "x$cc_family" = xclang && echo 'WRAPCC_CLANG = $(CC)'
exec 1>&3 3>&-
printf "done\n"
--- /dev/null
+#!/bin/sh
+cc="@CC@"
+libc_lib="@LIBDIR@"
+ldso="@LDSO@"
+cleared=
+shared=
+userlinkdir=
+userlink=
+
+for x ; do
+ test "$cleared" || set -- ; cleared=1
+
+ case "$x" in
+ -L-user-start)
+ userlinkdir=1
+ ;;
+ -L-user-end)
+ userlinkdir=
+ ;;
+ -L*)
+ test "$userlinkdir" && set -- "$@" "$x"
+ ;;
+ -l-user-start)
+ userlink=1
+ ;;
+ -l-user-end)
+ userlink=
+ ;;
+ crtbegin*.o|crtend*.o)
+ set -- "$@" $($cc -print-file-name=$x)
+ ;;
+ -lgcc|-lgcc_eh)
+ file=lib${x#-l}.a
+ set -- "$@" $($cc -print-file-name=$file)
+ ;;
+ -l*)
+ test "$userlink" && set -- "$@" "$x"
+ ;;
+ -shared)
+ shared=1
+ set -- "$@" -shared
+ ;;
+ -sysroot=*|--sysroot=*)
+ ;;
+ *)
+ set -- "$@" "$x"
+ ;;
+ esac
+done
+
+exec $($cc -print-prog-name=ld) -nostdlib "$@" -lc -dynamic-linker "$ldso"