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

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

Now updated to use -specs instead of extra wrapping layers with -B in
order to inhibit the default library paths. This version should be
faster, cleaner, and perhaps even more correct than the previous
attempts. I believe some of the other options could also be integrated
into the specs file passed in, and this might make things even cleaner
still.

Please test and let me know if there are problems.

Rich

[-- Attachment #2: my-musl-gcc --]
[-- Type: text/plain, Size: 1162 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##*/}

case "$gccver" in
2.*|3.*|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 ;;
-*) ;;
*) havefile=1 ;;
esac
skip=
done

[ "$havefile" ] || nolink=1

[ "$nolink" ] || {
tmp_specs=$HOME/.specs.tmp.$$
printf '*link_libgcc:\n\n\n' > "$tmp_specs" || exit 1
set -- -specs="$tmp_specs" "$libc_start" "$libc_crt" "$@" "$libc_end" \
  -Wl,--start-group -lc -lgcc -lgcc_eh -Wl,--end-group \
  -Wl,-dynamic-linker,"$ldso_pathname" -Wl,-nostdlib
}

set -- -std=gnu99 -nostdinc -nostdlib $nosp \
  -isystem "$libc_inc" -isystem "$gcc_inc" "$@" \
  -L"$libc_lib" -L"$libgcc"

"$gcc" "$@"

[ "$tmp_specs" ] && rm -f "$tmp_specs"

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

* Re: New gcc wrapper, take 3
  2011-09-21 20:41 New gcc wrapper, take 3 Rich Felker
@ 2011-09-21 21:54 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2011-09-21 21:54 UTC (permalink / raw)
  To: musl

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

On Wed, Sep 21, 2011 at 04:41:04PM -0400, Rich Felker wrote:
> Now updated to use -specs instead of extra wrapping layers with -B in
> order to inhibit the default library paths. This version should be
> faster, cleaner, and perhaps even more correct than the previous
> attempts. I believe some of the other options could also be integrated
> into the specs file passed in, and this might make things even cleaner
> still.
> 
> Please test and let me know if there are problems.

There were problems... stupid handling of removing the temp file.
Try the new version.

Rich

[-- Attachment #2: my-musl-gcc --]
[-- Type: text/plain, Size: 1163 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##*/}

case "$gccver" in
2.*|3.*|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 ;;
-*) ;;
*) havefile=1 ;;
esac
skip=
done

[ "$havefile" ] || nolink=1

[ "$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=/dev/fd/3 "$libc_start" "$libc_crt" "$@" "$libc_end" \
  -Wl,--start-group -lc -lgcc -lgcc_eh -Wl,--end-group \
  -Wl,-dynamic-linker,"$ldso_pathname" -Wl,-nostdlib
}

set -- -std=gnu99 -nostdinc -nostdlib $nosp \
  -isystem "$libc_inc" -isystem "$gcc_inc" "$@" \
  -L"$libc_lib" -L"$libgcc"

exec "$gcc" "$@"

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-21 20:41 New gcc wrapper, take 3 Rich Felker
2011-09-21 21:54 ` 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).