Skip to content

Commit

Permalink
Trac #29408: Fix build errors with pplpy, scipy, kiwisolver, fpylll o…
Browse files Browse the repository at this point in the history
…n macos with system python3

On the platform `local-homebrew-macos` defined by `tox.ini`, running on
a `macos-latest` system as defined in
https://help.github.com/en/actions/reference/virtual-environments-for-
github-hosted-runners#supported-runners-and-hardware-resources, a branch
that includes #27824 (spkg-configure.m4 for python3) leads to the
following error with `pplpy`, as seen in
https://github.com/mkoeppe/sage/runs/538432631:
{{{
    g++ -sdk macosx clang -bundle -undefined dynamic_lookup
-L/Users/runner/runners/2.165.2/work/sage/sage/.tox/local-homebrew-
macos-standard/local/lib
-Wl,-rpath,/Users/runner/runners/2.165.2/work/sage/sage/.tox/local-
homebrew-macos-standard/local/lib
-L/Users/runner/runners/2.165.2/work/sage/sage/.tox/local-homebrew-
macos-standard/homebrew/opt/readline/lib
-L/Users/runner/runners/2.165.2/work/sage/sage/.tox/local-homebrew-
macos-standard/homebrew/lib
-I/Users/runner/runners/2.165.2/work/sage/sage/.tox/local-homebrew-
macos-standard/homebrew/opt/readline/include
-I/Users/runner/runners/2.165.2/work/sage/sage/.tox/local-homebrew-
macos-standard/homebrew/include
build/temp.macosx-10.14-x86_64-3.7/ppl/linear_algebra.o
build/temp.macosx-10.14-x86_64-3.7/ppl/ppl_shim.o -lgmp -lgmpxx -lppl
-lm -o build/lib.macosx-10.14-x86_64-3.7/ppl/linear_algebra.cpython-37m-
darwin.so
    clang: error: unknown argument: '-sdk'
    clang: error: no such file or directory: 'macosx'
    clang: error: no such file or directory: 'clang'
    error: command 'g++' failed with exit status 1
    Running setup.py install for pplpy: finished with status 'error'
Cleaning up...
}}}

Same kind of error with scipy, kiwisolver, fpylll.

Full logs can be downloaded at the above link.

To test locally, using #29104 + #27824, remove all python3 from the
homebrew in /usr/local
and run
{{{
tox -e local-homebrew-macos-standard -- V=0 pplpy
}}}
With #29417, it is:
{{{
tox -e local-homebrew-macos-standard-python3_xcode -- V=0 pplpy
}}}

(broken out from #29404)

URL: https://trac.sagemath.org/29408
Reported by: mkoeppe
Ticket author(s): Matthias Koeppe
Reviewer(s): John Palmieri
  • Loading branch information
Release Manager committed Apr 14, 2020
2 parents 58c92b8 + 8317c3e commit b42af5e
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 15 deletions.
11 changes: 11 additions & 0 deletions build/pkgs/perl_term_readline_gnu/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ fi

cd src

case $(uname) in
Darwin)
# #21175/#29408: Set the ARCHFLAGS environment variable. This
# is to make sure that the output of perl -MExtUtils::Embed
# -e ldopts and perl -MExtUtils::Embed -e ccflags (picked up
# from system perl) do not contain -arch flags incompatible
# with our gcc.
export ARCHFLAGS=""
;;
esac

# In the configure phase, the package fails to use rpath for a test
# program that it compiles, causing a build failure on Linux as
# reported in #22505 (libreadline.so not found). We work around it by
Expand Down
14 changes: 11 additions & 3 deletions build/pkgs/polymake/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ cd src

more_configure_options=

if [ `uname` = Darwin ]; then
more_configure_options="$more_configure_options --without-fink"
fi
case $(uname) in
Darwin)
more_configure_options="$more_configure_options --without-fink"
# #21175/#29408: Set the ARCHFLAGS environment variable. This
# is to make sure that the output of perl -MExtUtils::Embed
# -e ldopts and perl -MExtUtils::Embed -e ccflags (picked up
# from system perl) do not contain -arch flags incompatible
# with our gcc.
export ARCHFLAGS=""
;;
esac

