about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-04-22 14:32:49 -0400
committerRich Felker <dalias@aerifal.cx>2012-04-22 14:32:49 -0400
commit58f430c1e0255c0b28aed1e9bf3d892c18c06631 (patch)
treee36e0e24a68603c42903e142260b37765491bf76 /tools
parent02eb568dedadb3d66c2751aba6bea559370ff32c (diff)
downloadmusl-58f430c1e0255c0b28aed1e9bf3d892c18c06631.tar.gz
musl-58f430c1e0255c0b28aed1e9bf3d892c18c06631.tar.xz
musl-58f430c1e0255c0b28aed1e9bf3d892c18c06631.zip
new gcc wrapper, entirely specfile based
the _concept_ of this wrapper has been tested extensively, but the
integration with the build/install system, and using a persistent
specfile rather than one generated at build-time, have not been
heavily tested and may need minor tweaks.

this approach should be a lot more robust (and easier to improve) than
writing a shell script that's responsible for trying to mimic gcc's
logic about whether it's compiling or linking, building shared libs or
executable files, etc. it's also lighter weight and should result in
mildly faster builds when using the wrapper.
Diffstat (limited to 'tools')
-rw-r--r--tools/gen-musl-gcc.sh60
-rw-r--r--tools/musl-gcc.specs.sh39
2 files changed, 39 insertions, 60 deletions
diff --git a/tools/gen-musl-gcc.sh b/tools/gen-musl-gcc.sh
deleted file mode 100644
index 7b80fda6..00000000
--- a/tools/gen-musl-gcc.sh
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/sh
-
-printf '#!/bin/sh\n\nlibc_prefix="%s"\nldso_pathname="%s"\n' "$1" "$2"
-
-cat <<"EOF"
-gcc=gcc
-libc_lib=$libc_prefix/lib
-libc_inc=$libc_prefix/include
-libc_crt="$libc_lib/crt1.o"
-libc_start="$libc_lib/crti.o"
-libc_end="$libc_lib/crtn.o"
-
-gcc_inc=$libc_inc
-libgcc="$("$gcc" -print-file-name=libgcc.a)"
-libgcc=${libgcc%/libgcc.a}
-
-gccver=${libgcc##*/}
-gcctarget=${libgcc%/*}
-gcctarget=${gcctarget##*/}
-
-case "$gccver" in
-[0123].*|4.[01]*) ;;
-*) nosp=-fno-stack-protector ;;
-esac
-
-[ "x$1" = "x-V" ] && { printf "%s: -V not supported\n" "$0" ; exit 1 ; }
-
-for i ; do
-case "$skip$i" in
--I|-L) skip=--- ; continue ;;
--[cSE]|-M*) nolink=1 ;;
--shared|-nostartfiles|-nostdlib) nocrt=1 ;;
--*) ;;
-*) havefile=1 ;;
-esac
-skip=
-done
-
-[ "$havefile" ] || nolink=1
-
-[ "$nolink" ] && nocrt=1
-
-[ "$nocrt" ] || set -- "$libc_start" "$libc_crt" "$@" "$libc_end" \
-
-[ "$nolink" ] || {
-tmp_specs=$HOME/.specs.tmp.$$
-printf '*link_libgcc:\n\n\n' > "$tmp_specs" || exit 1
-exec 3<"$tmp_specs"
-rm -f "$tmp_specs"
-set -- -specs=/proc/self/fd/3 "$@" \
-  -Wl,--as-needed -Wl,--start-group -lc -lgcc -lgcc_eh -Wl,--end-group \
-  -Wl,-dynamic-linker,"$ldso_pathname" -Wl,-nostdlib
-}
-
-set -- -nostdinc -nostdlib $nosp \
-  -isystem "$libc_inc" -isystem "$gcc_inc" "$@" \
-  -L"$libc_lib" -L"$libgcc"
-
-exec "$gcc" "$@"
-EOF
diff --git a/tools/musl-gcc.specs.sh b/tools/musl-gcc.specs.sh
new file mode 100644
index 00000000..30b2676d
--- /dev/null
+++ b/tools/musl-gcc.specs.sh
@@ -0,0 +1,39 @@
+incdir=$1
+libdir=$2
+ldso=$3
+cat <<EOF
+%rename cpp_options old_cpp_options
+
+*cpp_options:
+-nostdinc -isystem $incdir %(old_cpp_options)
+
+*cc1:
+%(cc1_cpu) -nostdinc -isystem $incdir 
+
+*link_libgcc:
+-L$libdir
+
+*libgcc:
+libgcc.a%s %:if-exists(libgcc_eh.a%s)
+
+*startfile:
+%{!shared: $libdir/crt1.o} $libdir/crti.o %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}
+
+*endfile:
+%{shared|pie:crtendS.o%s;:crtend.o%s} $libdir/crtn.o
+
+%rename link old_link
+
+*link:
+%(old_link) -dynamic-linker $ldso -nostdlib
+
+*esp_link:
+
+
+*esp_options:
+
+
+*esp_cpp_options:
+
+
+EOF