Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 23 Aug 2012 11:23:26 +0200
From: Szabolcs Nagy <>
Subject: Re: build musl with clang

* agent <> [2012-08-23 13:53:18 +0600]:
> i am trying to build musl with clang 3.0 from ubuntu 12.04. musl
> itself builds fairly fine with some notes on unused command line

i've never tried to build musl with clang
but others did so it should work

in config.mak setup LIBCC properly
(it defaults to -lgcc in the Makefile, this is needed for
udiv* symbols provided by the compiler on 32bit archs for
64bit int division)

i recommend using -g in the cflags and ldflags
so you have debug symbols

don't use the system

> my clang command lines:
> dynamic link:
> clang -Wall -nostdlib -nostdinc -Wl,-dynamic-linker
> /lib/ -L/opt/musl-clang/lib -isystem
> /opt/musl-clang/include/ /opt/musl-clang/lib/crt1.o
> /opt/musl-clang/lib/crti.o t.c /opt/musl-clang/lib/crtn.o -o t.out
> -lc
> static link:
> clang -Wall -nostdlib -nostdinc -L/opt/musl-clang/lib -isystem
> /opt/musl-clang/include/ /opt/musl-clang/lib/crt1.o
> /opt/musl-clang/lib/crti.o t.c /opt/musl-clang/lib/crtn.o -o t.out
> -static -lc

you need the LIBCC here as well, otherwise it looks ok

maybe try to link separately with ld
(clang might invoke ld in hideous ways)

# if there is no crtbegin.o,crtend.o then remove them
START="$MUSL/lib/crti.o $MUSL/lib/crt1.o $CLANG/lib/crtbegin.o"
END="$CLANG/lib/crtend.o $MUSL/lib/crtn.o -L$MUSL/lib -lc -L$CLANG/lib -lclang"

# compile:
clang -c t.c -nostdinc -isystem $MUSL/include

# link: either one of the following should work
clang -nostdlib -Wl,-dynamic-linker,/lib/ $START t.o $END
ld -X -d -e _start -dynamic-linker /lib/ $START t.o $END

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.