Skip to content

Commit c6b16da

Browse files
committed
macos: prevent use of utimensat() and futimensat() on macOS
And turn the compiler warnings into errors so we don't use functions that aren't supported on the targeted macOS version. This should fix indygreg/PyOxidizer#112 once a produced distribution makes its way to PyOxidizer.
1 parent 0edcb61 commit c6b16da

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cpython-unix/build-cpython.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ CFLAGS="-fPIC -I${TOOLS_PATH}/deps/include -I${TOOLS_PATH}/deps/include/ncurses"
107107

108108
if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
109109
CFLAGS="${CFLAGS} -I${TOOLS_PATH}/deps/lib/libffi-3.2.1/include -I${TOOLS_PATH}/deps/include/uuid"
110+
# Prevent using symbols not supported by current macOS SDK target.
111+
CFLAGS="${CFLAGS} -Werror=unguarded-availability-new"
110112
fi
111113

112114
CPPFLAGS=$CFLAGS
@@ -134,6 +136,13 @@ fi
134136
CFLAGS=$CFLAGS CPPFLAGS=$CFLAGS LDFLAGS=$LDFLAGS \
135137
./configure ${CONFIGURE_FLAGS}
136138

139+
# configure checks for the presence of functions and blindly uses them,
140+
# even if they aren't available in the target macOS SDK. Work around that.
141+
if [ "${PYBUILD_PLATFORM}" = "macos" ]; then
142+
sed -i "" "s/#define HAVE_UTIMENSAT 1//g" pyconfig.h
143+
sed -i "" "s/#define HAVE_FUTIMENS 1//g" pyconfig.h
144+
fi
145+
137146
# Supplement produced Makefile with our modifications.
138147
cat ../Makefile.extra >> Makefile
139148

0 commit comments

Comments
 (0)