Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59ea17c

Browse files
committed
If a C23 compiler is detected, try asking for C17.
Branches before 16 can't be compiled with a C23 compiler (seedeprecation warnings silenced by commitf9a56e7, and non-back-patchablechanges made in 16 by commit1c27d16). Test __STDC_VERSION__, and ifit's above C17 then try appending -std=gnu17. The test is done with theuser's CFLAGS, so an acceptable language version can also be configuredmanually that way.This is done in branches 15 and older, back to 9.2, per policy ofkeeping them buildable with modern tools.Discussion:https://postgr.es/m/87o72eo9iu.fsf%40gentoo.org
1 parent5c30672 commit59ea17c

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

‎configure

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5258,6 +5258,83 @@ else
52585258
BITCODE_CXXFLAGS="-O2 $BITCODE_CXXFLAGS"
52595259
fi
52605260

5261+
# We use C constructs that became invalid in C23. Check if the compiler
5262+
# reports a standard higher than C17, with the flags selected above (so the
5263+
# user can control the language level explicitly to avoid the gcc/clang-only
5264+
# fallback logic below if preferred).
5265+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC reports a C standard higher than ISO C17" >&5
5266+
$as_echo_n "checking whether $CC reports a C standard higher than ISO C17... " >&6; }
5267+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5268+
/* end confdefs.h. */
5269+
5270+
int
5271+
main ()
5272+
{
5273+
#if __STDC_VERSION__ > 201710L
5274+
choke me
5275+
#endif
5276+
;
5277+
return 0;
5278+
}
5279+
_ACEOF
5280+
if ac_fn_c_try_compile "$LINENO"; then :
5281+
POSTC17=no
5282+
else
5283+
POSTC17=yes
5284+
fi
5285+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5286+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${POSTC17}" >&5
5287+
$as_echo "${POSTC17}" >&6; }
5288+
5289+
# If a too recent standard was detected with the user's CFLAGS, try asking for
5290+
# C17 with GNU extensions explicitly.
5291+
if test "$POSTC17" = yes; then
5292+
old_CFLAGS="$CFLAGS"
5293+
5294+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -std=gnu17, for CFLAGS" >&5
5295+
$as_echo_n "checking whether ${CC} supports -std=gnu17, for CFLAGS... " >&6; }
5296+
if ${pgac_cv_prog_CC_cflags__std_gnu17+:} false; then :
5297+
$as_echo_n "(cached) " >&6
5298+
else
5299+
pgac_save_CFLAGS=$CFLAGS
5300+
pgac_save_CC=$CC
5301+
CC=${CC}
5302+
CFLAGS="${CFLAGS} -std=gnu17"
5303+
ac_save_c_werror_flag=$ac_c_werror_flag
5304+
ac_c_werror_flag=yes
5305+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5306+
/* end confdefs.h. */
5307+
5308+
int
5309+
main ()
5310+
{
5311+
5312+
;
5313+
return 0;
5314+
}
5315+
_ACEOF
5316+
if ac_fn_c_try_compile "$LINENO"; then :
5317+
pgac_cv_prog_CC_cflags__std_gnu17=yes
5318+
else
5319+
pgac_cv_prog_CC_cflags__std_gnu17=no
5320+
fi
5321+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5322+
ac_c_werror_flag=$ac_save_c_werror_flag
5323+
CFLAGS="$pgac_save_CFLAGS"
5324+
CC="$pgac_save_CC"
5325+
fi
5326+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__std_gnu17" >&5
5327+
$as_echo "$pgac_cv_prog_CC_cflags__std_gnu17" >&6; }
5328+
if test x"$pgac_cv_prog_CC_cflags__std_gnu17" = x"yes"; then
5329+
CFLAGS="${CFLAGS} -std=gnu17"
5330+
fi
5331+
5332+
5333+
if test "$CFLAGS" = "$old_CFLAGS"; then
5334+
as_fn_error $? "cannot proceed" "$LINENO" 5
5335+
fi
5336+
fi
5337+
52615338
# C[XX]FLAGS we determined above will be added back at the end
52625339
user_CFLAGS=$CFLAGS
52635340
CFLAGS=""

‎configure.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,26 @@ else
456456
BITCODE_CXXFLAGS="-O2 $BITCODE_CXXFLAGS"
457457
fi
458458

459+
# We use C constructs that became invalid in C23. Check if the compiler
460+
# reports a standard higher than C17, with the flags selected above (so the
461+
# user can control the language level explicitly to avoid the gcc/clang-only
462+
# fallback logic below if preferred).
463+
AC_MSG_CHECKING([whether $CC reports a C standard higher than ISO C17])
464+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@if __STDC_VERSION__ > 201710L
465+
choke me
466+
@%:@endif])], [POSTC17=no], [POSTC17=yes])
467+
AC_MSG_RESULT(${POSTC17})
468+
469+
# If a too recent standard was detected with the user's CFLAGS, try asking for
470+
# C17 with GNU extensions explicitly.
471+
if test "$POSTC17" = yes; then
472+
old_CFLAGS="$CFLAGS"
473+
PGAC_PROG_CC_CFLAGS_OPT([-std=gnu17])
474+
if test "$CFLAGS" = "$old_CFLAGS"; then
475+
AC_MSG_ERROR([cannot proceed])
476+
fi
477+
fi
478+
459479
# C[XX]FLAGS we determined above will be added back at the end
460480
user_CFLAGS=$CFLAGS
461481
CFLAGS=""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp