Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 85a2a89

Browse files
committed
Allow CFLAGS from configure's environment to override automatic CFLAGS.
Previously, configure would add any switches that it chose of its own accord to the end of the user-specified CFLAGS string. Since most compilers process these left-to-right, this meant that configure's choices would override the user-specified flags in case of conflicts. We'd rather that worked the other way around, so adjust the logic to put the user's string at the end not the beginning. There does not seem to be a need for a similar behavior change for CPPFLAGS or LDFLAGS: in those, the earlier switches tend to win (think -I or -L behavior) so putting the user's string at the front is fine. Backpatch to 9.4 but not earlier. I'm not planning to run buildfarm member guar on older branches, and it seems a bit risky to change this behavior in long-stable branches.
1 parent fd3d894 commit 85a2a89

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

configure

+11-2
Original file line numberDiff line numberDiff line change
@@ -4386,6 +4386,10 @@ else
43864386
fi
43874387
fi
43884388

4389+
# CFLAGS we determined above will be added back at the end
4390+
user_CFLAGS=$CFLAGS
4391+
CFLAGS=""
4392+
43894393
# set CFLAGS_VECTOR from the environment, if available
43904394
if test "$ac_env_CFLAGS_VECTOR_set" = set; then
43914395
CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
@@ -4397,7 +4401,7 @@ fi
43974401
# but has its own. Also check other compiler-specific flags here.
43984402

43994403
if test "$GCC" = yes -a "$ICC" = no; then
4400-
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith"
4404+
CFLAGS="-Wall -Wmissing-prototypes -Wpointer-arith"
44014405
# These work in some but not all gcc versions
44024406
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wdeclaration-after-statement" >&5
44034407
$as_echo_n "checking whether $CC supports -Wdeclaration-after-statement... " >&6; }
@@ -4904,7 +4908,12 @@ if test "$PORTNAME" = "win32"; then
49044908
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32 -DEXEC_BACKEND"
49054909
fi
49064910

4907-
# Check if the compiler still works with the template settings
4911+
# Now that we're done automatically adding stuff to CFLAGS, put back the
4912+
# user-specified flags (if any) at the end. This lets users override
4913+
# the automatic additions.
4914+
CFLAGS="$CFLAGS $user_CFLAGS"
4915+
4916+
# Check if the compiler still works with the final flag settings
49084917
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler still works" >&5
49094918
$as_echo_n "checking whether the C compiler still works... " >&6; }
49104919
cat confdefs.h - <<_ACEOF >conftest.$ac_ext

configure.in

+11-2
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,10 @@ else
414414
fi
415415
fi
416416

417+
# CFLAGS we determined above will be added back at the end
418+
user_CFLAGS=$CFLAGS
419+
CFLAGS=""
420+
417421
# set CFLAGS_VECTOR from the environment, if available
418422
if test "$ac_env_CFLAGS_VECTOR_set" = set; then
419423
CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
@@ -425,7 +429,7 @@ fi
425429
# but has its own. Also check other compiler-specific flags here.
426430

427431
if test "$GCC" = yes -a "$ICC" = no; then
428-
CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wpointer-arith"
432+
CFLAGS="-Wall -Wmissing-prototypes -Wpointer-arith"
429433
# These work in some but not all gcc versions
430434
PGAC_PROG_CC_CFLAGS_OPT([-Wdeclaration-after-statement])
431435
PGAC_PROG_CC_CFLAGS_OPT([-Wendif-labels])
@@ -488,7 +492,12 @@ if test "$PORTNAME" = "win32"; then
488492
CPPFLAGS="$CPPFLAGS -I$srcdir/src/include/port/win32 -DEXEC_BACKEND"
489493
fi
490494

491-
# Check if the compiler still works with the template settings
495+
# Now that we're done automatically adding stuff to CFLAGS, put back the
496+
# user-specified flags (if any) at the end. This lets users override
497+
# the automatic additions.
498+
CFLAGS="$CFLAGS $user_CFLAGS"
499+
500+
# Check if the compiler still works with the final flag settings
492501
AC_MSG_CHECKING([whether the C compiler still works])
493502
AC_TRY_LINK([], [return 0;],
494503
[AC_MSG_RESULT(yes)],

0 commit comments

Comments
 (0)