mailing list of musl libc
 help / color / mirror / code / Atom feed
* New gcc wrapper, take 2
@ 2011-09-21 17:37 Rich Felker
  2011-09-21 19:38 ` Isaac Dunham
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Felker @ 2011-09-21 17:37 UTC (permalink / raw)
  To: musl

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

Here's the updated version with reported issues hopefully all fixed. I
have no idea what -V is supposed to do. Since it's not documented
anywhere in the gcc manual, I just check for and disallow it. I'm
guessing it's for some sort of multi-config setup that doesn't make
sense with the wrapper anyway.

Please test and report any new issues found. If all is well, I'm going
to replace the code in git with this new script.

Rich

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

#!/bin/sh

gcc=gcc
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##*/}

[ "x$1" = "x-V" ] && { printf "%s: -V not supported\n" "$0" ; exit 1 ; }

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

if [ -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" \
|| exit 1
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 -fno-stack-protector \
  -isystem "$libc_inc" -isystem "$gcc_inc" "$@"
exit 1
fi

if [ "$havefile" ] ; then
exec "$gcc" -B"$wrap_dir" \
  -std=gnu99 -nostdinc -nostdlib -fno-stack-protector \
  -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 -lgcc_eh -Wl,--end-group \
  -Wl,-dynamic-linker,"$ldso_pathname" -Wl,-nostdlib
exit 1
fi

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

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

* Re: New gcc wrapper, take 2
  2011-09-21 17:37 New gcc wrapper, take 2 Rich Felker
@ 2011-09-21 19:38 ` Isaac Dunham
  0 siblings, 0 replies; 2+ messages in thread
From: Isaac Dunham @ 2011-09-21 19:38 UTC (permalink / raw)
  To: musl

-V specifies the version to execute (ie, gcc -V 4.2.4, or gcc -V 4.5.1, if you have multiple versions installed)
It's described here:
http://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Target-Options.html#Target-Options

> Here's the updated version with reported issues hopefully all fixed. I
> have no idea what -V is supposed to do. Since it's not documented
> anywhere in the gcc manual, I just check for and disallow it. I'm
> guessing it's for some sort of multi-config setup that doesn't make
> sense with the wrapper anyway.
-- 
Isaac Dunham <idunham@lavabit.com>



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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-21 17:37 New gcc wrapper, take 2 Rich Felker
2011-09-21 19:38 ` Isaac Dunham

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