# We disable SoPlex to avoid linking errors (#24905).
# Since polymake v3.4, it does not find our lrs installation if we do not provide --with-lrs explicitly.
Expand Down
70 changes: 63 additions & 7 deletions build/pkgs/python3/spkg-configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,70 @@ modules = list((Extension("config_check_distutils", list(("conftest.c",))),))
setup(name="config_check_distutils", ext_modules=modules)
exit(0)
EOF
AS_IF([conftest_venv/bin/python3 conftest.py --quiet build --build-base=conftest.dir], [
ac_cv_path_PYTHON3="$ac_path_PYTHON3"
ac_path_PYTHON3_found=:
AC_MSG_RESULT([yes])
dnl introduction for AC_MSG_RESULT printed by AC_CACHE_CHECK
AC_MSG_CHECKING([for python3 >= 3.7.3, < 3.8 with modules $check_modules])
dnl (echo "***ENV***:"; env; echo "***SYSCONFIG***"; conftest_venv/bin/python3 -m sysconfig) >& AS_MESSAGE_LOG_FD
echo CC="$CC" CXX="$CXX" conftest_venv/bin/python3 conftest.py --verbose build --build-base=conftest.dir >& AS_MESSAGE_LOG_FD
AS_IF([CC="$CC" CXX="$CXX" conftest_venv/bin/python3 conftest.py --verbose build --build-base=conftest.dir >& AS_MESSAGE_LOG_FD 2>&1 ], [
rm -rf conftest.*
AC_LANG_PUSH([C++])
AC_LANG_CONFTEST([
AC_LANG_SOURCE([[
#define PY_SSIZE_T_CLEAN
#include <Python.h>
static PyMethodDef SpamMethods[] = {
{NULL, NULL, 0, NULL} /* Sentinel */
};
static struct PyModuleDef spammodule = {
PyModuleDef_HEAD_INIT,
"spam", /* name of module */
NULL, /* module documentation, may be NULL */
-1, /* size of per-interpreter state of the module,
or -1 if the module keeps state in global variables. */
SpamMethods
};
PyMODINIT_FUNC
PyInit_spam(void)
{
PyObject *m;
m = PyModule_Create(&spammodule);
return m;
}
// Partial C++11 test, from ax_cxx_compile_stdcxx.m4
namespace test_noexcept
{
int f() { return 0; }
int g() noexcept { return 0; }
static_assert(noexcept(f()) == false, "");
static_assert(noexcept(g()) == true, "");
}
]])
])
AC_LANG_POP([C++])
cat > conftest.py <<EOF
from distutils.core import setup
from distutils.extension import Extension
from sys import exit
modules = list((Extension("config_check_distutils_cxx", list(("conftest.cpp",)),
extra_compile_args=list(("-std=c++11",)), language="c++"),))
setup(name="config_check_distutils_cxx", ext_modules=modules)
exit(0)
EOF
AS_IF([CC="$CC" CXX="$CXX" conftest_venv/bin/python3 conftest.py --verbose build --build-base=conftest.dir >& AS_MESSAGE_LOG_FD 2>&1 ], [
ac_cv_path_PYTHON3="$ac_path_PYTHON3"
ac_path_PYTHON3_found=:
AC_MSG_RESULT([yes])
dnl introduction for AC_MSG_RESULT printed by AC_CACHE_CHECK
AC_MSG_CHECKING([for python3 >= 3.7.3, < 3.8 with modules $check_modules])
], [
AC_MSG_RESULT([no, the version is in the supported range, and the modules can be imported, but distutils cannot build a C++ 11 extension])
])
], [
AC_MSG_RESULT([no, the version is in the supported range, and the modules can be imported, but distutils cannot build an extension])
AC_MSG_RESULT([no, the version is in the supported range, and the modules can be imported, but distutils cannot build a C extension])
])
], [
AC_MSG_RESULT([no, the version is in the supported range but cannot import one of the required modules: $check_modules])
Expand Down
5 changes: 0 additions & 5 deletions src/bin/sage-env
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,6 @@ if [ -n "$CFLAGS" -a -z "$CXXFLAGS" ]; then
export CXXFLAGS="$CFLAGS"
fi

if [ "$UNAME" = "Darwin" ]; then
# Trac #21175 - export empty ARCHFLAGS for the benefit of Perl modules
ARCHFLAGS="" && export ARCHFLAGS
fi

if [ "$CP" = "" ]; then
CP="cp" && export CP
fi
Expand Down

0 comments on commit b42af5e

Please sign in to comment.