From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8721 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Having hard time adding to CFLAGS Date: Thu, 22 Oct 2015 23:02:36 -0400 Message-ID: <20151023030236.GB8645@brightrain.aerifal.cx> References: <20151022232330.GG10551@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1445569374 2385 80.91.229.3 (23 Oct 2015 03:02:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Oct 2015 03:02:54 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8734-gllmg-musl=m.gmane.org@lists.openwall.com Fri Oct 23 05:02:54 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZpSd3-0006Jg-MS for gllmg-musl@m.gmane.org; Fri, 23 Oct 2015 05:02:53 +0200 Original-Received: (qmail 5247 invoked by uid 550); 23 Oct 2015 03:02:51 -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 5229 invoked from network); 23 Oct 2015 03:02:50 -0000 Content-Disposition: inline In-Reply-To: <20151022232330.GG10551@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:8721 Archived-At: On Fri, Oct 23, 2015 at 01:23:30AM +0200, Szabolcs Nagy wrote: > * Denys Vlasenko [2015-10-23 00:31:09 +0200]: > > Let's say I need to add a gcc option to my musl build. > > > > configure says: > > ... > > Some influential environment variables: > > CC C compiler command [detected] > > CFLAGS C compiler flags [-Os -pipe ...] > > CROSS_COMPILE prefix for cross compiler and tools [none] > > LIBCC compiler runtime library [detected > > > > So I try this, combining all possible ways of passing CFLAGS > > (past experience is that different projects do it differently). > > > > CFLAGS is in environment, and on both configure and make > > command lines: > > > > export CFLAGS="-falign-functions=1" # for example > > ./configure CFLAGS="$CFLAGS" > > make CFLAGS="$CFLAGS" > > this is not what configure said... > > > Evidently, my CFLAGS replaced needed flags instead of being added at the end. > > > > Can this be fixed? If user needs to use e.g. EXTRA_CFLAGS instead, > > please fix configure --help. > > it can be fixed, but i think 'needed flag' is not > always clear and overriding CFLAGS on the make > commandline is not polite. Agreed. If you pass CFLAGS to configure, there's no reason to override it later. But it also shouldn't break. > the attached patch makes this work, but i > consider -Os to be not part of 'needed' > diff --git a/Makefile b/Makefile > index 844a017..f713286 100644 > --- a/Makefile > +++ b/Makefile > @@ -94,22 +94,22 @@ crt/crt1.o crt/Scrt1.o crt/rcrt1.o src/ldso/dlstart.lo: $(wildcard arch/$(ARCH)/ > > crt/rcrt1.o: src/ldso/dlstart.c > > -crt/Scrt1.o crt/rcrt1.o: CFLAGS += -fPIC > +crt/Scrt1.o crt/rcrt1.o: CFLAGS_ALL += -fPIC This is the correct fix. I was not aware that make variables set from the make command line would take precedence over the target-specific += concatenations. The intent has always been that editing CFLAGS should not break the build (unless you put really inapproriate stuff there, of course). Rich