mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Testing new gcc wrapper script
Date: Wed, 21 Sep 2011 01:14:28 -0400	[thread overview]
Message-ID: <20110921051428.GC132@brightrain.aerifal.cx> (raw)

[-- 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 \

             reply	other threads:[~2011-09-21  5:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-21  5:14 Rich Felker [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110921051428.GC132@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).