mailing list of musl libc
 help / color / mirror / code / Atom feed
* Testing new gcc wrapper script
@ 2011-09-21  5:14 Rich Felker
  2011-09-21 10:59 ` Szabolcs Nagy
  0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2011-09-21  5:14 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

The existing gcc wrapper script shipped with musl hasn't been very
robust, and it doesn't work with pre-4.4 gcc. I'm testing a new
version (attached to this email) and I'd like some feedback on how
well it works. Edit the top of the file to choose your installation
location, compiler to run, etc. then invoke it just like before.

Rich

[-- Attachment #2: my-musl-gcc --]
[-- Type: text/plain, Size: 1649 bytes --]

#!/bin/sh

gcc=gcc
libc_name=musl
libc_prefix="/usr/local/musl"
ldso_pathname="/lib/ld-musl-i386.so.1"
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##*/}

collect2="$("$gcc" -print-prog-name=collect2)"
wrap_dir=$HOME/.tmp/gcc_wrapper/$libc_name-$gcctarget-$gccver

if false && [ -x "$wrap_dir/collect2" ] ; then true
else
mkdir -p "$wrap_dir" || exit 1
echo '#!/bin/sh
first=1
for i ; do
[ "$first" ] && { first= ; set -- ; }
case "$i" in
-L/dev/null) nolibs=1 ;;
-L*) [ "$nolibs" ] || set -- "$@" "$i" ;;
*) set -- "$@" "$i" ;;
esac
done
exec "'"$collect2"'" "$@"' > "$wrap_dir/collect2.$$"
chmod 755 "$wrap_dir/collect2.$$"
mv "$wrap_dir/collect2.$$" "$wrap_dir/collect2"
fi

for i ; do
case "$skip$i" in
-I|-L) skip=- ; continue ;;
-[cSE]|-M*) nolink=1 ;;
-*) ;;
*) havefile=1 ;;
esac
skip=
done

if [ "$nolink" ] ; then
exec "$gcc" -std=gnu99 -nostdinc -isystem "$libc_inc" -isystem "$gcc_inc" "$@"
exit 1
fi

if [ "$havefile" ] ; then
exec "$gcc" -B"$wrap_dir" \
  -std=gnu99 -nostdinc -nostdlib \
  -isystem "$libc_inc" -isystem "$gcc_inc" \
  "$libc_start" "$libc_crt" "$@" "$libc_end" \
  -L"$libc_lib" -L"$libgcc" -L/dev/null \
  -Wl,--start-group -lc -lgcc -Wl,--end-group \
  -Wl,-dynamic-linker,"$ldso_pathname" -Wl,-nostdlib
exit 1
fi

exec "$gcc" -std=gnu99 -nostdinc -nostdlib \
  -isystem "$libc_inc" -isystem "$gcc_inc" \
  "$@" \
  -L"$libc_lib" -L"$libgcc" -L/dev/null \

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-09-21 15:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-21  5:14 Testing new gcc wrapper script Rich Felker
2011-09-21 10:59 ` Szabolcs Nagy
2011-09-21 14:02   ` Rich Felker
2011-09-21 15:05     ` Szabolcs Nagy
2011-09-21 15:13       ` Rich Felker

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).