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

Commit3f302f0

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 parent15a89e2 commit3f302f0

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
@@ -5247,6 +5247,83 @@ else
52475247
BITCODE_CXXFLAGS="-O2 $BITCODE_CXXFLAGS"
52485248
fi
52495249

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

‎configure.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,26 @@ else
452452
BITCODE_CXXFLAGS="-O2 $BITCODE_CXXFLAGS"
453453
fi
454454

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp