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

* Re: Testing new gcc wrapper script
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Szabolcs Nagy @ 2011-09-21 10:59 UTC (permalink / raw)
  To: musl

* Rich Felker <dalias@aerifal.cx> [2011-09-21 01:14:28 -0400]:
> 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

./configure might test cc --version which fails with my-musl-gcc
another special option is -V which must come first

if HOME is not set or / then maybe use /tmp instead of $HOME/.tmp

i had to add -fno-stack-protector


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

* Re: Testing new gcc wrapper script
  2011-09-21 10:59 ` Szabolcs Nagy
@ 2011-09-21 14:02   ` Rich Felker
  2011-09-21 15:05     ` Szabolcs Nagy
  0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2011-09-21 14:02 UTC (permalink / raw)
  To: musl

On Wed, Sep 21, 2011 at 12:59:41PM +0200, Szabolcs Nagy wrote:
> * Rich Felker <dalias@aerifal.cx> [2011-09-21 01:14:28 -0400]:
> > 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
> 
> ../configure might test cc --version which fails with my-musl-gcc

This works fine as far as I can tell.

> another special option is -V which must come first

This is broken; I can fix it though.

> if HOME is not set or / then maybe use /tmp instead of $HOME/.tmp

I suppose it's a good idea.

> i had to add -fno-stack-protector

This is a toolchain bug but worth working around anyway.

Rich


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

* Re: Testing new gcc wrapper script
  2011-09-21 14:02   ` Rich Felker
@ 2011-09-21 15:05     ` Szabolcs Nagy
  2011-09-21 15:13       ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Szabolcs Nagy @ 2011-09-21 15:05 UTC (permalink / raw)
  To: musl

* Rich Felker <dalias@aerifal.cx> [2011-09-21 10:02:16 -0400]:

> On Wed, Sep 21, 2011 at 12:59:41PM +0200, Szabolcs Nagy wrote:
> > * Rich Felker <dalias@aerifal.cx> [2011-09-21 01:14:28 -0400]:
> > > 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
> > 
> > ../configure might test cc --version which fails with my-musl-gcc
> 
> This works fine as far as I can tell.
> 

i get
$ ./my-musl-gcc --version
/home/nsz/.tmp/gcc_wrapper/musl-gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3 Copyright (C) 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
mkdir: cannot create directory `/home/nsz/.tmp/gcc_wrapper/musl-gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3\nCopyright (C) 2008 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions.  There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3\nCopyright (C) 2008 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions.  There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.': File name too long

so --version goes to stdout and -print-file-name is discarded when i run
gcc --version -print-file-name=libgcc.a



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

* Re: Testing new gcc wrapper script
  2011-09-21 15:05     ` Szabolcs Nagy
@ 2011-09-21 15:13       ` Rich Felker
  0 siblings, 0 replies; 5+ messages in thread
From: Rich Felker @ 2011-09-21 15:13 UTC (permalink / raw)
  To: musl

On Wed, Sep 21, 2011 at 05:05:33PM +0200, Szabolcs Nagy wrote:
> * Rich Felker <dalias@aerifal.cx> [2011-09-21 10:02:16 -0400]:
> 
> > On Wed, Sep 21, 2011 at 12:59:41PM +0200, Szabolcs Nagy wrote:
> > > * Rich Felker <dalias@aerifal.cx> [2011-09-21 01:14:28 -0400]:
> > > > 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
> > > 
> > > ../configure might test cc --version which fails with my-musl-gcc
> > 
> > This works fine as far as I can tell.
> > 
> 
> i get
> $ ./my-musl-gcc --version
> [...]
> 
> so --version goes to stdout and -print-file-name is discarded when i run
> gcc --version -print-file-name=libgcc.a

I see. Wonder why it didn't happen for me. Anyway I'll fix it. Thanks
for the reports! Hopefully this will be able to go into the next
release...

Rich


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