From dc5e22511f783391282eca6a986971e6fe6f20b3 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sat, 30 Jan 2021 20:17:04 -0800 Subject: [PATCH] build/pkgs/python3/spkg-configure.m4: On macOS, if the distutils test fails, try using empty ARCHFLAGS --- build/pkgs/python3/spkg-configure.m4 | 6 +++++- m4/sage_check_python_for_venv.m4 | 19 +++++++++++++++++-- src/bin/sage-env | 6 +++--- src/bin/sage-env-config.in | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/build/pkgs/python3/spkg-configure.m4 b/build/pkgs/python3/spkg-configure.m4 index f1470e904d4..40880ffa2d2 100644 --- a/build/pkgs/python3/spkg-configure.m4 +++ b/build/pkgs/python3/spkg-configure.m4 @@ -75,10 +75,14 @@ SAGE_SPKG_CONFIGURE([python3], [ dnl POST AS_IF([test x$sage_spkg_install_python3 = xno], [ PYTHON_FOR_VENV="$ac_cv_path_PYTHON3" + AS_IF([test "$SAGE_ARCHFLAGS" != "unset"], [ + ARCHFLAGS="$SAGE_ARCHFLAGS" + export ARCHFLAGS + ]) AS_IF([test -n "$CFLAGS_MARCH"], [ dnl Trac #31228 AC_MSG_CHECKING([whether "$CFLAGS_MARCH" works with the C/C++ compilers configured for building extensions for $PYTHON_FOR_VENV]) - SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" ARCHFLAGS="" CFLAGS="$CFLAGS_MARCH" conftest_venv/bin/python3], [ + SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" CFLAGS="$CFLAGS_MARCH" conftest_venv/bin/python3], [ AC_MSG_RESULT([yes]) ], [ AC_MSG_RESULT([no, with these flags, $reason; disabling use of "$CFLAGS_MARCH"]) diff --git a/m4/sage_check_python_for_venv.m4 b/m4/sage_check_python_for_venv.m4 index 89b42106674..64bc1e2da56 100644 --- a/m4/sage_check_python_for_venv.m4 +++ b/m4/sage_check_python_for_venv.m4 @@ -7,6 +7,8 @@ AC_DEFUN([SAGE_CHECK_PYTHON_FOR_VENV], [ m4_pushdef([REQUIRED_MODULES], [$4]) m4_pushdef([COMMANDS_IF_GOOD], [$5]) + AC_SUBST([SAGE_ARCHFLAGS]) + AC_MSG_CHECKING([... whether ]PYTHON_EXE[ is good]) python3_version=`"PYTHON_EXE" --version 2>&1 \ | $SED -n -e 's/\([[0-9]]*\.[[0-9]]*\.[[0-9]]*\).*/\1/p'` @@ -19,10 +21,23 @@ AC_DEFUN([SAGE_CHECK_PYTHON_FOR_VENV], [ dnl m4_define([conftest_venv], [config-venv]) .... for debugging only rm -rf conftest_venv AS_IF(["]PYTHON_EXE[" build/bin/sage-venv conftest_venv && conftest_venv/bin/python3 -c "import ]REQUIRED_MODULES["], [ - SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" ARCHFLAGS="" conftest_venv/bin/python3], [ + SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" conftest_venv/bin/python3], [ + SAGE_ARCHFLAGS="unset" COMMANDS_IF_GOOD ], [ - AC_MSG_RESULT([no, the version is in the supported range, and the modules can be imported, but $reason]) + AS_CASE([$host], + [*-*-darwin*], [ + dnl #31227: Try if setting ARCHFLAGS to empty fixes it + SAGE_PYTHON_CHECK_DISTUTILS([CC="$CC" CXX="$CXX" ARCHFLAGS="" conftest_venv/bin/python3], [ + SAGE_ARCHFLAGS="" + COMMANDS_IF_GOOD + ], [ + AC_MSG_RESULT([no, the version is in the supported range, and the modules can be imported, but $reason (even with ARCHFLAGS set to empty)]) + ]) + ], [ + AC_MSG_RESULT([no, the version is in the supported range, and the modules can be imported, but $reason]) + ] + ) ]) ], [ AC_MSG_RESULT([no, the version is in the supported range but cannot import one of the required modules: ]REQUIRED_MODULES) diff --git a/src/bin/sage-env b/src/bin/sage-env index 317ed700293..4c617d8cd44 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -206,9 +206,9 @@ export F95="$FC" # If the environment defines ARCHFLAGS, even when empty, then take that. # Otherwise, use the configured value; but if that is "unset", do not set # the variable at all. -if [ "{$ARCHFLAGS-unset}" = "unset" ]; then - if [ "${CONFIGURED_ARCHFLAGS-unset}" != "unset" ]; then - export ARCHFLAGS="${CONFIGURED_ARCHFLAGS}" +if [ "${ARCHFLAGS-unset}" = "unset" ]; then + if [ "${SAGE_ARCHFLAGS-unset}" != "unset" ]; then + export ARCHFLAGS="${SAGE_ARCHFLAGS}" fi fi diff --git a/src/bin/sage-env-config.in b/src/bin/sage-env-config.in index 2285c7c4035..7ab1995e4e8 100644 --- a/src/bin/sage-env-config.in +++ b/src/bin/sage-env-config.in @@ -42,7 +42,6 @@ CONFIGURED_CXX="@CXX@" CONFIGURED_FC="@FC@" CONFIGURED_OBJC="@OBJC@" CONFIGURED_OBJCXX="@OBJCXX@" -CONFIGURED_ARCHFLAGS="@ARCHFLAGS@" ####################################### # Other configuration (exported) @@ -51,5 +50,6 @@ CONFIGURED_ARCHFLAGS="@ARCHFLAGS@" ####################################### # Other configuration (not exported, only used in sage-env) ####################################### +SAGE_ARCHFLAGS="@SAGE_ARCHFLAGS@" SAGE_PKG_CONFIG_PATH="@SAGE_PKG_CONFIG_PATH@" SAGE_MACOSX_DEPLOYMENT_TARGET="@SAGE_MACOSX_DEPLOYMENT_TARGET@"