Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120516230716.11df4881@newbook>
Date: Wed, 16 May 2012 23:07:16 -0700
From: Isaac Dunham <idunham@...abit.com>
To: musl@...ts.openwall.com
Subject: Re: gcc segfault at src/mman/mlockall.c

On Thu, 17 May 2012 00:04:57 +0200
Szabolcs Nagy <nsz@...t70.net> wrote:

> i'm not sure what is a glibc->musl cross-compiler
Built on glibc, targets musl (similar to musl-gcc, though a strict
cross-compiler is a little more complex)
> i used something like the following to compile with pcc using musl
> libc

> MUSL=/path/to/musl
> PCC=`pcc -v foobar.o 2>&1 |sed -n 's,.*
> \([^ ]*\)/lib/crtbegin.o.*,\1,p'`
> 
> x.o: x.c
> 	pcc $(CFLAGS) -nostdinc -isystem $(MUSL)/include -isystem
> $(PCC)/include -c -o $@ $< x-static1: x.o
> 	ld -X -d -e _start -Bstatic -o $@ $< $(LDFLAGS)
> $(MUSL)/lib/crti.o $(MUSL)/lib/crt1.o \ $(PCC)/lib/crtbegin.o
> $(PCC)/lib/crtend.o $(MUSL)/lib/crtn.o -L$(MUSL)/lib -lc -L$(PCC)/lib
> -lpcc x-static2: x.o pcc -static -nostdlib -o $@ $< $(LDFLAGS)
> $(MUSL)/lib/crti.o $(MUSL)/lib/crt1.o \ $(PCC)/lib/crtbegin.o
> $(PCC)/lib/crtend.o $(MUSL)/lib/crtn.o -L$(MUSL)/lib -lc -L$(PCC)/lib
> -lpcc x-dynamic1: x.o ld -X -d -e _start
> -dynamic-linker /lib/ld-musl-i386.so.1 -o $@ $< $(LDFLAGS)
> $(MUSL)/lib/crti.o $(MUSL)/lib/crt1.o \ $(PCC)/lib/crtbegin.o
> $(PCC)/lib/crtend.o $(MUSL)/lib/crtn.o -L$(MUSL)/lib -lc -L$(PCC)/lib
> -lpcc x-dynamic2: x.o pcc -nostdlib
> -Wl,-dynamic-linker,/lib/ld-musl-i386.so.1 -o $@ $< $(LDFLAGS)
> $(MUSL)/lib/crti.o $(MUSL)/lib/crt1.o \ $(PCC)/lib/crtbegin.o
> $(PCC)/lib/crtend.o $(MUSL)/lib/crtn.o -L$(MUSL)/lib -lc -L$(PCC)/lib
> -lpcc

For static, I can do it about like so (shell):
# Pass 1: headers
pcc $@ -nostdinc -isystem $MUSL/include -isystem $PCC/include
# Pass 2: linking executables
STARTOBJ="$MUSL/lib/crti.o $MUSL/lib/crt1.o $PCC/lib/crtbegin.o"
ENDOBJ="$PCC/lib/crtend.o $MUSL/lib/crtn.o -L$MUSL/lib -lc -L$PCC/lib \
 -lpcc"
pcc -nostdlib -static $STARTOBJ $@ $ENDOBJ

Thanks!
Isaac Dunham

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.