From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12267 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: musl-cross-make: how to build target libraries with -fpic Date: Wed, 20 Dec 2017 21:03:42 -0500 Message-ID: <20171221020342.GX1627@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1513821724 29267 195.159.176.226 (21 Dec 2017 02:02:04 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 21 Dec 2017 02:02:04 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-12283-gllmg-musl=m.gmane.org@lists.openwall.com Thu Dec 21 03:02:00 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eRqBI-00072A-Sa for gllmg-musl@m.gmane.org; Thu, 21 Dec 2017 03:01:57 +0100 Original-Received: (qmail 9691 invoked by uid 550); 21 Dec 2017 02:03:55 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 9673 invoked from network); 21 Dec 2017 02:03:55 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:12267 Archived-At: On Thu, Dec 21, 2017 at 09:51:21AM +1100, Patrick Oppenlander wrote: > Hi, > > what is the the right way to build a toolchain with PIC libraries? > > The best I've come up with is to add > > GCC_CONFIG_FOR_TARGET = CFLAGS_FOR_TARGET="-g -O2 -fpic" > MUSL_CONFIG = CFLAGS="-fpic" > > to my config. But that seems a little over complicated. > > Is there a recommended/better way? Are you specifically trying to get -fpic instead of -fPIC? As far as I know, -fPIC is the default for all of the gcc target libraries anyway; if not all, at least for libgcc (parts of which normally get linked into most shared libraries and thus need to be pic). If you build gcc with --enable-default-pie, musl libc.a will also end up as PIC by default. Aside from that, the above should work, but you should probably be using GCC_CONFIG, not GCC_CONFIG_FOR_TARGET. The latter is intended for the makefiles and your config.mak to automatically build based on $(TARGET) to meet the ABI requirements of the target you specified, and replacing it will definitely break some targets. Rich