From 6fd31842e3d3ce046fcb4625f93a782ac2f6ade9 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Fri, 20 Dec 2024 12:43:06 -0600 Subject: [PATCH 1/6] Error on `unguarded-availability-new` in Darwin builds --- ...-12-21-09-56-37.gh-issue-100384.Ib-XrN.rst | 2 + configure | 41 +++++++++++++++++++ configure.ac | 7 ++++ 3 files changed, 50 insertions(+) create mode 100644 Misc/NEWS.d/next/Build/2024-12-21-09-56-37.gh-issue-100384.Ib-XrN.rst diff --git a/Misc/NEWS.d/next/Build/2024-12-21-09-56-37.gh-issue-100384.Ib-XrN.rst b/Misc/NEWS.d/next/Build/2024-12-21-09-56-37.gh-issue-100384.Ib-XrN.rst new file mode 100644 index 00000000000000..2c800d33b356b8 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2024-12-21-09-56-37.gh-issue-100384.Ib-XrN.rst @@ -0,0 +1,2 @@ +Error on ``unguarded-availability-new`` in Darwin builds, preventing invalid +use of symbols that are not available in older versions of the OS. diff --git a/configure b/configure index e59c7046305d46..74f741ee719884 100755 --- a/configure +++ b/configure @@ -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-new" >&5 +printf %s "checking whether C compiler accepts -Wunguarded-availability-new... " >&6; } +if test ${ax_cv_check_cflags__Werror__Wunguarded_availability_new+y} +then : + printf %s "(cached) " >&6 +else $as_nop + + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror -Wunguarded-availability-new" + 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_new=yes +else $as_nop + ax_cv_check_cflags__Werror__Wunguarded_availability_new=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_new" >&5 +printf "%s\n" "$ax_cv_check_cflags__Werror__Wunguarded_availability_new" >&6; } +if test "x$ax_cv_check_cflags__Werror__Wunguarded_availability_new" = xyes +then : + as_fn_append CFLAGS_NODIST " -Werror=unguarded-availability-new" +else $as_nop + : +fi + + LIPO_INTEL64_FLAGS="" if test "${enable_universalsdk}" then diff --git a/configure.ac b/configure.ac index 074e2ce3dd3024..2a3518ed8e310d 100644 --- a/configure.ac +++ b/configure.ac @@ -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-new], + [AS_VAR_APPEND([CFLAGS_NODIST], [" -Werror=unguarded-availability-new"])], + [], + [-Werror]) + LIPO_INTEL64_FLAGS="" if test "${enable_universalsdk}" then From 0f4b63ee53194eec9422dd4897fd72eae5a5c85b Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sat, 21 Dec 2024 10:37:07 -0600 Subject: [PATCH 2/6] Set `MACOSX_DEPLOYMENT_TARGET=10.9` in CI --- .github/workflows/reusable-macos.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/reusable-macos.yml b/.github/workflows/reusable-macos.yml index 6fa389b2d66e5e..cba8e9885755b6 100644 --- a/.github/workflows/reusable-macos.yml +++ b/.github/workflows/reusable-macos.yml @@ -45,6 +45,7 @@ jobs: brew link --overwrite tcl-tk@8 - name: Configure CPython run: | + MACOSX_DEPLOYMENT_TARGET=10.9 \ GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \ GDBM_LIBS="-L$(brew --prefix gdbm)/lib -lgdbm" \ ./configure \ From 2ddda3a36dff171170a7b7adfa5b5264fe05a4d3 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sun, 22 Dec 2024 10:48:13 -0600 Subject: [PATCH 3/6] Use `-Werror=unguarded-availability` instead of `unguarded-availability-new` --- configure | 20 ++++++++++---------- configure.ac | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/configure b/configure index 74f741ee719884..a697bc1f87b012 100755 --- a/configure +++ b/configure @@ -10408,15 +10408,15 @@ 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-new" >&5 -printf %s "checking whether C compiler accepts -Wunguarded-availability-new... " >&6; } -if test ${ax_cv_check_cflags__Werror__Wunguarded_availability_new+y} + { 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-new" + CFLAGS="$CFLAGS -Werror -Wunguarded-availability" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -10430,18 +10430,18 @@ main (void) _ACEOF if ac_fn_c_try_compile "$LINENO" then : - ax_cv_check_cflags__Werror__Wunguarded_availability_new=yes + ax_cv_check_cflags__Werror__Wunguarded_availability=yes else $as_nop - ax_cv_check_cflags__Werror__Wunguarded_availability_new=no + 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_new" >&5 -printf "%s\n" "$ax_cv_check_cflags__Werror__Wunguarded_availability_new" >&6; } -if test "x$ax_cv_check_cflags__Werror__Wunguarded_availability_new" = xyes +{ 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-new" + as_fn_append CFLAGS_NODIST " -Werror=unguarded-availability" else $as_nop : fi diff --git a/configure.ac b/configure.ac index 2a3518ed8e310d..ebc15503f069cc 100644 --- a/configure.ac +++ b/configure.ac @@ -2605,8 +2605,8 @@ AS_VAR_IF([ac_cv_gcc_compat], [yes], [ # 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-new], - [AS_VAR_APPEND([CFLAGS_NODIST], [" -Werror=unguarded-availability-new"])], + AX_CHECK_COMPILE_FLAG([-Wunguarded-availability], + [AS_VAR_APPEND([CFLAGS_NODIST], [" -Werror=unguarded-availability"])], [], [-Werror]) From 24ee4a778b9b0c1640c0c885e672b588c67eba6f Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sun, 22 Dec 2024 10:48:51 -0600 Subject: [PATCH 4/6] Bump macOS deployment target to 10.13 in CI --- .github/workflows/reusable-macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-macos.yml b/.github/workflows/reusable-macos.yml index cba8e9885755b6..a46ed472ab19b3 100644 --- a/.github/workflows/reusable-macos.yml +++ b/.github/workflows/reusable-macos.yml @@ -45,7 +45,7 @@ jobs: brew link --overwrite tcl-tk@8 - name: Configure CPython run: | - MACOSX_DEPLOYMENT_TARGET=10.9 \ + MACOSX_DEPLOYMENT_TARGET=10.13 \ GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \ GDBM_LIBS="-L$(brew --prefix gdbm)/lib -lgdbm" \ ./configure \ From 88ea2230ab90a20a2ee8f98f0d47df97f845632e Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sun, 22 Dec 2024 11:00:32 -0600 Subject: [PATCH 5/6] Update news blurb --- .../next/Build/2024-12-21-09-56-37.gh-issue-100384.Ib-XrN.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Build/2024-12-21-09-56-37.gh-issue-100384.Ib-XrN.rst b/Misc/NEWS.d/next/Build/2024-12-21-09-56-37.gh-issue-100384.Ib-XrN.rst index 2c800d33b356b8..75c19fe3d8cef9 100644 --- a/Misc/NEWS.d/next/Build/2024-12-21-09-56-37.gh-issue-100384.Ib-XrN.rst +++ b/Misc/NEWS.d/next/Build/2024-12-21-09-56-37.gh-issue-100384.Ib-XrN.rst @@ -1,2 +1,2 @@ -Error on ``unguarded-availability-new`` in Darwin builds, preventing invalid +Error on ``unguarded-availability`` in macOS builds, preventing invalid use of symbols that are not available in older versions of the OS. From dcbd9a6e7712524a7199557da447527e06fe5a81 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Sun, 22 Dec 2024 11:52:32 -0600 Subject: [PATCH 6/6] Bump `MACOSX_DEPLOYMENT_TARGET` to 10.15 --- .github/workflows/reusable-macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-macos.yml b/.github/workflows/reusable-macos.yml index a46ed472ab19b3..cdbe05e09fb8e7 100644 --- a/.github/workflows/reusable-macos.yml +++ b/.github/workflows/reusable-macos.yml @@ -45,7 +45,7 @@ jobs: brew link --overwrite tcl-tk@8 - name: Configure CPython run: | - MACOSX_DEPLOYMENT_TARGET=10.13 \ + MACOSX_DEPLOYMENT_TARGET=10.15 \ GDBM_CFLAGS="-I$(brew --prefix gdbm)/include" \ GDBM_LIBS="-L$(brew --prefix gdbm)/lib -lgdbm" \ ./configure \