mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
bpo-26317: Support OBJC and OBJCXX configure command line variables (GH-20176)
Add support to the configure script for OBJC and OBJCXX command line options so that the macOS builds can use the clang compiler for the macOS-specific Objective C source files. This allows third-party compilers, like GNU gcc, to be used to build the rest of the project since some of the Objective C system header files are not compilable by GNU gcc. Co-authored-by: Jeffrey Kintscher <websurfer@surf2c.net> Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
This commit is contained in:
@@ -892,6 +892,14 @@ Build Changes
|
||||
functions are now required to build Python.
|
||||
(Contributed by Victor Stinner in :issue:`39395`.)
|
||||
|
||||
* The ``OBJC`` and ``OBJCXX`` standard command line options for the configure
|
||||
script are now supported. This allows building fot macOS with a third-party
|
||||
compiler, like GNU `gcc`, for everything except for the several
|
||||
system-specific source files that need system headers that require the
|
||||
Apple-supplied compile chain (e.g. the ``_scproxy`` helper module and
|
||||
``PythonLauncher.app``).
|
||||
(Contributed by Jeffrey Kintscher in :issue:`26317`.)
|
||||
|
||||
|
||||
C API Changes
|
||||
=============
|
||||
|
||||
@@ -21,6 +21,7 @@ PYTHONFRAMEWORK=@PYTHONFRAMEWORK@
|
||||
PYTHONFRAMEWORKIDENTIFIER=@PYTHONFRAMEWORKIDENTIFIER@
|
||||
LIPO_32BIT_FLAGS=@LIPO_32BIT_FLAGS@
|
||||
CC=@CC@
|
||||
OBJC=@OBJC@
|
||||
MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
|
||||
export MACOSX_DEPLOYMENT_TARGET
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
CC=@CC@
|
||||
LD=@CC@
|
||||
OBJC=@OBJC@
|
||||
OBJCFLAFS=@OBJCFLAGS@
|
||||
BASECFLAGS=@BASECFLAGS@
|
||||
OPT=@OPT@
|
||||
CFLAGS=@CFLAGS@ $(BASECFLAGS) $(OPT)
|
||||
@@ -52,25 +54,25 @@ Python\ Launcher.app: Info.plist \
|
||||
cp -R $(srcdir)/English.lproj "Python Launcher.app/Contents/Resources"
|
||||
|
||||
FileSettings.o: $(srcdir)/FileSettings.m
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/FileSettings.m
|
||||
$(OBJC) $(CFLAGS) -o $@ -c $(srcdir)/FileSettings.m
|
||||
|
||||
MyAppDelegate.o: $(srcdir)/MyAppDelegate.m
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyAppDelegate.m
|
||||
$(OBJC) $(CFLAGS) -o $@ -c $(srcdir)/MyAppDelegate.m
|
||||
|
||||
MyDocument.o: $(srcdir)/MyDocument.m
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyDocument.m
|
||||
$(OBJC) $(CFLAGS) -o $@ -c $(srcdir)/MyDocument.m
|
||||
|
||||
PreferencesWindowController.o: $(srcdir)/PreferencesWindowController.m
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/PreferencesWindowController.m
|
||||
$(OBJC) $(CFLAGS) -o $@ -c $(srcdir)/PreferencesWindowController.m
|
||||
|
||||
doscript.o: $(srcdir)/doscript.m
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/doscript.m
|
||||
$(OBJC) $(CFLAGS) -o $@ -c $(srcdir)/doscript.m
|
||||
|
||||
main.o: $(srcdir)/main.m
|
||||
$(CC) $(CFLAGS) -o $@ -c $(srcdir)/main.m
|
||||
$(OBJC) $(CFLAGS) -o $@ -c $(srcdir)/main.m
|
||||
|
||||
Python\ Launcher: $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o "Python Launcher" $(OBJECTS) -framework AppKit -framework Carbon
|
||||
$(OBJC) $(LDFLAGS) -o "Python Launcher" $(OBJECTS) -framework AppKit -framework Carbon
|
||||
|
||||
Info.plist: $(srcdir)/Info.plist.in
|
||||
sed 's/%VERSION%/'"`$(RUNSHARED) $(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`"'/g' < $(srcdir)/Info.plist.in > Info.plist
|
||||
|
||||
@@ -35,6 +35,7 @@ abs_builddir= @abs_builddir@
|
||||
|
||||
CC= @CC@
|
||||
CXX= @CXX@
|
||||
OBJC= @OBJC@
|
||||
MAINCC= @MAINCC@
|
||||
LINKCC= @LINKCC@
|
||||
AR= @AR@
|
||||
@@ -613,12 +614,22 @@ $(srcdir)/Modules/_blake2/blake2s_impl.c: $(srcdir)/Modules/_blake2/blake2b_impl
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Modules/_blake2/blake2b2s.py
|
||||
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py -f $@
|
||||
|
||||
# _scproxy.o needs to be built outside of setup.py so that we can force
|
||||
# the use of the OBJC compiler when the CC compiler is different. For
|
||||
# example, it allows _scproxy.c to be compiled using the clang compiler
|
||||
# while the rest of the project uses the GNU C compiler.
|
||||
#
|
||||
# see issue #26317 for details
|
||||
@SCPROXY@Modules/_scproxy.o: $(srcdir)/Modules/_scproxy.c $(srcdir)/Include/Python.h
|
||||
@SCPROXY@ $(OBJC) -c $(CCSHARED) $(PY_CORE_CFLAGS) -o $@ $<
|
||||
@NOSCPROXY@.PHONY: Modules/_scproxy.o
|
||||
|
||||
# Build the shared modules
|
||||
# Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
|
||||
# -s, --silent or --quiet is always the first char.
|
||||
# Under BSD make, MAKEFLAGS might be " -s -v x=y".
|
||||
# Ignore macros passed by GNU make, passed after --
|
||||
sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
|
||||
sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o Modules/_scproxy.o
|
||||
@case "`echo X $$MAKEFLAGS | sed 's/^X //;s/ -- .*//'`" in \
|
||||
*\ -s*|s*) quiet="-q";; \
|
||||
*) quiet="";; \
|
||||
|
||||
@@ -882,6 +882,7 @@ Sam Kimbrel
|
||||
Tomohiko Kinebuchi
|
||||
James King
|
||||
W. Trevor King
|
||||
Jeffrey Kintscher
|
||||
Paul Kippes
|
||||
Steve Kirsch
|
||||
Sebastian Kirsche
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
The OBJC and OBJCXX standard command line options for the configure script are now supported. This allows building fot macOS with a third-party compiler, like GNU gcc, for everything except for the several system-specific source files that need system headers that require the Apple-supplied compile chain (e.g. the _scproxy helper module and PythonLauncher.app). Patch by Jeffrey Kintscher.
|
||||
10
aclocal.m4
vendored
10
aclocal.m4
vendored
@@ -55,7 +55,7 @@ dnl
|
||||
dnl See the "Since" comment for each macro you use to see what version
|
||||
dnl of the macros you require.
|
||||
m4_defun([PKG_PREREQ],
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29.1])
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29.2])
|
||||
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
||||
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
||||
])dnl PKG_PREREQ
|
||||
@@ -156,7 +156,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
|
||||
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
|
||||
|
||||
pkg_failed=no
|
||||
AC_MSG_CHECKING([for $1])
|
||||
AC_MSG_CHECKING([for $2])
|
||||
|
||||
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
|
||||
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
|
||||
@@ -166,11 +166,11 @@ and $1[]_LIBS to avoid the need to call pkg-config.
|
||||
See the pkg-config man page for more details.])
|
||||
|
||||
if test $pkg_failed = yes; then
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_RESULT([no])
|
||||
_PKG_SHORT_ERRORS_SUPPORTED
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
|
||||
else
|
||||
else
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
@@ -187,7 +187,7 @@ installed software in a non-standard prefix.
|
||||
_PKG_TEXT])[]dnl
|
||||
])
|
||||
elif test $pkg_failed = untried; then
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_RESULT([no])
|
||||
m4_default([$4], [AC_MSG_FAILURE(
|
||||
[The pkg-config script could not be found or is too old. Make sure it
|
||||
is in your PATH or set the PKG_CONFIG environment variable to the full
|
||||
|
||||
19
configure.ac
19
configure.ac
@@ -663,6 +663,25 @@ AC_PROG_SED
|
||||
|
||||
AC_SUBST(CXX)
|
||||
AC_SUBST(MAINCC)
|
||||
|
||||
if test "$ac_sys_system" = "Darwin"
|
||||
then
|
||||
# MacOSX requires an Objective C compiler to
|
||||
# build some Mac-specific code.
|
||||
AC_PROG_OBJC
|
||||
AC_PROG_OBJCXX
|
||||
AC_SUBST(OBJC)
|
||||
AC_SUBST(OBJCXX)
|
||||
SCPROXY=
|
||||
NOSCPROXY=#
|
||||
else
|
||||
SCPROXY=#
|
||||
NOSCPROXY=
|
||||
fi
|
||||
|
||||
AC_SUBST(SCPROXY)
|
||||
AC_SUBST(NOSCPROXY)
|
||||
|
||||
AC_MSG_CHECKING(for --with-cxx-main=<compiler>)
|
||||
AC_ARG_WITH(cxx_main,
|
||||
AS_HELP_STRING([--with-cxx-main@<:@=COMPILER@:>@],
|
||||
|
||||
5
setup.py
5
setup.py
@@ -1583,10 +1583,11 @@ class PyBuildExt(build_ext):
|
||||
self.missing.append('ossaudiodev')
|
||||
|
||||
if MACOS:
|
||||
self.add(Extension('_scproxy', ['_scproxy.c'],
|
||||
self.add(Extension('_scproxy', [],
|
||||
extra_link_args=[
|
||||
'-framework', 'SystemConfiguration',
|
||||
'-framework', 'CoreFoundation']))
|
||||
'-framework', 'CoreFoundation'],
|
||||
extra_objects=['Modules/_scproxy.o']))
|
||||
|
||||
def detect_compress_exts(self):
|
||||
# Andrew Kuchling's zlib module. Note that some versions of zlib
|
||||
|
||||
Reference in New Issue
Block a user