Skip to content

Commit

Permalink
Adding back -march=native for non-wheel builds.
Browse files Browse the repository at this point in the history
This way, when installing from source (either via a local
checkout or from the source dist on PyPI) the most optimal machine
instructions will be produced.

Fixed #99.
  • Loading branch information
dhermes committed May 27, 2018
1 parent 7265e6c commit 1566019
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/manylinux/build-wheels.sh
Expand Up @@ -40,6 +40,9 @@ for PYBIN in /opt/python/*/bin; do
fi
done

# Indicate that wheels are being built.
export BEZIER_WHEEL=True

# Compile wheels
for PYBIN in ${VERSION_WHITELIST}; do
"${PYBIN}/pip" install -r /io/scripts/manylinux/dev-requirements.txt
Expand Down
3 changes: 3 additions & 0 deletions scripts/osx/build-wheels.sh
Expand Up @@ -54,6 +54,9 @@ ${PY_BIN} -m pip install --upgrade setuptools numpy
# Make sure the custom ``libgfortran`` is in place.
${PY_BIN} ${OSX_DIR}/make_universal_libgfortran.py

# Indicate that wheels are being built.
export BEZIER_WHEEL=True

# Create the wheel (make sure to use the custom ``libgfortran``).
DIST_WHEELS="${OSX_DIR}/dist_wheels"
mkdir -p ${DIST_WHEELS}
Expand Down
9 changes: 9 additions & 0 deletions setup_helpers.py
Expand Up @@ -35,6 +35,12 @@
``scripts/osx/make_universal_libgfortran.py`` and
``scripts/osx/build-wheels.sh`` for an example of this.)
"""
WHEEL_ENV = "BEZIER_WHEEL"
"""Environment variable used to indicate a wheel is being built.
If this is present (e.g. ``BEZIER_WHEEL="True"``) then the ``-march=native``
flag will **not** be used.
"""
FORTRAN_LIBRARY_PREFIX = "libraries: ="
GFORTRAN_MISSING_LIBS = (
"""\
Expand Down Expand Up @@ -62,6 +68,7 @@
GFORTRAN_DEBUG_FLAGS = (
"-g", "-fcheck=all", "-fbacktrace", "-fimplicit-none", "-pedantic"
)
GFORTRAN_NATIVE_FLAG = "-march=native"
GFORTRAN_OPTIMIZE_FLAGS = ("-Werror", "-O3", "-funroll-loops")
BAD_JOURNAL = "Saving journal failed with {!r}."
JOURNAL_ENV = "BEZIER_JOURNAL"
Expand Down Expand Up @@ -234,6 +241,8 @@ def patch_f90_compiler(f90_compiler):
to_remove = GFORTRAN_OPTIMIZE_FLAGS
else:
to_add = GFORTRAN_OPTIMIZE_FLAGS
if os.environ.get(WHEEL_ENV) is None:
to_add += (GFORTRAN_NATIVE_FLAG,)
to_remove = GFORTRAN_DEBUG_FLAGS
for flag in to_add:
if flag not in f90_flags:
Expand Down

0 comments on commit 1566019

Please sign in to comment.