mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: build musl with clang
Date: Thu, 23 Aug 2012 11:23:26 +0200	[thread overview]
Message-ID: <20120823092325.GC10731@port70.net> (raw)
In-Reply-To: <5035E16E.50004@gmail.com>

* agent <agentprog@gmail.com> [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 ld.so

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

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/ld-musl-i386.so.1 $START t.o $END
ld -X -d -e _start -dynamic-linker /lib/ld-musl-i386.so.1 $START t.o $END



  reply	other threads:[~2012-08-23  9:23 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-23  7:53 agent
2012-08-23  9:23 ` Szabolcs Nagy [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120823092325.GC10731@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).