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

Commitf4e8f13

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 parent320534f commitf4e8f13

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

‎configure

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4508,6 +4508,78 @@ else
45084508
fi
45094509
fi
45104510

4511+
# We use C constructs that became invalid in C23. Check if the compiler
4512+
# reports a standard higher than C17, with the flags selected above (so the
4513+
# user can control the language level explicitly to avoid the gcc/clang-only
4514+
# fallback logic below if preferred).
4515+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC reports a C standard higher than ISO C17" >&5
4516+
$as_echo_n "checking whether $CC reports a C standard higher than ISO C17... " >&6; }
4517+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4518+
/* end confdefs.h. */
4519+
4520+
int
4521+
main ()
4522+
{
4523+
#if __STDC_VERSION__ > 201710L
4524+
choke me
4525+
#endif
4526+
;
4527+
return 0;
4528+
}
4529+
_ACEOF
4530+
if ac_fn_c_try_compile "$LINENO"; then :
4531+
POSTC17=no
4532+
else
4533+
POSTC17=yes
4534+
fi
4535+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4536+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${POSTC17}" >&5
4537+
$as_echo "${POSTC17}" >&6; }
4538+
4539+
# If a too recent standard was detected with the user's CFLAGS, try asking for
4540+
# C17 with GNU extensions explicitly.
4541+
if test "$POSTC17" = yes; then
4542+
old_CFLAGS="$CFLAGS"
4543+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -std=gnu17" >&5
4544+
$as_echo_n "checking whether $CC supports -std=gnu17... " >&6; }
4545+
if ${pgac_cv_prog_cc_cflags__std_gnu17+:} false; then :
4546+
$as_echo_n "(cached) " >&6
4547+
else
4548+
pgac_save_CFLAGS=$CFLAGS
4549+
CFLAGS="$pgac_save_CFLAGS -std=gnu17"
4550+
ac_save_c_werror_flag=$ac_c_werror_flag
4551+
ac_c_werror_flag=yes
4552+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4553+
/* end confdefs.h. */
4554+
4555+
int
4556+
main ()
4557+
{
4558+
4559+
;
4560+
return 0;
4561+
}
4562+
_ACEOF
4563+
if ac_fn_c_try_compile "$LINENO"; then :
4564+
pgac_cv_prog_cc_cflags__std_gnu17=yes
4565+
else
4566+
pgac_cv_prog_cc_cflags__std_gnu17=no
4567+
fi
4568+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4569+
ac_c_werror_flag=$ac_save_c_werror_flag
4570+
CFLAGS="$pgac_save_CFLAGS"
4571+
fi
4572+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_cflags__std_gnu17" >&5
4573+
$as_echo "$pgac_cv_prog_cc_cflags__std_gnu17" >&6; }
4574+
if test x"$pgac_cv_prog_cc_cflags__std_gnu17" = x"yes"; then
4575+
CFLAGS="$CFLAGS -std=gnu17"
4576+
fi
4577+
4578+
if test "$CFLAGS" = "$old_CFLAGS"; then
4579+
as_fn_error $? "cannot proceed" "$LINENO" 5
4580+
fi
4581+
fi
4582+
45114583
# CFLAGS we determined above will be added back at the end
45124584
user_CFLAGS=$CFLAGS
45134585
CFLAGS=""

‎configure.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,26 @@ else
434434
fi
435435
fi
436436

437+
# We use C constructs that became invalid in C23. Check if the compiler
438+
# reports a standard higher than C17, with the flags selected above (so the
439+
# user can control the language level explicitly to avoid the gcc/clang-only
440+
# fallback logic below if preferred).
441+
AC_MSG_CHECKING([whether $CC reports a C standard higher than ISO C17])
442+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [@%:@if __STDC_VERSION__ > 201710L
443+
choke me
444+
@%:@endif])], [POSTC17=no], [POSTC17=yes])
445+
AC_MSG_RESULT(${POSTC17})
446+
447+
# If a too recent standard was detected with the user's CFLAGS, try asking for
448+
# C17 with GNU extensions explicitly.
449+
if test "$POSTC17" = yes; then
450+
old_CFLAGS="$CFLAGS"
451+
PGAC_PROG_CC_CFLAGS_OPT([-std=gnu17])
452+
if test "$CFLAGS" = "$old_CFLAGS"; then
453+
AC_MSG_ERROR([cannot proceed])
454+
fi
455+
fi
456+
437457
# CFLAGS we determined above will be added back at the end
438458
user_CFLAGS=$CFLAGS
439459
CFLAGS=""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp