From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4519 Path: news.gmane.org!not-for-mail From: Chris Anderson Newsgroups: gmane.linux.lib.musl.general Subject: Statically linking musl with lto optimizations Date: Tue, 28 Jan 2014 01:52:46 +0000 Message-ID: <457671390873966@web16j.yandex.ru> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1390873971 24707 80.91.229.3 (28 Jan 2014 01:52:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 28 Jan 2014 01:52:51 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4523-gllmg-musl=m.gmane.org@lists.openwall.com Tue Jan 28 02:53:00 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1W7xrH-0002wY-B8 for gllmg-musl@plane.gmane.org; Tue, 28 Jan 2014 02:52:59 +0100 Original-Received: (qmail 29826 invoked by uid 550); 28 Jan 2014 01:52:57 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 29818 invoked from network); 28 Jan 2014 01:52:57 -0000 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Xref: news.gmane.org gmane.linux.lib.musl.general:4519 Archived-At: Hi I just wanted to know if anyone has tried this and if so with what success? I have tried adding the -flto and -fuse-linker-plugin to my CFLAGS but when I go and link against the static lib/libc.a archive I get a lot of unresolved symbols. I fixed this by changing the makefile thus: 38 AR = $(CROSS_COMPILE)gcc-ar 39 RANLIB = $(CROSS_COMPILE)gcc-ranlib which is described in this thread http://permalink.gmane.org/gmane.comp.gcc.patches/221033 This meant that the archive was being created correctly. The problem that I now have is that if I use If I use ./bin/musl-gcc -flto=5 -fuse-linker-plugin -o test test.c I get a whole lot of unresolved symbols being spewed out by the linker. If I try and link using gcc without gcc libs and but without the musl spec file, ie gcc -flto=5 -fuse-linker-plugin -static -nostdlib all is good apart from an undefined reference to __dynlink. If I add a dummy __dynlink then the whole program links of course it wont execute because the .bss and other segments are not configured. What is the correct way to do this? Cheers Chris