From f9267cdfae79c786816a001643f5fc84f15e846e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=8E=E3=82=A6=E3=83=A9=20=7C=20Flare?= Date: Sat, 19 Sep 2026 18:11:49 +0200 Subject: [PATCH] gh-157549: Use sysconf() for the page size in remote_debug.h (GH-157800) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit getpagesize() is not an ISO C or POSIX function. Darwin hides the prototype under -std=c11, so the _remote_debugging build fails with -Werror=implicit-function-declaration. That is the failure in the reported x86_64-apple-darwin → arm64-apple-darwin cross build. Call sysconf(_SC_PAGESIZE) instead, which is already how resource.getpagesize() works. Fall back to 4096 if sysconf() fails. --without-remote-debug is unchanged. That flag only disables the target-side attach protocol (Py_REMOTE_DEBUG); it does not exclude the _remote_debugging client module. (cherry picked from commit 9193375382fbfc871a8a1c14f918895081e219a1) Co-authored-by: ノウラ | Flare --- .../next/Build/2026-09-19-16-54-58.gh-issue-157549.uk6QNH.rst | 3 +++ Python/remote_debug.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Build/2026-09-19-16-54-58.gh-issue-157549.uk6QNH.rst diff --git a/Misc/NEWS.d/next/Build/2026-09-19-16-54-58.gh-issue-157549.uk6QNH.rst b/Misc/NEWS.d/next/Build/2026-09-19-16-54-58.gh-issue-157549.uk6QNH.rst new file mode 100644 index 000000000000000..eab0335aa671148 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-09-19-16-54-58.gh-issue-157549.uk6QNH.rst @@ -0,0 +1,3 @@ +Use ``sysconf(_SC_PAGESIZE)`` instead of ``getpagesize()`` in +``remote_debug.h`` so ``_remote_debugging`` builds on Darwin with +``-Werror=implicit-function-declaration``. diff --git a/Python/remote_debug.h b/Python/remote_debug.h index 7b7380d25bf496f..16229df936ffef6 100644 --- a/Python/remote_debug.h +++ b/Python/remote_debug.h @@ -142,7 +142,8 @@ get_page_size(void) { GetSystemInfo(&si); page_size = si.dwPageSize; #else - page_size = (size_t)getpagesize(); + long n = sysconf(_SC_PAGESIZE); + page_size = (n > 0) ? (size_t)n : 4096; #endif } return page_size;