mailing list of musl libc
 help / color / mirror / code / Atom feed
* build musl with clang
@ 2012-08-23  7:53 agent
  2012-08-23  9:23 ` Szabolcs Nagy
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: agent @ 2012-08-23  7:53 UTC (permalink / raw)
  To: musl

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 parameters and 
coding style. but i have some issues compiling a simple hello world 
program against this musl. the code is:

#include <stdio.h>

int main(int argc, char **argv) {
     printf("Hello, World!\n");
     return 0;
}

i have tried to link against musl both dynamically and statically. if i 
compile a program with the default ld-linux.so dynamic linker the 
program runs but fails at the end:

Hello, World!
Inconsistency detected by ld.so: dl-fini.c: 207: _dl_fini: Assertion `ns 
!= 0 || i == nloaded' failed!

if i use musl's ld-musl (as far as i can notice it is just symlink to 
libc.so) i get a segfault. gdb says:

(gdb) r
Starting program: /home/agent/dev/musl/musl-0.9.4_clang/lib/t.out

Program received signal SIGSEGV, Segmentation fault.
0xb7f9d73a in find_sym () from /lib/ld-musl-i386.so.1
(gdb) where
#0  0xb7f9d73a in find_sym () from /lib/ld-musl-i386.so.1

btw, exactly the same things happen when i try it with gcc (4.6.3 from 
ubuntu).

if i compile statically with gcc the program works fine, but with clang 
it even does not compile (i mean link):

/opt/musl-clang/lib/libc.a(vfprintf.o): In function `printf_core':
src/stdio/vfprintf.c:(.text+0x1088): undefined reference to `__udivdi3'
src/stdio/vfprintf.c:(.text+0x10a6): undefined reference to `__umoddi3'
/opt/musl-clang/lib/libc.a(vfprintf.o): In function `fmt_u':
src/stdio/vfprintf.c:(.text+0x1a11): undefined reference to `__udivdi3'
src/stdio/vfprintf.c:(.text+0x1a33): undefined reference to `__umoddi3'
clang: error: linker command failed with exit code 1 (use -v to see 
invocation)

i suppose those functions do not get into libc.a for some reason, but 
they are in libc.so according to readelf.

my clang command lines:
dynamic link:

clang -Wall -nostdlib -nostdinc -Wl,-dynamic-linker 
/lib/ld-musl-i386.so.1 -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

as far as i can see, musl do not provide crtbegin.o and crtend.o, clang 
do not have it's own and if i add gcc's ones situation does not change.

maybe i am wrong with clang parameters (i based them on gcc spec 
provided), maybe it is impossible to compile a working musl with clang 
at this stage, maybe a quick fix can be applied (:

PS: sorry for so long message -- i'd like to be maximum verbose
PPS: and sorry for duplicates if any -- i didn't find any search on 
mainling list archive


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

end of thread, other threads:[~2012-08-29 17:50 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-23  7:53 build musl with clang agent
2012-08-23  9:23 ` Szabolcs Nagy
2012-08-23 10:25   ` agent
2012-08-23 12:24 ` Rich Felker
2012-08-23 13:11   ` agent
2012-08-23 13:56     ` John Spencer
2012-08-23 14:42       ` Szabolcs Nagy
2012-08-23 15:12       ` agent
2012-08-23 17:55     ` Rich Felker
2012-08-24  5:58       ` agent
2012-08-24  6:06         ` Rich Felker
2012-08-24 10:37           ` agent
2012-08-24 11:01             ` Szabolcs Nagy
2012-08-24 12:22               ` agent
2012-08-24 12:35                 ` Rich Felker
2012-08-24 12:39                   ` agent
2012-08-24 14:59                 ` Szabolcs Nagy
2012-08-24 17:51                   ` Rich Felker
2012-08-24 18:55                     ` agent
2012-08-24 19:04                       ` Szabolcs Nagy
2012-08-25  0:09                         ` Rich Felker
2012-08-25  5:57                           ` agent
2012-08-25  8:03                             ` Szabolcs Nagy
2012-08-29 16:21                               ` agent
2012-08-29 16:59                                 ` Rich Felker
2012-08-29 17:50                                   ` agent
2012-08-24 17:37       ` Luca Barbato
2012-08-24 17:52         ` Rich Felker
2012-08-23 12:24 ` John Spencer

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