Skip to content

Commit 766ddcd

Browse files
committed
restructure *CFLAGS configuration.
Convert CFLAGS to be a concatenation: CFLAGS := CONFIGURE_CFLAGS SPECIFIED_CFLAGS EXTRA_CFLAGS This ordering makes it possible to override the flags set by the configure script both during and after configuration, with CFLAGS and EXTRA_CFLAGS, respectively. This resolves jemalloc#619.
1 parent 7b53fe9 commit 766ddcd

File tree

3 files changed

+141
-111
lines changed

3 files changed

+141
-111
lines changed

INSTALL

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,17 +306,16 @@ The following environment variables (not a definitive list) impact configure's
306306
behavior:
307307

308308
CFLAGS="?"
309-
Pass these flags to the compiler. You probably shouldn't define this unless
310-
you know what you are doing. (Use EXTRA_CFLAGS instead.)
309+
Pass these flags to the C compiler. Any flags set by the configure script
310+
are prepended, which means explicitly set flags generally take precedence.
311+
Take care when specifying flags such as -Werror, because configure tests may
312+
be affected in undesirable ways.
311313

312314
EXTRA_CFLAGS="?"
313-
Append these flags to CFLAGS. This makes it possible to add flags such as
314-
-Werror, while allowing the configure script to determine what other flags
315-
are appropriate for the specified configuration.
316-
317-
The configure script specifically checks whether an optimization flag (-O*)
318-
is specified in EXTRA_CFLAGS, and refrains from specifying an optimization
319-
level if it finds that one has already been specified.
315+
Append these flags to CFLAGS, without passing them to the compiler during
316+
configuration. This makes it possible to add flags such as -Werror, while
317+
allowing the configure script to determine what other flags are appropriate
318+
for the specified configuration.
320319

321320
CPPFLAGS="?"
322321
Pass these flags to the C preprocessor. Note that CFLAGS is not passed to

Makefile.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ abs_objroot := @abs_objroot@
2424

2525
# Build parameters.
2626
CPPFLAGS := @CPPFLAGS@ -I$(srcroot)include -I$(objroot)include
27+
CONFIGURE_CFLAGS := @CONFIGURE_CFLAGS@
28+
SPECIFIED_CFLAGS := @SPECIFIED_CFLAGS@
2729
EXTRA_CFLAGS := @EXTRA_CFLAGS@
28-
CFLAGS := @CFLAGS@ $(EXTRA_CFLAGS)
30+
CFLAGS := $(strip $(CONFIGURE_CFLAGS) $(SPECIFIED_CFLAGS) $(EXTRA_CFLAGS))
2931
LDFLAGS := @LDFLAGS@
3032
EXTRA_LDFLAGS := @EXTRA_LDFLAGS@
3133
LIBS := @LIBS@

0 commit comments

Comments
 (0)