From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Cc: Rich Felker <dalias@libc.org>
Subject: Re: Having hard time adding to CFLAGS
Date: Fri, 23 Oct 2015 01:23:30 +0200 [thread overview]
Message-ID: <20151022232330.GG10551@port70.net> (raw)
In-Reply-To: <CAK1hOcM2Tcdx3RRyYu8X55Ek9CrDZi7YENQs_3xj1mLb6-k2pA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]
* Denys Vlasenko <vda.linux@googlemail.com> [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'
[-- Attachment #2: a.diff --]
[-- Type: text/x-diff, Size: 1393 bytes --]
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
next prev parent reply other threads:[~2015-10-22 23:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-22 22:31 Denys Vlasenko
2015-10-22 23:04 ` Josiah Worcester
2015-10-23 0:13 ` Denys Vlasenko
2015-10-22 23:23 ` Szabolcs Nagy [this message]
2015-10-23 3:02 ` Rich Felker
2015-10-23 4:09 ` Rich Felker
2015-10-23 4:53 ` Denys Vlasenko
2015-10-23 5:16 ` Rich Felker
2015-10-23 6:47 ` Denys Vlasenko
2015-10-24 19:37 ` Rich Felker
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=20151022232330.GG10551@port70.net \
--to=nsz@port70.net \
--cc=dalias@libc.org \
--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).