From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8718 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Having hard time adding to CFLAGS Date: Fri, 23 Oct 2015 01:23:30 +0200 Message-ID: <20151022232330.GG10551@port70.net> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="2NLGdgz3UMHa/lqP" X-Trace: ger.gmane.org 1445556228 11669 80.91.229.3 (22 Oct 2015 23:23:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 Oct 2015 23:23:48 +0000 (UTC) Cc: Rich Felker To: musl@lists.openwall.com Original-X-From: musl-return-8731-gllmg-musl=m.gmane.org@lists.openwall.com Fri Oct 23 01:23:48 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 1ZpPCy-0003YO-PY for gllmg-musl@m.gmane.org; Fri, 23 Oct 2015 01:23:44 +0200 Original-Received: (qmail 9394 invoked by uid 550); 22 Oct 2015 23:23:42 -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 9363 invoked from network); 22 Oct 2015 23:23:42 -0000 Mail-Followup-To: musl@lists.openwall.com, Rich Felker Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Xref: news.gmane.org gmane.linux.lib.musl.general:8718 Archived-At: --2NLGdgz3UMHa/lqP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * 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. the attached patch makes this work, but i consider -Os to be not part of 'needed' --2NLGdgz3UMHa/lqP Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="a.diff" 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 OPTIMIZE_SRCS = $(wildcard $(OPTIMIZE_GLOBS:%=src/%)) -$(OPTIMIZE_SRCS:%.c=%.o) $(OPTIMIZE_SRCS:%.c=%.lo): CFLAGS += -O3 +$(OPTIMIZE_SRCS:%.c=%.o) $(OPTIMIZE_SRCS:%.c=%.lo): CFLAGS_ALL += -O3 MEMOPS_SRCS = src/string/memcpy.c src/string/memmove.c src/string/memcmp.c src/string/memset.c -$(MEMOPS_SRCS:%.c=%.o) $(MEMOPS_SRCS:%.c=%.lo): CFLAGS += $(CFLAGS_MEMOPS) +$(MEMOPS_SRCS:%.c=%.o) $(MEMOPS_SRCS:%.c=%.lo): CFLAGS_ALL += $(CFLAGS_MEMOPS) NOSSP_SRCS = $(wildcard crt/*.c) \ src/env/__libc_start_main.c src/env/__init_tls.c \ src/thread/__set_thread_area.c src/env/__stack_chk_fail.c \ src/string/memset.c src/string/memcpy.c \ src/ldso/dlstart.c src/ldso/dynlink.c -$(NOSSP_SRCS:%.c=%.o) $(NOSSP_SRCS:%.c=%.lo): CFLAGS += $(CFLAGS_NOSSP) +$(NOSSP_SRCS:%.c=%.o) $(NOSSP_SRCS:%.c=%.lo): CFLAGS_ALL += $(CFLAGS_NOSSP) -$(CRT_LIBS:lib/%=crt/%): CFLAGS += -DCRT +$(CRT_LIBS:lib/%=crt/%): CFLAGS_ALL += -DCRT # This incantation ensures that changes to any subarch asm files will # force the corresponding object file to be rebuilt, even if the implicit --2NLGdgz3UMHa/lqP--