gh-100384: Error on `unguarded-availability` in macOS builds (#128155)

Generate a build error on ``unguarded-availability`` in portable macOS builds (i.e. using MACOSX_DEPLOYMENT_TARGET), preventing invalid use of symbols that are not available in older versions of the OS.
This commit is contained in:
Zanie Blue 2024-12-22 13:01:45 -06:00 committed by GitHub
parent f420bdd29f
commit 9d3a8f4949
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 51 additions and 0 deletions

View File

@ -45,6 +45,7 @@ jobs:
brew link --overwrite tcl-tk@8
- name: Configure CPython
run: |
MACOSX_DEPLOYMENT_TARGET=10.15 \
GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \
GDBM_LIBS="-L$(brew --prefix gdbm)/lib -lgdbm" \
./configure \

View File

@ -0,0 +1,2 @@
Error on ``unguarded-availability`` in macOS builds, preventing invalid
use of symbols that are not available in older versions of the OS.

41
configure generated vendored
View File

@ -10406,6 +10406,47 @@ printf %s "checking which compiler should be used... " >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
printf "%s\n" "$CC" >&6; }
# Error on unguarded use of new symbols, which will fail at runtime for
# users on older versions of macOS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wunguarded-availability" >&5
printf %s "checking whether C compiler accepts -Wunguarded-availability... " >&6; }
if test ${ax_cv_check_cflags__Werror__Wunguarded_availability+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -Werror -Wunguarded-availability"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
ax_cv_check_cflags__Werror__Wunguarded_availability=yes
else $as_nop
ax_cv_check_cflags__Werror__Wunguarded_availability=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror__Wunguarded_availability" >&5
printf "%s\n" "$ax_cv_check_cflags__Werror__Wunguarded_availability" >&6; }
if test "x$ax_cv_check_cflags__Werror__Wunguarded_availability" = xyes
then :
as_fn_append CFLAGS_NODIST " -Werror=unguarded-availability"
else $as_nop
:
fi
LIPO_INTEL64_FLAGS=""
if test "${enable_universalsdk}"
then

View File

@ -2603,6 +2603,13 @@ AS_VAR_IF([ac_cv_gcc_compat], [yes], [
esac
AC_MSG_RESULT([$CC])
# Error on unguarded use of new symbols, which will fail at runtime for
# users on older versions of macOS
AX_CHECK_COMPILE_FLAG([-Wunguarded-availability],
[AS_VAR_APPEND([CFLAGS_NODIST], [" -Werror=unguarded-availability"])],
[],
[-Werror])
LIPO_INTEL64_FLAGS=""
if test "${enable_universalsdk}"
then