27122 determines whether CC accepts -march=native and then adds it globally to CFLAGS in build/bin/sage-build-env.
30725 fixes this for macOS, where some packages are explicitly built with clang.
However, there is another mechanism how clang can come in: Python extension modules are compiled with the compiler listed in sysconfig. On macOS with homebrew, using /usr/bin/python3, this could again be clang, which does not accept -march=native in combination with -arch arm64 (which is provided even on x86_64 if ARCHFLAGS is unset).
In this ticket, we fix this by checking whether the compiler used by distutils accepts -march=native (or more generally, the flags determined earlier by configure). If it does not, then we disable the use of these flags.
In order to test this with /usr/bin/python3 from XCode 12.3 (on macOS 10.15 (Catalina)), we fix another issue:
This python3 (3.8.2) is not able to build extension modules because it emits -arch arm64 -arch x86_64 unless ARCHFLAGS is set explicitly
In this ticket, if the distutils test fails, we try if setting ARCHFLAGS="" fixes it. Also, after accepting a system python and ARCHFLAGS so far has not been set, we test whether the system python wants to do the multi-arch build.
In either of these two cases, we store a configuration variable that causes sage-env to set ARCHFLAGS as well.
This is somewhat complicated logic - we are tiptoeing around previous breakage that had been caused by setting ARCHFLAGS unconditionally (#29408).
(from #31132)
27122 determines whether CC accepts
-march=native
and then adds it globally toCFLAGS
inbuild/bin/sage-build-env
.30725 fixes this for macOS, where some packages are explicitly built with
clang
.However, there is another mechanism how
clang
can come in: Python extension modules are compiled with the compiler listed in sysconfig. On macOS with homebrew, using/usr/bin/python3
, this could again beclang
, which does not accept-march=native
in combination with-arch arm64
(which is provided even on x86_64 ifARCHFLAGS
is unset).In this ticket, we fix this by checking whether the compiler used by distutils accepts
-march=native
(or more generally, the flags determined earlier byconfigure
). If it does not, then we disable the use of these flags.In order to test this with
/usr/bin/python3
from XCode 12.3 (on macOS 10.15 (Catalina)), we fix another issue: This python3 (3.8.2) is not able to build extension modules because it emits-arch arm64 -arch x86_64
unlessARCHFLAGS
is set explicitlyIn this ticket, if the distutils test fails, we try if setting
ARCHFLAGS=""
fixes it. Also, after accepting a system python andARCHFLAGS
so far has not been set, we test whether the system python wants to do the multi-arch build.In either of these two cases, we store a configuration variable that causes
sage-env
to setARCHFLAGS
as well.This is somewhat complicated logic - we are tiptoeing around previous breakage that had been caused by setting
ARCHFLAGS
unconditionally (#29408).Depends on #31132 Depends on #30725
CC: @jhpalmieri @zlscherr @dimpase @kliem @vbraun
Component: build: configure
Author: Matthias Koeppe
Branch/Commit:
fc8b676
Reviewer: Jonathan Kliem
Issue created by migration from https://trac.sagemath.org/ticket/31227