From 86aa73b21ced659445d49c600bb304574d29feb5 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 15 Jun 2020 15:34:08 +0200 Subject: [PATCH 01/40] add march=native in configure.ac --- configure.ac | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index bc7e9fe1510..fd54c080a37 100644 --- a/configure.ac +++ b/configure.ac @@ -304,10 +304,42 @@ AX_PROG_PERL_VERSION([5.8.0],[],[ AC_MSG_ERROR([Exiting, since AC_PACKAGE_NAME requires perl-5.8.0 or later]) ]) + + ############################################################################### -# Check C/C++/Fortran compilers +# Check C/C++/Fortran compilers and set CFLAGS ############################################################################### +ORIGINAL_CFLAGS="$CFLAGS" +ORIGINAL_CXXFLAGS="$CXXFLAGS" +ORIGINAL_CXXFLAGS="$FCFLAGS" +ORIGINAL_CXXFLAGS="$F77FLAGS" +AC_SUBST(ORIGINAL_CFLAGS) +AC_SUBST(ORIGINAL_CXXFLAGS) +AC_SUBST(ORIGINAL_FCFLAGS) +AC_SUBST(ORIGINAL_F77FLAGS) + +if test "x${CFLAGS}" = "x"; then + GOT_FLAGS="no" + + # Evaluate SAGE_DEBUG: + if test "x$SAGE_DEBUG" = "xyes" ; then + CFLAGS="-Og -g" + CFLAGS_O3="-Og -g" + else + if test "x$SAGE_DEBUG" = "no" ; then + CFLAGS="-O2" + CFLAGS_O3="-O3" + else + CFLAGS="-O2 -g" + CFLAGS_O3="-O3 -g" + fi + fi +else + GOT_FLAGS="yes" + CFLAGS_O3="${CFLAGS}" +fi + SAGE_CHECK_CONDA_COMPILERS AC_PROG_CC() @@ -328,6 +360,76 @@ AC_SUBST(OBJCXX) AS_IF([test "x$CXX" = x], [AC_MSG_ERROR([a C++ compiler is missing])]) +CFLAGS_NON_NATIVE="${CFLAGS}" +AC_SUBST(CFLAGS_NON_NATIVE) + +# Adding march native in certain cases. +if test "x$SAGE_FAT_BINARY" != "xyes" ; then + if test "x$GOT_FLAGS" = "xno"; then + + # GCC less than 5.1 is not yet ready for "-march=native", + # but it claims it is. + GCC_LT_51="no" + if test "x$GCC" = "xyes"; then + GCC_GTE_51=$(expr `${CC} --version | grep ^gcc | sed 's/^.* //g' | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$/&00/'` \>= 50100) + if test "x$GCC_GTE_51" = "x0"; then + GCC_LT_51="yes" + fi + fi + + if test "x$GCC_LT_51" = "xno"; then + AX_CHECK_COMPILE_FLAG("-march=native", [MARCH=" -march=native"], [MARCH=""], [], []) + CFLAGS="${CFLAGS}${MARCH}" + CFLAGS_O3="${CFLAGS_O3}${MARCH}" + fi + + fi +fi +AC_SUBST(CFLAGS) +AC_SUBST(CFLAGS_O3) +AC_MSG_NOTICE(CFLAGS_NON_NATIVE=$CFLAGS_NON_NATIVE) +AC_MSG_NOTICE(CFLAGS=$CFLAGS) +AC_MSG_NOTICE(CFLAGS_O3=$CFLAGS_O3) + +# Copy to CXXFLAGS, if this is not set. +if test "x${CXXFLAGS}" = "x"; then + CXXFLAGS="$CFLAGS" + CXXFLAGS_O3="$CFLAGS_O3" + CXXFLAGS_NON_NATIVE="$CFLAGS_NON_NATIVE" +else + CXXFLAGS_03="$CXXFLAGS" + CXXFLAGS_NON_NATIVE="$CXXFLAGS" +fi +AC_SUBST(CXXFLAGS) +AC_SUBST(CCXFLAGS_O3) +AC_SUBST(CXXFLAGS_NON_NATIVE) + +# Copy to FCFLAGS, if this is not set. +if test "x${FCFLAGS}" = "x"; then + FCFLAGS="$CFLAGS" + FCFLAGS_O3="$CFLAGS_O3" + FCFLAGS_NON_NATIVE="$CFLAGS_NON_NATIVE" +else + FCFLAGS_03="$FCFLAGS" + FCFLAGS_NON_NATIVE="$FCFLAGS" +fi +AC_SUBST(FCFLAGS) +AC_SUBST(FCFLAGS_O3) +AC_SUBST(FCFLAGS_NON_NATIVE) + +# Copy to F77FLAGS, if this is not set. +if test "x${F77FLAGS}" = "x"; then + F77FLAGS="$CFLAGS" + F77FLAGS_O3="$CFLAGS_O3" + F77FLAGS_NON_NATIVE="$CFLAGS_NON_NATIVE" +else + F77FLAGS_03="$FCFLAGS" + F77FLAGS_NON_NATIVE="$FCFLAGS" +fi +AC_SUBST(F77FLAGS) +AC_SUBST(F77FLAGS_O3) +AC_SUBST(F77FLAGS_NON_NATIVE) + ############################################################################### # Check header files @@ -370,6 +472,7 @@ AS_IF([echo "$ac_pwd" |grep " " >/dev/null], SAGE_CHECK_OSX_SUPPORTED() + ############################################################################### # Collect substitutions for build/make/Makefile.in ############################################################################### From dc591ea97df73c0389479819438fcad4c7445d45 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 15 Jun 2020 15:43:12 +0200 Subject: [PATCH 02/40] remove reduntant flag setting in packages --- build/pkgs/e_antic/spkg-install.in | 4 --- build/pkgs/ecl/spkg-install.in | 8 ----- build/pkgs/eclib/spkg-install.in | 14 ++------ build/pkgs/ecm/spkg-install.in | 8 ++--- build/pkgs/flint/spkg-install.in | 1 - build/pkgs/fplll/spkg-install.in | 3 -- build/pkgs/gap/spkg-install.in | 3 -- build/pkgs/gc/spkg-check.in | 6 ---- build/pkgs/gc/spkg-install.in | 7 ---- build/pkgs/gf2x/spkg-install.in | 5 +-- build/pkgs/gmp/spkg-install.in | 10 ------ build/pkgs/gsl/spkg-install.in | 8 ----- build/pkgs/iml/spkg-check.in | 6 ---- build/pkgs/iml/spkg-install.in | 7 +--- build/pkgs/latte_int/spkg-check.in | 8 ----- build/pkgs/lcalc/spkg-build.in | 15 -------- build/pkgs/libatomic_ops/spkg-check.in | 6 ---- build/pkgs/libatomic_ops/spkg-install.in | 7 ---- build/pkgs/m4ri/spkg-install.in | 2 -- build/pkgs/m4rie/spkg-install.in | 2 -- build/pkgs/mpfr/spkg-install.in | 6 ++-- build/pkgs/mpir/spkg-install.in | 10 ------ build/pkgs/ncurses/spkg-install.in | 13 ------- build/pkgs/pari/spkg-check.in | 10 +----- build/pkgs/pari/spkg-install.in | 12 ++----- build/pkgs/r/spkg-install.in | 8 ----- build/pkgs/readline/spkg-install.in | 18 ---------- build/pkgs/rubiks/spkg-install.in | 44 +++++------------------- build/pkgs/singular/spkg-install.in | 10 ------ build/pkgs/sqlite/spkg-install.in | 8 ----- build/pkgs/sympow/spkg-install.in | 2 ++ build/pkgs/zn_poly/spkg-check.in | 10 ++---- build/pkgs/zn_poly/spkg-install.in | 10 ++---- 33 files changed, 30 insertions(+), 261 deletions(-) diff --git a/build/pkgs/e_antic/spkg-install.in b/build/pkgs/e_antic/spkg-install.in index c9aa58efa63..0c0f5d01a1f 100644 --- a/build/pkgs/e_antic/spkg-install.in +++ b/build/pkgs/e_antic/spkg-install.in @@ -3,10 +3,6 @@ # e-antic Sage install script # ############################################################################### -if [ "$SAGE_DEBUG" = "yes" ]; then - CFLAGS="-O0 -g $CFLAGS"; export CFLAGS -fi - cd src sdh_configure diff --git a/build/pkgs/ecl/spkg-install.in b/build/pkgs/ecl/spkg-install.in index 81b28acba57..a03c27e5708 100644 --- a/build/pkgs/ecl/spkg-install.in +++ b/build/pkgs/ecl/spkg-install.in @@ -1,13 +1,5 @@ cd src -if [ "x$SAGE_DEBUG" = "xyes" ] ; then - CFLAGS="-g -O0 $CFLAGS" - CXXFLAGS="-g -O0 $CXXFLAGS" -else - CFLAGS="-g -O2 $CFLAGS" - CXXFLAGS="-g -O2 $CXXFLAGS" -fi - if [ "$UNAME" = "CYGWIN" ]; then # Some of ECL's sources rely on GNU-isms that are allowed by default on # most glibcs, but not in newlib; https://trac.sagemath.org/ticket/25057 diff --git a/build/pkgs/eclib/spkg-install.in b/build/pkgs/eclib/spkg-install.in index ba9a4c0b358..9ccc0420e34 100644 --- a/build/pkgs/eclib/spkg-install.in +++ b/build/pkgs/eclib/spkg-install.in @@ -1,15 +1,7 @@ -if [ "$SAGE_DEBUG" = yes ]; then - echo >&2 "Warning: Setting SAGE_DEBUG=yes completely disables optimization." - CFLAGS="$CFLAGS -g -O0" - CXXFLAGS="$CXXFLAGS -g -O0" -else - # Add debug symbols by default, enable optimization, but let the user - # still override these settings: - CFLAGS="-g -O3 $CFLAGS" - CXXFLAGS="-g -O3 $CXXFLAGS" -fi +CFLAGS="$CFLAGS_O3" +CXXFLAGS="$CXXFLAGS_O3" -export CFLAGS CPPFLAGS CXXFLAGS LDFLAGS +export CFLAGS CXXFLAGS echo "Deleting old versions of eclib libraries, which" diff --git a/build/pkgs/ecm/spkg-install.in b/build/pkgs/ecm/spkg-install.in index 610dd249822..e537735a038 100644 --- a/build/pkgs/ecm/spkg-install.in +++ b/build/pkgs/ecm/spkg-install.in @@ -52,6 +52,8 @@ if [ -n "$system_gmp_h" ]; then esac fi +CFLAGS="$CFLAGS_O3" + # libtool should add the proper flags, but doesn't use "-fPIC" # for the *static* library (which the Sage library links to unless @@ -62,6 +64,7 @@ if ! (echo $ECM_CONFIGURE | egrep -- "--enable-shared|--with-pic" >/dev/null) || then echo "Adding '-fPIC' to CFLAGS since we don't (also) build a shared library." CFLAGS="$CFLAGS -fPIC" # alternatively add '--with-pic' to 'configure' options + ORIGINAL_CFLAGS="$ORIGINAL_CFLAGS -fPIC" else # PIC usually slows down the execution, so don't use it for the *static* # library (unless '--with-pic' was given). libtool does the right thing @@ -79,7 +82,6 @@ fi if [ "$SAGE_DEBUG" = yes ]; then # Add debug symbols and disable optimization: echo >&2 "Warning: Setting SAGE_DEBUG=yes completely disables optimization." - CFLAGS="-g -O0 $CFLAGS" echo "You may in addition (or instead) pass '--enable-assert' and/or" echo "'--enable-memory-debug' to GMP-ECM's 'configure' by setting (and" echo "of course exporting) ECM_CONFIGURE accordingly." @@ -96,10 +98,8 @@ else echo >&2 "See http://trac.sagemath.org/sage_trac/ticket/5847#comment:35" \ "ff. for details." echo >&2 - CFLAGS="-O3 $CFLAGS" + CFLAGS="-O3 $ORIGINAL_CFLAGS" ;; - *) - CFLAGS="-g -O3 $CFLAGS" esac fi diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in index c648fe3ca01..eacd7b6e491 100644 --- a/build/pkgs/flint/spkg-install.in +++ b/build/pkgs/flint/spkg-install.in @@ -5,7 +5,6 @@ ############################################################################### if [ "$SAGE_DEBUG" = "yes" ]; then echo "Building a debug version of FLINT." - CFLAGS="-O0 -g $CFLAGS"; export CFLAGS FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE" fi diff --git a/build/pkgs/fplll/spkg-install.in b/build/pkgs/fplll/spkg-install.in index 4e1fab1dd87..619a3e8d53c 100644 --- a/build/pkgs/fplll/spkg-install.in +++ b/build/pkgs/fplll/spkg-install.in @@ -17,10 +17,7 @@ if [ "$UNAME" = "CYGWIN" ]; then fi if [ "x$SAGE_DEBUG" = "xyes" ]; then - CXXFLAGS="$CXXFLAGS -O0" CONFIGUREFLAGS="$CONFIGUREFLAGS --enable-debug" -else - CXXFLAGS="$CXXFLAGS -O3" fi export CXXFLAGS="$CXXFLAGS" diff --git a/build/pkgs/gap/spkg-install.in b/build/pkgs/gap/spkg-install.in index 45f6fed445e..56e95338df1 100644 --- a/build/pkgs/gap/spkg-install.in +++ b/build/pkgs/gap/spkg-install.in @@ -12,9 +12,6 @@ DESTDIR_GAP_ROOT="$SAGE_DESTDIR$GAP_ROOT" # Note that -g3 allows you to use preprocessor macros in gdb which are widely used if [ "$SAGE_DEBUG" = yes ] ; then export CFLAGS="-O0 -g3 -DDEBUG_MASTERPOINTERS -DDEBUG_GLOBAL_BAGS -DDEBUG_FUNCTIONS_BAGS $CFLAGS" -else - # Default flags - export CFLAGS="-O2 -g $CFLAGS" fi sdh_configure $SAGE_CONFIGURE_GMP diff --git a/build/pkgs/gc/spkg-check.in b/build/pkgs/gc/spkg-check.in index 6d620bd7417..917c8eb7209 100644 --- a/build/pkgs/gc/spkg-check.in +++ b/build/pkgs/gc/spkg-check.in @@ -1,9 +1,3 @@ cd src -if [ "$SAGE_DEBUG" = "yes" ]; then - export CFLAGS="-O0 -g $CFLAGS" -else - export CFLAGS="-O2 -g $CFLAGS" -fi - $MAKE check diff --git a/build/pkgs/gc/spkg-install.in b/build/pkgs/gc/spkg-install.in index 78d60cc8309..e5d254c86fe 100644 --- a/build/pkgs/gc/spkg-install.in +++ b/build/pkgs/gc/spkg-install.in @@ -1,12 +1,5 @@ cd src -if [ "$SAGE_DEBUG" = "yes" ]; then - echo "Building a debug version of BoehmGC." - export CFLAGS="-O0 -g $CFLAGS" -else - export CFLAGS="-O2 -g $CFLAGS" -fi - GC_CONFIGURE="--enable-large-config" if [ "$UNAME" = "CYGWIN" ]; then diff --git a/build/pkgs/gf2x/spkg-install.in b/build/pkgs/gf2x/spkg-install.in index 7ae410af1a8..5f023fc1b8b 100644 --- a/build/pkgs/gf2x/spkg-install.in +++ b/build/pkgs/gf2x/spkg-install.in @@ -13,12 +13,9 @@ touch aclocal.m4 configure Makefile.in gf2x/gf2x-config.h.in if [ "$SAGE_DEBUG" = "yes" ]; then echo "Building a debug version of gf2x." - export CFLAGS="-O0 -g $CFLAGS" elif $CC --version 2>/dev/null |grep 'gcc.* 5[.][12]' >/dev/null; then echo "Using compiler flags to work around problems with GCC 5.1/5.2 (Trac #18580,#18978)" - export CFLAGS="-O2 -fno-forward-propagate -g $CFLAGS" -else - export CFLAGS="-O2 -g $CFLAGS" + export CFLAGS="-fno-forward-propagate $CFLAGS" fi if [ "$SAGE_FAT_BINARY" = "yes" ]; then diff --git a/build/pkgs/gmp/spkg-install.in b/build/pkgs/gmp/spkg-install.in index 61096b76cab..fa53576f8c6 100644 --- a/build/pkgs/gmp/spkg-install.in +++ b/build/pkgs/gmp/spkg-install.in @@ -27,16 +27,6 @@ if [ -z "$CFLAG64" ]; then fi -if [ "$SAGE_DEBUG" = yes ]; then - # Disable optimization, add debug symbols: - required_cflags="$required_cflags -g -O0" - echo >&2 "Warning: Building GMP with SAGE_DEBUG=yes disables optimization." -else - # Add debug symbols by default - required_cflags="$required_cflags -g" -fi - - case "$UNAME" in SunOS) true;; # Auto-detect ABI diff --git a/build/pkgs/gsl/spkg-install.in b/build/pkgs/gsl/spkg-install.in index a6cc2072dda..179b78963a1 100644 --- a/build/pkgs/gsl/spkg-install.in +++ b/build/pkgs/gsl/spkg-install.in @@ -1,11 +1,3 @@ -if [ "$SAGE_DEBUG" = "yes" ] ; then - CFLAGS="-g -O0 $CFLAGS" # No optimisation, aids debugging. -else - CFLAGS="-g -O2 $CFLAGS" # Normal optimisation. -fi - -export CFLAGS - cd src sdh_configure LIBS="`pkg-config --libs-only-l cblas` -lm" diff --git a/build/pkgs/iml/spkg-check.in b/build/pkgs/iml/spkg-check.in index 6d620bd7417..917c8eb7209 100644 --- a/build/pkgs/iml/spkg-check.in +++ b/build/pkgs/iml/spkg-check.in @@ -1,9 +1,3 @@ cd src -if [ "$SAGE_DEBUG" = "yes" ]; then - export CFLAGS="-O0 -g $CFLAGS" -else - export CFLAGS="-O2 -g $CFLAGS" -fi - $MAKE check diff --git a/build/pkgs/iml/spkg-install.in b/build/pkgs/iml/spkg-install.in index 8764fd17cf8..1c082006267 100644 --- a/build/pkgs/iml/spkg-install.in +++ b/build/pkgs/iml/spkg-install.in @@ -1,11 +1,6 @@ cd src -if [ "$SAGE_DEBUG" = "yes" ]; then - echo "Building a debug version of IML." - export CFLAGS="-O0 -g $CFLAGS" -else - export CFLAGS="-O3 -g $CFLAGS" -fi +export CFLAGS=CFLAGS_O3 # When using GMP from a standard system location it shouldn't really # matter what we put here, but iml's configure script requires we diff --git a/build/pkgs/latte_int/spkg-check.in b/build/pkgs/latte_int/spkg-check.in index 7bdcf72a10c..27cd9419538 100644 --- a/build/pkgs/latte_int/spkg-check.in +++ b/build/pkgs/latte_int/spkg-check.in @@ -1,10 +1,2 @@ -if [ "x$SAGE_DEBUG" = xyes ] ; then - CFLAGS="$CFLAGS -g -O0" # No optimisation, aids debugging. -else - CFLAGS="$CFLAGS -g -O2" # Normal optimisation. -fi - -export CFLAGS - cd src $MAKE check diff --git a/build/pkgs/lcalc/spkg-build.in b/build/pkgs/lcalc/spkg-build.in index b477bd0d153..a5c67c2cafa 100644 --- a/build/pkgs/lcalc/spkg-build.in +++ b/build/pkgs/lcalc/spkg-build.in @@ -1,23 +1,8 @@ -# If SAGE_DEBUG is set to 'yes', add debugging information. Since both -# the Sun and GNU compilers accept -g to give debugging information, -# there is no need to do anything specific to one compiler or the other. -if [ "x$SAGE_DEBUG" = xyes ]; then - echo "Code will be built with debugging information present. Unset 'SAGE_DEBUG'" - echo "or set it to 'no' if you don't want that." - - CFLAGS="$CFLAGS -O0 -g" - CXXFLAGS="$CXXFLAGS -O0 -g" -else - echo "No debugging information will be used during the build of this package." - echo "Set 'SAGE_DEBUG' to 'yes' if you want debugging information present (-g added)." -fi - # Using pari in a C++17 file with "using namespace std doesn't # work due to a conflict between std::rank and pari's rank CXXFLAGS=$(echo "${CXXFLAGS}" | sed "s/-std=c++17//g") # Export everything. Probably not necessary in most cases. -export CFLAGS export CXXFLAGS export DEFINES="" diff --git a/build/pkgs/libatomic_ops/spkg-check.in b/build/pkgs/libatomic_ops/spkg-check.in index 1e19e3eb37f..75794c7ee97 100644 --- a/build/pkgs/libatomic_ops/spkg-check.in +++ b/build/pkgs/libatomic_ops/spkg-check.in @@ -1,11 +1,5 @@ cd src -if [ "$SAGE_DEBUG" = "yes" ]; then - export CFLAGS="-O0 -g $CFLAGS" -else - export CFLAGS="-O2 -g $CFLAGS" -fi - if [ "$SAGE64" = "yes" ]; then export CFLAGS="-m64 $CFLAGS" fi diff --git a/build/pkgs/libatomic_ops/spkg-install.in b/build/pkgs/libatomic_ops/spkg-install.in index 4347ff3cd5a..8bcf5eec8d7 100644 --- a/build/pkgs/libatomic_ops/spkg-install.in +++ b/build/pkgs/libatomic_ops/spkg-install.in @@ -1,12 +1,5 @@ cd src -if [ "$SAGE_DEBUG" = "yes" ]; then - echo "Building a debug version of libatomic_ops." - export CFLAGS="-O0 -g $CFLAGS" -else - export CFLAGS="-O2 -g $CFLAGS" -fi - if [ "$SAGE64" = "yes" ]; then echo "Building a 64-bit version of libatomic_ops." export CFLAGS="-m64 $CFLAGS" diff --git a/build/pkgs/m4ri/spkg-install.in b/build/pkgs/m4ri/spkg-install.in index 0ed379b4511..c3ae2270406 100644 --- a/build/pkgs/m4ri/spkg-install.in +++ b/build/pkgs/m4ri/spkg-install.in @@ -11,10 +11,8 @@ elif [ "$COMPILER" = "HP_on_HP-UX" ] ; then fi if [ "x$SAGE_DEBUG" = "xyes" ]; then - CFLAGS="$CFLAGS -O0" ENABLE_DEBUG="--enable-debug" else - CFLAGS="$CFLAGS -O2" ENABLE_DEBUG="" fi diff --git a/build/pkgs/m4rie/spkg-install.in b/build/pkgs/m4rie/spkg-install.in index 9a0449aaf46..925706f0581 100644 --- a/build/pkgs/m4rie/spkg-install.in +++ b/build/pkgs/m4rie/spkg-install.in @@ -18,10 +18,8 @@ fi CPPFLAGS="$INCLUDES" if [ "x$SAGE_DEBUG" = "xyes" ]; then - CFLAGS="-O0 $CFLAGS" ENABLE_DEBUG="--enable-debug" else - CFLAGS="-O2 $CFLAGS" ENABLE_DEBUG="" fi diff --git a/build/pkgs/mpfr/spkg-install.in b/build/pkgs/mpfr/spkg-install.in index ea918577af4..36663a48392 100644 --- a/build/pkgs/mpfr/spkg-install.in +++ b/build/pkgs/mpfr/spkg-install.in @@ -30,18 +30,18 @@ mpfr_configure() # Set up environment variables: ########################################################################### - user_cflags=$CFLAGS # Save them. 'sage-env' sets CC, but not CFLAGS. + user_cflags=$ORIGINAL_CFLAGS # Save them. 'sage-env' sets CC, but not CFLAGS. required_cflags="" # Additional mandatory settings required by Sage, accumulated below. default_cflags="" # Spkg defaults that can and might get overridden. if [ "$SAGE_DEBUG" = yes ]; then # Disable optimization, add debug symbols: - required_cflags="$required_cflags -g -O0" + required_cflags=$CFLAGS_NON_NATIVE echo >&2 "Warning: Building MPFR with SAGE_DEBUG=yes disables optimization." else # Add debug symbols by default, enable optimization, but do not (yet) # add processor-specific flags (these are eventually added later): - default_cflags="$default_cflags -g -O3" + default_cflags=$CFLAGS_O3 fi # Enabling thread-safe (which meanwhile is or at least may be the default) diff --git a/build/pkgs/mpir/spkg-install.in b/build/pkgs/mpir/spkg-install.in index 86b84036358..01070d1dc3e 100644 --- a/build/pkgs/mpir/spkg-install.in +++ b/build/pkgs/mpir/spkg-install.in @@ -49,16 +49,6 @@ if [ -z "$CFLAG64" ]; then fi -if [ "$SAGE_DEBUG" = yes ]; then - # Disable optimization, add debug symbols: - required_cflags="$required_cflags -g -O0" - echo >&2 "Warning: Building MPIR with SAGE_DEBUG=yes disables optimization." -else - # Add debug symbols by default - required_cflags="$required_cflags -g" -fi - - case "$UNAME" in SunOS) true;; # Auto-detect ABI diff --git a/build/pkgs/ncurses/spkg-install.in b/build/pkgs/ncurses/spkg-install.in index 4d4cfc18a6f..1f47e2f5493 100644 --- a/build/pkgs/ncurses/spkg-install.in +++ b/build/pkgs/ncurses/spkg-install.in @@ -1,23 +1,10 @@ DEBUG_CONFIGURE_FLAG='' if [ "$SAGE_DEBUG" = yes ]; then - CFLAGS="-O0 -g $CFLAGS" DEBUG_CONFIGURE_FLAG='--with-debug' else DEBUG_CONFIGURE_FLAG='--without-debug' fi - -echo "The following environment variables will be exported:" -echo "Using CC=$CC" -echo "Using CFLAGS=$CFLAGS" -echo "Using CPPFLAGS=$CPPFLAGS" -echo "Using LDFLAGS=$LDFLAGS" -echo - -export CFLAGS -export CPPFLAGS -export LDFLAGS - cd src # Ncurses cannot build narrow and wide (unicode, --enable-widec) diff --git a/build/pkgs/pari/spkg-check.in b/build/pkgs/pari/spkg-check.in index ae3aecb4a0a..9aaa5ff5fa0 100644 --- a/build/pkgs/pari/spkg-check.in +++ b/build/pkgs/pari/spkg-check.in @@ -2,15 +2,7 @@ ## PARI ########################################### -if [ "x$SAGE_DEBUG" = xyes ] ; then - CFLAGS="$CFLAGS -O0 -g" # Disable optimisation, add debug symbols. Good - # for debugging or working around compiler bugs. -else - CFLAGS="-O3 -g $CFLAGS" # Default optimisation, with debug symbols. - # Prepend to not override user's setting. -fi - -export CFLAGS +export CFLAGS=$CFLAGS_O3 cd src diff --git a/build/pkgs/pari/spkg-install.in b/build/pkgs/pari/spkg-install.in index d8896b62a18..3134aadb353 100644 --- a/build/pkgs/pari/spkg-install.in +++ b/build/pkgs/pari/spkg-install.in @@ -112,10 +112,9 @@ if [ $MACOSX_VERSION -ge 14 ]; then export MACOSX_DEPLOYMENT_TARGET=10.9 fi -# Set CFLAGS +export CFLAGS=$CFLAGS_O3 + if [ "$SAGE_DEBUG" = yes ]; then - # Disable optimisation, add debug symbols. - CFLAGS="-O0 -g $CFLAGS" # Compile kernel files with -O1 instead of -funroll-loops; -O0 gives # a segmentation fault on some OS X systems when doing @@ -123,15 +122,8 @@ if [ "$SAGE_DEBUG" = yes ]; then # See #13921, also reported upstream: # - http://pari.math.u-bordeaux.fr/archives/pari-dev-1301/msg00000.html PARI_MAKEFLAGS="KERNELCFLAGS=-O1 $PARI_MAKEFLAGS" -else - # Use PARI's default CFLAGS (with -g added). - # PARI's Configure adds -O3 to the CFLAGS, so we don't need to add - # it explicitly. - CFLAGS="-g $CFLAGS" fi -export CFLAGS - # Build PARI/GP # Configure PARI/GP, forcing bash instead of /bin/sh. It is not diff --git a/build/pkgs/r/spkg-install.in b/build/pkgs/r/spkg-install.in index d77db37688d..b3dea4c5539 100644 --- a/build/pkgs/r/spkg-install.in +++ b/build/pkgs/r/spkg-install.in @@ -7,14 +7,6 @@ unset GREP_OPTIONS # and cannot be used to pass this path. CPPFLAGS="$CPPFLAGS" -# Optimization flags -if [ "$SAGE_DEBUG" = yes ]; then - CFLAGS="-g -O0 $CFLAGS" - FCFLAGS="-g -O0 $FCFLAGS" -else - CFLAGS="-g -O2 $CFLAGS" - FCFLAGS="-g -O2 $FCFLAGS" -fi # #29170: Compilation errors caused by a silently failing configure check # "for type of 'hidden' Fortran character lengths" # on ubuntu-bionic-minimal, ubuntu-eoan/focal-minimal, debian-buster/bullseye/sid-minimal, diff --git a/build/pkgs/readline/spkg-install.in b/build/pkgs/readline/spkg-install.in index 6bdbc9a5cd0..126c4372169 100644 --- a/build/pkgs/readline/spkg-install.in +++ b/build/pkgs/readline/spkg-install.in @@ -1,21 +1,3 @@ -if [[ $SAGE_DEBUG = yes ]]; then - CFLAGS="$CFLAGS -g -O0" -else - CFLAGS="-g -O2 $CFLAGS" -fi - -echo "The following environment variables will be exported:" -echo "Using CC=$CC" -echo "Using CFLAGS=$CFLAGS" -echo "Using CPPFLAGS=$CPPFLAGS" -echo "Using LDFLAGS=$LDFLAGS" -echo "Configure scripts and/or makefiles might override these later." - -export CC -export CFLAGS -export CPPFLAGS -export LDFLAGS - cd src/ sdh_configure --with-curses --enable-shared --disable-static diff --git a/build/pkgs/rubiks/spkg-install.in b/build/pkgs/rubiks/spkg-install.in index 3ff0398d063..e03c76e432a 100644 --- a/build/pkgs/rubiks/spkg-install.in +++ b/build/pkgs/rubiks/spkg-install.in @@ -2,13 +2,11 @@ ## rubiks ########################################### -# Add a sensible default optimisation flag. Change if necessary. -OPTIMIZATION_FLAGS="-O2" # Work around a bug in gcc 4.6.0: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48702 if [ "`testcc.sh $CC`" = GCC ] ; then if $CC -dumpversion 2>/dev/null |grep >/dev/null '^4\.6\.[01]$' ; then echo "Warning: Working around bug in gcc 4.6.0" - OPTIMIZATION_FLAGS="$OPTIMIZATION_FLAGS -fno-ivopts" + EXTRA_FLAG="-fno-ivopts" fi fi @@ -16,28 +14,14 @@ fi # But it is better to do them all each time, rather than ommit # a flag by mistake. -CFLAGS="$CFLAGS $OPTIMIZATION_FLAGS " -CXXFLAGS="$CXXFLAGS $OPTIMIZATION_FLAGS " -FCFLAGS="$FCFLAGS $OPTIMIZATION_FLAGS " -F77FLAGS="$F77FLAGS $OPTIMIZATION_FLAGS " - -# If SAGE_DEBUG is set either unset (the default), or set to 'yes' -# Add debugging information. -# Since both the Sun and GNU compilers accept -g to give debugging information -# there is no need to do anything specific to one compiler or the other. - -if [ "x$SAGE_DEBUG" = "x" ] || [ "x$SAGE_DEBUG" = "xyes" ] ; then - echo "Code will be built with debugging information present. Set 'SAGE_DEBUG' to 'no' if you don't want that." - # Actually anything other than 'yes' will cause - # no debugging information to be added. - CFLAGS="$CFLAGS -g " - CXXFLAGS="$CXXFLAGS -g " - FCFLAGS="$FCFLAGS -g " - F77FLAGS="$F77FLAGS -g " -else - echo "No debugging information will be used during the build of this package" - echo "Unset SAGE_DEBUG if you want debugging information present (-g added)" -fi +export CFLAGS="$CFLAGS $EXTRA_FLAG" +export CXXFLAGS="$CXXFLAGS $EXTRA_FLAG" +export FCFLAGS="$FCFLAGS $EXTRA_FLAG" +export F77FLAGS="$F77FLAGS $EXTRA_FLAG" +export CPPFLAGS +export LDFLAGS +export ABI +export CPPFLAGS # These are all used by GNU to specify compilers. echo "Using CC=$CC" @@ -57,16 +41,6 @@ echo "Using ABI=$ABI" echo "configure scripts and/or makefiles might override these later" echo " " -# export everything. Probably not necessary in most cases. -export CFLAGS -export CXXFLAGS -export FCFLAGS -export F77FLAGS -export CPPFLAGS -export LDFLAGS -export ABI -export CPPFLAGS - # End of pretty general spkg-install file. # Now do the specific things needed for this package (rubiks) diff --git a/build/pkgs/singular/spkg-install.in b/build/pkgs/singular/spkg-install.in index 75306d57805..a9be7bfaa54 100644 --- a/build/pkgs/singular/spkg-install.in +++ b/build/pkgs/singular/spkg-install.in @@ -9,18 +9,8 @@ if [ "x$SAGE_DEBUG" = "xyes" ]; then # This used to disable omalloc but that is not really supported # by upstream SINGULAR_CONFIGURE="$SINGULAR_CONFIGURE --enable-debug --disable-optimizationflags" - - CFLAGS="$CFLAGS -O0 -g" - CXXFLAGS="$CXXFLAGS -O0 -g" -else - # Singular 4.x (mostly) does not longer set defaults for CFLAGS and CXXFLAGS - CFLAGS="-O2 -g $CFLAGS" - CXXFLAGS="-O2 -g $CXXFLAGS" fi -export CFLAGS CXXFLAGS - - remove_old_version() { # the following is a little verbose but it ensures we leave no trace of 3.x diff --git a/build/pkgs/sqlite/spkg-install.in b/build/pkgs/sqlite/spkg-install.in index 3cca459dae3..f20e4ecdb23 100644 --- a/build/pkgs/sqlite/spkg-install.in +++ b/build/pkgs/sqlite/spkg-install.in @@ -6,15 +6,7 @@ cd src cp "$SAGE_ROOT"/config/config.* . -# Build with -O0 if debugging requested -if [ "$SAGE_DEBUG" = "yes" ]; then - CFLAGS="-g -O0 $CFLAGS" -else - CFLAGS="-g -O2 $CFLAGS" -fi - export CPPFLAGS="$CPPFLAGS -I$SAGE_LOCAL/include" -export CFLAGS # Old OS X systems need -DSQLITE_WITHOUT_ZONEMALLOC if uname -sr |grep 'Darwin [0-8][.]' >/dev/null; then diff --git a/build/pkgs/sympow/spkg-install.in b/build/pkgs/sympow/spkg-install.in index 8fe518f2d04..af47bbf6ac3 100644 --- a/build/pkgs/sympow/spkg-install.in +++ b/build/pkgs/sympow/spkg-install.in @@ -38,6 +38,8 @@ try_add_CFLAG() return 2 } +CFLAGS=$ORIGINAL_CFLAGS + # These flags never hurt, so add them if possible for FLAG in '-fno-fast-math' '-mfpmath=sse' '-Dx86'; do try_add_CFLAG $FLAG diff --git a/build/pkgs/zn_poly/spkg-check.in b/build/pkgs/zn_poly/spkg-check.in index 299ac7a6b8a..c7831aed276 100644 --- a/build/pkgs/zn_poly/spkg-check.in +++ b/build/pkgs/zn_poly/spkg-check.in @@ -8,14 +8,8 @@ # Set up environment variables: ############################################################################### -if [ "$SAGE_DEBUG" = yes ]; then - echo >&2 "Warning: Setting SAGE_DEBUG to 'yes' completely disables optimization." - CFLAGS="$CFLAGS -O0 -g -fPIC" - CXXFLAGS="$CXXFLAGS -O0 -g -fPIC" -else - CFLAGS="-O3 -g $CFLAGS -fPIC" - CXXFLAGS="-O3 -g $CXXFLAGS -fPIC" -fi +CFLAGS="$CFLAGS_O3 -fPIC" +CXXFLAGS="$CXXFLAGS_O3 -fPIC" # Work around a bug in GCC 4.7.0 which breaks the build on Itanium CPUs with # '-O3', '-O2' and '-O1' (cf. #12765, #12751, and the bug URL below.) diff --git a/build/pkgs/zn_poly/spkg-install.in b/build/pkgs/zn_poly/spkg-install.in index 169aef83d17..039986543ba 100644 --- a/build/pkgs/zn_poly/spkg-install.in +++ b/build/pkgs/zn_poly/spkg-install.in @@ -2,14 +2,8 @@ # Set up environment variables: ############################################################################### -if [ "$SAGE_DEBUG" = yes ]; then - echo >&2 "Warning: Setting SAGE_DEBUG to 'yes' completely disables optimization." - CFLAGS="-O0 -g $CFLAGS -fPIC" - CXXFLAGS="-O0 -g $CXXFLAGS -fPIC" -else - CFLAGS="-O3 -g $CFLAGS -fPIC" - CXXFLAGS="-O3 -g $CXXFLAGS -fPIC" -fi +CFLAGS="$CFLAGS_O3 -fPIC" +CXXFLAGS="$CXXFLAGS_O3 -fPIC" export CFLAGS CPPFLAGS CXXFLAGS LDFLAGS # Partially redundant, but safe. From 491621cd16389a31ac2a62bf37da3446f19f1d6e Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 15 Jun 2020 17:06:16 +0200 Subject: [PATCH 03/40] enable-fat-binary --- configure.ac | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure.ac b/configure.ac index fd54c080a37..6d501226920 100644 --- a/configure.ac +++ b/configure.ac @@ -84,6 +84,12 @@ if test "$enable_build_as_root" != yes; then AX_CHECK_ROOT([AC_MSG_ERROR([You cannot build Sage as root, switch to an unprivileged user. (If building in a container, use --enable-build-as-root.)])], []) fi +AC_ARG_ENABLE([fat-binary], + [AS_HELP_STRING([--enable-fat-binary], + [build binaries that will run on the widest range of target CPUs (but not relocatable)])], + [AC_SUBST(SAGE_FAT_BINARY, "yes")], + []) + # Check whether we are on a supported platform AC_CANONICAL_BUILD() AC_CANONICAL_HOST() From 38088b057c1fe4f19c86fac9133aad109612c1e7 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Tue, 16 Jun 2020 07:25:09 +0200 Subject: [PATCH 04/40] typo for iml --- build/pkgs/iml/spkg-install.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/iml/spkg-install.in b/build/pkgs/iml/spkg-install.in index 1c082006267..bb00b407a29 100644 --- a/build/pkgs/iml/spkg-install.in +++ b/build/pkgs/iml/spkg-install.in @@ -1,6 +1,6 @@ cd src -export CFLAGS=CFLAGS_O3 +export CFLAGS=$CFLAGS_O3 # When using GMP from a standard system location it shouldn't really # matter what we put here, but iml's configure script requires we From 2d5bba5e353128e80e3c1e3615286bf3e24eba72 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Thu, 18 Jun 2020 00:38:11 +0200 Subject: [PATCH 05/40] copy/paste typo --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 6d501226920..367650a3ced 100644 --- a/configure.ac +++ b/configure.ac @@ -318,8 +318,8 @@ AX_PROG_PERL_VERSION([5.8.0],[],[ ORIGINAL_CFLAGS="$CFLAGS" ORIGINAL_CXXFLAGS="$CXXFLAGS" -ORIGINAL_CXXFLAGS="$FCFLAGS" -ORIGINAL_CXXFLAGS="$F77FLAGS" +ORIGINAL_FCFLAGS="$FCFLAGS" +ORIGINAL_F77FLAGS="$F77FLAGS" AC_SUBST(ORIGINAL_CFLAGS) AC_SUBST(ORIGINAL_CXXFLAGS) AC_SUBST(ORIGINAL_FCFLAGS) From 8aae4979c90bf256b0408e395a71315675095943 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Thu, 18 Jun 2020 00:40:44 +0200 Subject: [PATCH 06/40] export configured compilation flags for build --- build/bin/sage-build-env-config.in | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index 01ba892dfd6..6eb6267f61b 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -22,6 +22,27 @@ # The configured CXX without special flags added that enable C++11 support export SAGE_CXX_WITHOUT_STD="@SAGE_CXX_WITHOUT_STD@" +# The configured compilation flags +export CFLAGS="@CFLAGS@" +export CXXFLAGS="@CXXFLAGS@" +export FCFLAGS="@FCFLAGS@" +export F77FLAGS="@F77FLAGS@" + +export CFLAGS_O3="@CFLAGS_O3@" +export CXXFLAGS_O3="@CXXFLAGS_O3@" +export FCFLAGS_O3="@FCFLAGS_O3@" +export F77FLAGS_O3="@F77FLAGS_O3@" + +export CFLAGS_NON_NATIVE="@CFLAGS_NON_NATIVE@" +export CXXFLAGS_NON_NATIVE="@CXXFLAGS_NON_NATIVE@" +export FCFLAGS_NON_NATIVE="@FCFLAGS_NON_NATIVE@" +export F77FLAGS_NON_NATIVE="@F77FLAGS_NON_NATIVE@" + +export ORIGINAL_CFLAGS="@ORIGINAL_CFLAGS@" +export ORIGINAL_CXXFLAGS="@ORIGINAL_CXXFLAGS@" +export ORIGINAL_FCFLAGS="@ORIGINAL_FCFLAGS@" +export ORIGINAL_F77FLAGS="@ORIGINAL_F77FLAGS@" + # This is usually blank if the system GMP is used, or $SAGE_LOCAL otherwise export SAGE_GMP_PREFIX="@SAGE_GMP_PREFIX@" export SAGE_GMP_INCLUDE="@SAGE_GMP_INCLUDE@" @@ -41,7 +62,7 @@ fi export SAGE_MPFR_PREFIX="@SAGE_MPFR_PREFIX@" if [ -n "$SAGE_MPFR_PREFIX" ]; then # Some packages that depend on MPFR accept a --with-mpfr= flag to - # their ./configure scripts. Thus we deal with this just as with GMP above. + # their ./configure scripts. Thus we deal with this just as with GMP above. export SAGE_CONFIGURE_MPFR="--with-mpfr=$SAGE_MPFR_PREFIX" fi @@ -50,7 +71,7 @@ fi export SAGE_MPC_PREFIX="@SAGE_MPC_PREFIX@" if [ -n "$SAGE_MPC_PREFIX" ]; then # Some packages that depend on MPC accept a --with-mpc= flag to - # their ./configure scripts. Thus we deal with this just as with GMP above. + # their ./configure scripts. Thus we deal with this just as with GMP above. export SAGE_CONFIGURE_MPC="--with-mpc=$SAGE_MPC_PREFIX" fi From caf0f6f4aabc1f1d1405db88c4d86904eef3450f Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Thu, 18 Jun 2020 08:00:51 +0200 Subject: [PATCH 07/40] O3 non native --- build/bin/sage-build-env-config.in | 5 +++++ configure.ac | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index 6eb6267f61b..9a51c8476f3 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -38,6 +38,11 @@ export CXXFLAGS_NON_NATIVE="@CXXFLAGS_NON_NATIVE@" export FCFLAGS_NON_NATIVE="@FCFLAGS_NON_NATIVE@" export F77FLAGS_NON_NATIVE="@F77FLAGS_NON_NATIVE@" +export CFLAGS_O3_NON_NATIVE="@CFLAGS_O3_NON_NATIVE@" +export CXXFLAGS_O3_NON_NATIVE="@CXXFLAGS_O3_NON_NATIVE@" +export FCFLAGS_O3_NON_NATIVE="@FCFLAGS_O3_NON_NATIVE@" +export F77FLAGS_O3_NON_NATIVE="@F77FLAGS_O3_NON_NATIVE@" + export ORIGINAL_CFLAGS="@ORIGINAL_CFLAGS@" export ORIGINAL_CXXFLAGS="@ORIGINAL_CXXFLAGS@" export ORIGINAL_FCFLAGS="@ORIGINAL_FCFLAGS@" diff --git a/configure.ac b/configure.ac index 367650a3ced..4b028b3fc04 100644 --- a/configure.ac +++ b/configure.ac @@ -367,7 +367,9 @@ AC_SUBST(OBJCXX) AS_IF([test "x$CXX" = x], [AC_MSG_ERROR([a C++ compiler is missing])]) CFLAGS_NON_NATIVE="${CFLAGS}" +CFLAGS_O3_NON_NATIVE="${CFLAGS_O3}" AC_SUBST(CFLAGS_NON_NATIVE) +AC_SUBST(CFLAGS_O3_NON_NATIVE) # Adding march native in certain cases. if test "x$SAGE_FAT_BINARY" != "xyes" ; then @@ -402,39 +404,48 @@ if test "x${CXXFLAGS}" = "x"; then CXXFLAGS="$CFLAGS" CXXFLAGS_O3="$CFLAGS_O3" CXXFLAGS_NON_NATIVE="$CFLAGS_NON_NATIVE" + CXXFLAGS_O3_NON_NATIVE="$CFLAGS_O3_NON_NATIVE" else CXXFLAGS_03="$CXXFLAGS" CXXFLAGS_NON_NATIVE="$CXXFLAGS" + CXXFLAGS_O3_NON_NATIVE="$CXXFLAGS" fi AC_SUBST(CXXFLAGS) AC_SUBST(CCXFLAGS_O3) AC_SUBST(CXXFLAGS_NON_NATIVE) +AC_SUBST(CXXFLAGS_O3_NON_NATIVE) # Copy to FCFLAGS, if this is not set. if test "x${FCFLAGS}" = "x"; then FCFLAGS="$CFLAGS" FCFLAGS_O3="$CFLAGS_O3" FCFLAGS_NON_NATIVE="$CFLAGS_NON_NATIVE" + FCFLAGS_O3_NON_NATIVE="$CFLAGS_O3_NON_NATIVE" else FCFLAGS_03="$FCFLAGS" FCFLAGS_NON_NATIVE="$FCFLAGS" + FCFLAGS_O3_NON_NATIVE="$FCFLAGS" fi AC_SUBST(FCFLAGS) AC_SUBST(FCFLAGS_O3) AC_SUBST(FCFLAGS_NON_NATIVE) +AC_SUBST(FCFLAGS_O3_NON_NATIVE) # Copy to F77FLAGS, if this is not set. if test "x${F77FLAGS}" = "x"; then F77FLAGS="$CFLAGS" F77FLAGS_O3="$CFLAGS_O3" F77FLAGS_NON_NATIVE="$CFLAGS_NON_NATIVE" + F77FLAGS_O3_NON_NATIVE="$CFLAGS_NON_NATIVE" else F77FLAGS_03="$FCFLAGS" F77FLAGS_NON_NATIVE="$FCFLAGS" + F77FLAGS_O3_NON_NATIVE="$FCFLAGS" fi AC_SUBST(F77FLAGS) AC_SUBST(F77FLAGS_O3) AC_SUBST(F77FLAGS_NON_NATIVE) +AC_SUBST(F77FLAGS_O3_NON_NATIVE) ############################################################################### From 1f42fc8803a45cb0c3d7dddfa571e1d815161d5a Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Thu, 18 Jun 2020 08:01:28 +0200 Subject: [PATCH 08/40] non-native for eclib --- build/pkgs/eclib/spkg-install.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/pkgs/eclib/spkg-install.in b/build/pkgs/eclib/spkg-install.in index 9ccc0420e34..1611cfdd27d 100644 --- a/build/pkgs/eclib/spkg-install.in +++ b/build/pkgs/eclib/spkg-install.in @@ -1,5 +1,5 @@ -CFLAGS="$CFLAGS_O3" -CXXFLAGS="$CXXFLAGS_O3" +CFLAGS="$CFLAGS_O3_NON_NATIVE" +CXXFLAGS="$CXXFLAGS_O3_NON_NATIVE" export CFLAGS CXXFLAGS From 0329e0dac0594db020330baaa7aee788454e97fc Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Thu, 18 Jun 2020 08:24:19 +0200 Subject: [PATCH 09/40] export SAGE_FAT_BINARY of configure --- build/bin/sage-build-env-config.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index 9a51c8476f3..019838a8863 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -48,6 +48,9 @@ export ORIGINAL_CXXFLAGS="@ORIGINAL_CXXFLAGS@" export ORIGINAL_FCFLAGS="@ORIGINAL_FCFLAGS@" export ORIGINAL_F77FLAGS="@ORIGINAL_F77FLAGS@" +# Export SAGE_FAT_BINARY if this was enabled during configure. +export SAGE_FAT_BINARY="@SAGE_FAT_BINARY@" + # This is usually blank if the system GMP is used, or $SAGE_LOCAL otherwise export SAGE_GMP_PREFIX="@SAGE_GMP_PREFIX@" export SAGE_GMP_INCLUDE="@SAGE_GMP_INCLUDE@" From 7399abd0955a7f5b65614c83a9428978ced5fe90 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 19 Jun 2020 11:21:53 +0200 Subject: [PATCH 10/40] r non-native --- build/pkgs/r/spkg-install.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/pkgs/r/spkg-install.in b/build/pkgs/r/spkg-install.in index b3dea4c5539..634a607c7ab 100644 --- a/build/pkgs/r/spkg-install.in +++ b/build/pkgs/r/spkg-install.in @@ -11,8 +11,8 @@ CPPFLAGS="$CPPFLAGS" # "for type of 'hidden' Fortran character lengths" # on ubuntu-bionic-minimal, ubuntu-eoan/focal-minimal, debian-buster/bullseye/sid-minimal, # linuxmint-19.3-minimal, archlinux-latest-minimal -CFLAGS="$CFLAGS -fPIC" -FCFLAGS="$FCFLAGS -fPIC" +CFLAGS="$CFLAGS_NON_NATIVE -fPIC" +FCFLAGS="$FCFLAGS_NON_NATIVE -fPIC" export CFLAGS CPPFLAGS FCFLAGS LDFLAGS From ceddbe1b24d52721c61858ccbef89fb0550181b4 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 19 Jun 2020 11:33:14 +0200 Subject: [PATCH 11/40] gap without native --- build/pkgs/gap/spkg-install.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/pkgs/gap/spkg-install.in b/build/pkgs/gap/spkg-install.in index 56e95338df1..c986e59da6d 100644 --- a/build/pkgs/gap/spkg-install.in +++ b/build/pkgs/gap/spkg-install.in @@ -4,6 +4,9 @@ cd src +export CFLAGS=$CFLAGS_NON_NATIVE +export CXXFLAGS=$CXXFLAGS_NON_NATIVE + GAP_BUILD_ROOT="$(pwd)" GAP_ROOT="$SAGE_LOCAL/share/gap" DESTDIR_GAP_ROOT="$SAGE_DESTDIR$GAP_ROOT" From 8ff40110dc5c896ba2c0a719b4b708e8f847daeb Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Tue, 23 Jun 2020 10:56:48 +0200 Subject: [PATCH 12/40] update documentation --- src/doc/en/developer/packaging.rst | 30 +++++++++++++++++++++++++++--- src/doc/en/installation/source.rst | 14 +++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/doc/en/developer/packaging.rst b/src/doc/en/developer/packaging.rst index e4852e843e8..b065cf8bfb7 100644 --- a/src/doc/en/developer/packaging.rst +++ b/src/doc/en/developer/packaging.rst @@ -248,6 +248,30 @@ something like the following to install it: sdh_install doc/ "$SAGE_SHARE"/doc/PACKAGE_NAME fi +At build time :envvar:`CFLAGS`, :envvar:`CXXFLAGS`, :envvar:`FCFLAGS`, +and :envvar:`F77FLAGS` are usually set to ``-g -O2 -march=native`` +(according to `debugging options <../installation/source.html#sage-debug>`_ +and whether building +`fat binaries <../installation/source.html#sage-fat-binary>`_). + +Slightly modified versions are available: + +.. CODE-BLOCK:: bash + + # No ``-march=native``. + export CFLAGS=$CFLAGS_NON_NATIVE + + # ``-O3`` instead of ``-O2``. + export CFLAGS=$CFLAGS_O3 + + # No ``-march=native`` and ``-O3`` instead of ``-O2``. + export CFLAGS=$CFLAGS_O3_NON_NATIVE + + # Use flags as set by the user, possibly empty. + export CFLAGS=$ORIGINAL_CFLAGS + +Likewise for :envvar:`CXXFLAGS`, :envvar:`FCFLAGS`, and :envvar:`F77FLAGS`. + .. note:: Prior to Sage 9.1, the script templates were called ``spkg-build``, @@ -619,7 +643,7 @@ For example, considering the layout: SAGE_ROOT/build/pkgs/foo |-- patches | |-- solaris - | | |-- solaris.patch + | | |-- solaris.patch | |-- bar.patch | `-- baz.patch @@ -674,7 +698,7 @@ When to patch, when to repackage, when to autoconfiscate - If the upstream Makefile does not build shared libraries, don't bother trying to patch it. - + Autoconfiscate the package instead and use the standard facilities of Automake and Libtool. This ensures that the shared library build is portable between Linux and macOS. @@ -718,7 +742,7 @@ We recommend the following workflow for maintaining a set of patches. rm -Rf SAGE_ROOT/build/pkgs/PACKAGE/patches mkdir SAGE_ROOT/build/pkgs/PACKAGE/patches git format-patch -o SAGE_ROOT/build/pkgs/PACKAGE/patches/ upstream - + - Optionally, create an ``spkg-src`` file in the Sage package's directory that regenerates the patch directory using the above commands. diff --git a/src/doc/en/installation/source.rst b/src/doc/en/installation/source.rst index 15c62c9cf60..7e0a5afb8c3 100644 --- a/src/doc/en/installation/source.rst +++ b/src/doc/en/installation/source.rst @@ -1171,7 +1171,9 @@ Here are some of the more commonly used variables affecting the build process: building ccache for Sage, so that Sage can pull down the necessary sources. -- :envvar:`SAGE_DEBUG` - controls debugging support. +- .. _sage_debug: + + :envvar:`SAGE_DEBUG` - controls debugging support. There are three different possible values: * Not set (or set to anything else than "yes" or "no"): build binaries with @@ -1188,6 +1190,9 @@ Here are some of the more commonly used variables affecting the build process: These will be notably slower but, for example, make it much easier to pinpoint memory allocation problems. + Instead of using :envvar:`SAGE_DEBUG` one can configure with + ``--enable-debug={no|symbols|yes}``. + - :envvar:`SAGE_PROFILE` - controls profiling support. If this is set to ``yes``, profiling support is enabled where possible. Note that Python-level profiling is always available; This option enables @@ -1276,9 +1281,12 @@ Here are some of the more commonly used variables affecting the build process: So you can set this variable to ``yes`` instead of using the ``-s`` flag for ``sage -i`` and ``sage -f``. -- :envvar:`SAGE_FAT_BINARY` - to build binaries that will run on the +- .. _sage_fat_binary: + + :envvar:`SAGE_FAT_BINARY` - to build binaries that will run on the widest range of target CPUs set this variable to ``yes`` before - building Sage. This does not make the binaries relocatable, it only + building Sage or configure with ``--enable-fat-binary``. + This does not make the binaries relocatable, it only avoids newer CPU instruction set extensions. For relocatable (=can be moved to a different directory) binaries, you must use https://github.com/sagemath/binary-pkg From df53cf3187dc4ad937e4a0ca48bc034a4dcad9ae Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Tue, 23 Jun 2020 11:25:24 +0200 Subject: [PATCH 13/40] --enable-debug as configuration option --- configure.ac | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4b028b3fc04..27bf142eb95 100644 --- a/configure.ac +++ b/configure.ac @@ -90,6 +90,12 @@ AC_ARG_ENABLE([fat-binary], [AC_SUBST(SAGE_FAT_BINARY, "yes")], []) +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug={no|symbols|yes}], + [controls debugging support: "no" debugging; debugging "symbols" (default); build debug version ("yes")])], + [AC_SUBST(SAGE_DEBUG, $enableval)], + []) + # Check whether we are on a supported platform AC_CANONICAL_BUILD() AC_CANONICAL_HOST() @@ -333,7 +339,7 @@ if test "x${CFLAGS}" = "x"; then CFLAGS="-Og -g" CFLAGS_O3="-Og -g" else - if test "x$SAGE_DEBUG" = "no" ; then + if test "x$SAGE_DEBUG" = "xno" ; then CFLAGS="-O2" CFLAGS_O3="-O3" else From 6fd7ba74376c2ce09e150ac548ead5b138eadee0 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Tue, 23 Jun 2020 13:55:14 +0200 Subject: [PATCH 14/40] move to buil/spkg/{gcc,gfortran}/spkg-configure.ac --- build/pkgs/gcc/spkg-configure.m4 | 89 ++++++++++- build/pkgs/gfortran/spkg-configure.m4 | 28 ++++ configure.ac | 203 +++++--------------------- 3 files changed, 148 insertions(+), 172 deletions(-) diff --git a/build/pkgs/gcc/spkg-configure.m4 b/build/pkgs/gcc/spkg-configure.m4 index a358b37498d..6ea5260ab3b 100644 --- a/build/pkgs/gcc/spkg-configure.m4 +++ b/build/pkgs/gcc/spkg-configure.m4 @@ -49,13 +49,32 @@ AC_DEFUN([SAGE_CHECK_BROKEN_GCC], [ fi ]) +dnl Save the flags as configured by the user. +AC_DEFUN([SAGE_SAVE_ORIGINAL_FLAGS], [ + AC_SUBST(ORIGINAL_CFLAGS, "$CFLAGS") + AC_SUBST(ORIGINAL_CXXFLAGS, "$CXXFLAGS") + AC_SUBST(ORIGINAL_FCFLAGS, "$FCFLAGS") + AC_SUBST(ORIGINAL_F77FLAGS, "$F77FLAGS") +]) SAGE_SPKG_CONFIGURE_BASE([gcc], [ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_PROG_CPP]) - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([AC_PROG_OBJC]) - AC_REQUIRE([AC_PROG_OBJCXX]) + AC_REQUIRE([SAGE_SAVE_ORIGINAL_FLAGS]) + + AC_REQUIRE([SAGE_CHECK_CONDA_COMPILERS]) + + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_PROG_CPP]) + AC_REQUIRE([AC_PROG_CXX]) + + AC_SUBST(CC) + AC_SUBST(FC) + + AC_REQUIRE([AC_PROG_OBJC]) + AC_REQUIRE([AC_PROG_OBJCXX]) + AC_SUBST(OBJC) + AC_SUBST(OBJCXX) + + AS_IF([test "x$CXX" = x], [AC_MSG_ERROR([a C++ compiler is missing])]) if test -f "$SAGE_LOCAL/bin/gcc"; then # Special value for SAGE_INSTALL_GCC if GCC is already installed @@ -151,6 +170,10 @@ SAGE_SPKG_CONFIGURE_BASE([gcc], [ # Install our own GCC if the system-provided one is newer than 9.x. # See https://trac.sagemath.org/ticket/29456 SAGE_SHOULD_INSTALL_GCC([$CXX is g++ version $GXX_VERSION, which is too recent for this version of Sage]) + ], + [4.[[8-9]].*|5.[[0-1]].*], [ + # GCC less than 5.1 is not ready for AVX512. + sage_use_march_native=no ]) fi @@ -201,6 +224,62 @@ SAGE_SPKG_CONFIGURE_BASE([gcc], [ SAGE_SRC="$SAGE_SRC" ]) fi + + # Determine which compiler flags should be set. + if test "x$sage_use_march_native" = "xno"; then + march="" + elif test "x$SAGE_FAT_BINARY" = "xyes"; then + march="" + elif test "x$SAGE_DEBUG" = "xyes"; then + march="" + elif test "x$sage_spkg_install_gcc" =" xyes"; then + march=" -march=native" + else + AX_CHECK_COMPILE_FLAG("-march=native", [march=" -march=native"], [march=""], [], []) + fi + + if test "x$ORIGINAL_CFLAGS" = "x"; then + # Evaluate SAGE_DEBUG: + if test "x$SAGE_DEBUG" = "xyes" ; then + AC_SUBST(CFLAGS_NON_NATIVE, "-Og -g") + AC_SUBST(CFLAGS_O3_NON_NATIVE, "-Og -g") + else + if test "x$SAGE_DEBUG" = "xno" ; then + AC_SUBST(CFLAGS_NON_NATIVE, "-O2") + AC_SUBST(CFLAGS_O3_NON_NATIVE, "-O3") + else + AC_SUBST(CFLAGS_NON_NATIVE, "-O2 -g") + AC_SUBST(CFLAGS_O3_NON_NATIVE, "-O3 -g") + fi + fi + AC_SUBST(CFLAGS, "${CFLAGS_NON_NATIVE}${march}") + AC_SUBST(CFLAGS_O3, "${CFLAGS_O3_NON_NATIVE}${march}") + else + # Respect user environment variable. + AC_SUBST(CFLAGS, "${CFLAGS}") + AC_SUBST(CFLAGS_O3, "${CFLAGS}") + AC_SUBST(CFLAGS_NON_NATIVE, "${CFLAGS}") + AC_SUBST(CFLAGS_O3_NON_NATIVE, "${CFLAGS}") + fi + + AC_MSG_NOTICE(ORIGINAL_CFLAGS=$ORIGINAL_CFLAGS) + AC_MSG_NOTICE(CFLAGS=$CFLAGS) + AC_MSG_NOTICE(CFLAGS_O3=$CFLAGS_O3) + AC_MSG_NOTICE(CFLAGS_NON_NATIVE=$CFLAGS_NON_NATIVE) + AC_MSG_NOTICE(CFLAGS_O3_NON_NATIVE=$CFLAGS_O3_NON_NATIVE) + + # Copy to CXXFLAGS if this is not set. + if test "x$CXXFLAGS" = "x"; then + AC_SUBST(CXXFLAGS, "$CFLAGS") + AC_SUBST(CXXFLAGS_O3, "$CFLAGS_O3") + AC_SUBST(CXXFLAGS_NON_NATIVE, "$CFLAGS_NON_NATIVE") + AC_SUBST(CXXFLAGS_O3_NON_NATIVE, "$CFLAGS_O3_NON_NATIVE") + else + AC_SUBST(CXXFLAGS_03, "$CXXFLAGS") + AC_SUBST(CXXFLAGS_NON_NATIVE, "$CXXFLAGS") + AC_SUBST(CXXFLAGS_O3_NON_NATIVE, "$CXXFLAGS") + fi + ], , , [ # Trac #27907: Find location of crti.o from the system CC, in case we build our own gcc AC_MSG_CHECKING([for the location of crti.o]) diff --git a/build/pkgs/gfortran/spkg-configure.m4 b/build/pkgs/gfortran/spkg-configure.m4 index d75bbca9be5..09c0f99dbd2 100644 --- a/build/pkgs/gfortran/spkg-configure.m4 +++ b/build/pkgs/gfortran/spkg-configure.m4 @@ -1,6 +1,9 @@ SAGE_SPKG_CONFIGURE([gfortran], [ AC_REQUIRE([SAGE_SPKG_CONFIGURE_GCC]) + AC_REQUIRE([AC_PROG_FC]) + AC_SUBST(FC) + # Check that the Fortran compiler accepts free-format source code (as # opposed to the older fixed-format style from Fortran 77). # This helps verify the compiler works too, so if some idiot sets FC to @@ -21,4 +24,29 @@ SAGE_SPKG_CONFIGURE([gfortran], [ if test "x$sage_spkg_install_gcc" = "xyes" -o x$SAGE_INSTALL_GCC = xexists; then sage_spkg_install_gfortran=no fi + + # Copy CFLAGS to FCFLAGS if this is not set. + if test "x$FCFLAGS" = "x"; then + AC_SUBST(FCFLAGS, "$CFLAGS") + AC_SUBST(FCFLAGS_O3, "$CFLAGS_O3") + AC_SUBST(FCFLAGS_NON_NATIVE, "$CFLAGS_NON_NATIVE") + AC_SUBST(FCFLAGS_O3_NON_NATIVE, "$CFLAGS_O3_NON_NATIVE") + else + AC_SUBST(FCFLAGS_03, "$FCFLAGS") + AC_SUBST(FCFLAGS_NON_NATIVE, "$FCFLAGS") + AC_SUBST(FCFLAGS_O3_NON_NATIVE, "$FCFLAGS") + fi + + # Copy FCFLAGS to F77FLAGS if this is not set. + if test "x$F77FLAGS" = "x"; then + AC_SUBST(F77FLAGS, "$FCFLAGS") + AC_SUBST(F77FLAGS_O3, "$FCFLAGS_O3") + AC_SUBST(F77FLAGS_NON_NATIVE, "$FCFLAGS_NON_NATIVE") + AC_SUBST(F77FLAGS_O3_NON_NATIVE, "$FCFLAGS_O3_NON_NATIVE") + else + AC_SUBST(F77FLAGS_03, "$F77FLAGS") + AC_SUBST(F77FLAGS_NON_NATIVE, "$F77FLAGS") + AC_SUBST(F77FLAGS_O3_NON_NATIVE, "$F77FLAGS") + fi + ]) diff --git a/configure.ac b/configure.ac index 27bf142eb95..48f917fbb00 100644 --- a/configure.ac +++ b/configure.ac @@ -319,139 +319,48 @@ AX_PROG_PERL_VERSION([5.8.0],[],[ ############################################################################### -# Check C/C++/Fortran compilers and set CFLAGS +# Collect packages and check C/C++/Fortran compilers ############################################################################### -ORIGINAL_CFLAGS="$CFLAGS" -ORIGINAL_CXXFLAGS="$CXXFLAGS" -ORIGINAL_FCFLAGS="$FCFLAGS" -ORIGINAL_F77FLAGS="$F77FLAGS" -AC_SUBST(ORIGINAL_CFLAGS) -AC_SUBST(ORIGINAL_CXXFLAGS) -AC_SUBST(ORIGINAL_FCFLAGS) -AC_SUBST(ORIGINAL_F77FLAGS) - -if test "x${CFLAGS}" = "x"; then - GOT_FLAGS="no" - - # Evaluate SAGE_DEBUG: - if test "x$SAGE_DEBUG" = "xyes" ; then - CFLAGS="-Og -g" - CFLAGS_O3="-Og -g" - else - if test "x$SAGE_DEBUG" = "xno" ; then - CFLAGS="-O2" - CFLAGS_O3="-O3" - else - CFLAGS="-O2 -g" - CFLAGS_O3="-O3 -g" - fi - fi -else - GOT_FLAGS="yes" - CFLAGS_O3="${CFLAGS}" +# Python version +AC_ARG_WITH([python], +[AS_HELP_STRING([--with-python=3], + [build and use Python 3 (default)])]) + +case "$with_python" in + 3) SAGE_PYTHON_VERSION=3;; + 3*) AC_MSG_WARN([the only allowed value for --with-python is 3; specific Python 3.x versions cannot be requested using --with-python. For compatibility reasons, this is only a warning. Use './configure PYTHON3=/path/to/python3' to use a specific Python 3 binary for the Sage venv.]) + SAGE_PYTHON_VERSION=3;; + "") SAGE_PYTHON_VERSION=3;; + *) + AC_MSG_ERROR([the only allowed value for --with-python is 3. Support for Python 2 has been removed in Sage 9.2.]);; +esac +AC_SUBST(SAGE_PYTHON_VERSION) + +# $(TOOLCHAIN) variable containing prerequisites for the build +SAGE_TOOLCHAIN=gcc +if test "$SAGE_INSTALL_CCACHE" = yes ; then + SAGE_TOOLCHAIN="$SAGE_TOOLCHAIN ccache" fi +AC_SUBST([SAGE_TOOLCHAIN]) -SAGE_CHECK_CONDA_COMPILERS - -AC_PROG_CC() -AC_PROG_CPP() -AC_PROG_CXX() -AC_PROG_FC() - -AC_SUBST(CC) -AC_SUBST(FC) - -# On darwin, also set the objective C/C++ compilers -# Checking on all platforms doesn't hurt and stops -# configure from sending an error when run on non-darwin. -AC_PROG_OBJC() -AC_PROG_OBJCXX() -AC_SUBST(OBJC) -AC_SUBST(OBJCXX) - -AS_IF([test "x$CXX" = x], [AC_MSG_ERROR([a C++ compiler is missing])]) - -CFLAGS_NON_NATIVE="${CFLAGS}" -CFLAGS_O3_NON_NATIVE="${CFLAGS_O3}" -AC_SUBST(CFLAGS_NON_NATIVE) -AC_SUBST(CFLAGS_O3_NON_NATIVE) - -# Adding march native in certain cases. -if test "x$SAGE_FAT_BINARY" != "xyes" ; then - if test "x$GOT_FLAGS" = "xno"; then - - # GCC less than 5.1 is not yet ready for "-march=native", - # but it claims it is. - GCC_LT_51="no" - if test "x$GCC" = "xyes"; then - GCC_GTE_51=$(expr `${CC} --version | grep ^gcc | sed 's/^.* //g' | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$/&00/'` \>= 50100) - if test "x$GCC_GTE_51" = "x0"; then - GCC_LT_51="yes" - fi - fi +AC_ARG_ENABLE([experimental-packages], + [AS_HELP_STRING([--enable-experimental-packages], + [allow installing experimental packages (default: no = ask for user confirmation for each package)])]) +AC_ARG_ENABLE([download-from-upstream-url], + [AS_HELP_STRING([--enable-download-from-upstream-url], + [allow downloading packages from their upstream URL if they cannot be found on the Sage mirrors])]) - if test "x$GCC_LT_51" = "xno"; then - AX_CHECK_COMPILE_FLAG("-march=native", [MARCH=" -march=native"], [MARCH=""], [], []) - CFLAGS="${CFLAGS}${MARCH}" - CFLAGS_O3="${CFLAGS_O3}${MARCH}" - fi +SAGE_SPKG_OPTIONS="" +AS_IF([test "x$enable_experimental_packages" = "xyes"], [ + AS_VAR_APPEND([SAGE_SPKG_OPTIONS], [" -y"]) +]) +AS_IF([test "x$enable_download_from_upstream_url" = "xyes"], [ + AS_VAR_APPEND([SAGE_SPKG_OPTIONS], [" -o"]) +]) +AC_SUBST([SAGE_SPKG_OPTIONS]) - fi -fi -AC_SUBST(CFLAGS) -AC_SUBST(CFLAGS_O3) -AC_MSG_NOTICE(CFLAGS_NON_NATIVE=$CFLAGS_NON_NATIVE) -AC_MSG_NOTICE(CFLAGS=$CFLAGS) -AC_MSG_NOTICE(CFLAGS_O3=$CFLAGS_O3) - -# Copy to CXXFLAGS, if this is not set. -if test "x${CXXFLAGS}" = "x"; then - CXXFLAGS="$CFLAGS" - CXXFLAGS_O3="$CFLAGS_O3" - CXXFLAGS_NON_NATIVE="$CFLAGS_NON_NATIVE" - CXXFLAGS_O3_NON_NATIVE="$CFLAGS_O3_NON_NATIVE" -else - CXXFLAGS_03="$CXXFLAGS" - CXXFLAGS_NON_NATIVE="$CXXFLAGS" - CXXFLAGS_O3_NON_NATIVE="$CXXFLAGS" -fi -AC_SUBST(CXXFLAGS) -AC_SUBST(CCXFLAGS_O3) -AC_SUBST(CXXFLAGS_NON_NATIVE) -AC_SUBST(CXXFLAGS_O3_NON_NATIVE) - -# Copy to FCFLAGS, if this is not set. -if test "x${FCFLAGS}" = "x"; then - FCFLAGS="$CFLAGS" - FCFLAGS_O3="$CFLAGS_O3" - FCFLAGS_NON_NATIVE="$CFLAGS_NON_NATIVE" - FCFLAGS_O3_NON_NATIVE="$CFLAGS_O3_NON_NATIVE" -else - FCFLAGS_03="$FCFLAGS" - FCFLAGS_NON_NATIVE="$FCFLAGS" - FCFLAGS_O3_NON_NATIVE="$FCFLAGS" -fi -AC_SUBST(FCFLAGS) -AC_SUBST(FCFLAGS_O3) -AC_SUBST(FCFLAGS_NON_NATIVE) -AC_SUBST(FCFLAGS_O3_NON_NATIVE) - -# Copy to F77FLAGS, if this is not set. -if test "x${F77FLAGS}" = "x"; then - F77FLAGS="$CFLAGS" - F77FLAGS_O3="$CFLAGS_O3" - F77FLAGS_NON_NATIVE="$CFLAGS_NON_NATIVE" - F77FLAGS_O3_NON_NATIVE="$CFLAGS_NON_NATIVE" -else - F77FLAGS_03="$FCFLAGS" - F77FLAGS_NON_NATIVE="$FCFLAGS" - F77FLAGS_O3_NON_NATIVE="$FCFLAGS" -fi -AC_SUBST(F77FLAGS) -AC_SUBST(F77FLAGS_O3) -AC_SUBST(F77FLAGS_NON_NATIVE) -AC_SUBST(F77FLAGS_O3_NON_NATIVE) +SAGE_SPKG_COLLECT() ############################################################################### @@ -500,46 +409,6 @@ SAGE_CHECK_OSX_SUPPORTED() # Collect substitutions for build/make/Makefile.in ############################################################################### -# Python version -AC_ARG_WITH([python], -[AS_HELP_STRING([--with-python=3], - [build and use Python 3 (default)])]) - -case "$with_python" in - 3) SAGE_PYTHON_VERSION=3;; - 3*) AC_MSG_WARN([the only allowed value for --with-python is 3; specific Python 3.x versions cannot be requested using --with-python. For compatibility reasons, this is only a warning. Use './configure PYTHON3=/path/to/python3' to use a specific Python 3 binary for the Sage venv.]) - SAGE_PYTHON_VERSION=3;; - "") SAGE_PYTHON_VERSION=3;; - *) - AC_MSG_ERROR([the only allowed value for --with-python is 3. Support for Python 2 has been removed in Sage 9.2.]);; -esac -AC_SUBST(SAGE_PYTHON_VERSION) - -# $(TOOLCHAIN) variable containing prerequisites for the build -SAGE_TOOLCHAIN=gcc -if test "$SAGE_INSTALL_CCACHE" = yes ; then - SAGE_TOOLCHAIN="$SAGE_TOOLCHAIN ccache" -fi -AC_SUBST([SAGE_TOOLCHAIN]) - -AC_ARG_ENABLE([experimental-packages], - [AS_HELP_STRING([--enable-experimental-packages], - [allow installing experimental packages (default: no = ask for user confirmation for each package)])]) -AC_ARG_ENABLE([download-from-upstream-url], - [AS_HELP_STRING([--enable-download-from-upstream-url], - [allow downloading packages from their upstream URL if they cannot be found on the Sage mirrors])]) - -SAGE_SPKG_OPTIONS="" -AS_IF([test "x$enable_experimental_packages" = "xyes"], [ - AS_VAR_APPEND([SAGE_SPKG_OPTIONS], [" -y"]) -]) -AS_IF([test "x$enable_download_from_upstream_url" = "xyes"], [ - AS_VAR_APPEND([SAGE_SPKG_OPTIONS], [" -o"]) -]) -AC_SUBST([SAGE_SPKG_OPTIONS]) - -SAGE_SPKG_COLLECT() - # We need sage-env-config to exist before running this. # TODO: fix this in Trac #21524 touch "$SAGE_SRC/bin/sage-env-config" From 03b002a8beb5e757143ba142506382ebb8e9fe21 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Tue, 23 Jun 2020 14:02:14 +0200 Subject: [PATCH 15/40] disable native for gcc build --- build/pkgs/gcc/spkg-install.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/pkgs/gcc/spkg-install.in b/build/pkgs/gcc/spkg-install.in index 819a9caba59..f7c8db1de19 100644 --- a/build/pkgs/gcc/spkg-install.in +++ b/build/pkgs/gcc/spkg-install.in @@ -1,3 +1,7 @@ +# If we are building gcc ourselves, usually the system compiler isn't suitable. +export CFLAGS=$CFLAGS_NON_NATIVE +export CXXFLAGS=$CXXFLAGS_NON_NATIVE + # First, install any custom binaries or headers we created for macOS # workarounds for dir in bin include; do From 0660ab0573f27cd4c7bc2535e22f8f28ba812697 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Wed, 24 Jun 2020 08:02:52 +0200 Subject: [PATCH 16/40] partly undo reordering --- build/pkgs/gcc/spkg-configure.m4 | 27 ++------ build/pkgs/gfortran/spkg-configure.m4 | 19 +++-- configure.ac | 99 +++++++++++++++++---------- 3 files changed, 73 insertions(+), 72 deletions(-) diff --git a/build/pkgs/gcc/spkg-configure.m4 b/build/pkgs/gcc/spkg-configure.m4 index 6ea5260ab3b..9a2882e7e9e 100644 --- a/build/pkgs/gcc/spkg-configure.m4 +++ b/build/pkgs/gcc/spkg-configure.m4 @@ -49,32 +49,13 @@ AC_DEFUN([SAGE_CHECK_BROKEN_GCC], [ fi ]) -dnl Save the flags as configured by the user. -AC_DEFUN([SAGE_SAVE_ORIGINAL_FLAGS], [ - AC_SUBST(ORIGINAL_CFLAGS, "$CFLAGS") - AC_SUBST(ORIGINAL_CXXFLAGS, "$CXXFLAGS") - AC_SUBST(ORIGINAL_FCFLAGS, "$FCFLAGS") - AC_SUBST(ORIGINAL_F77FLAGS, "$F77FLAGS") -]) SAGE_SPKG_CONFIGURE_BASE([gcc], [ - AC_REQUIRE([SAGE_SAVE_ORIGINAL_FLAGS]) - - AC_REQUIRE([SAGE_CHECK_CONDA_COMPILERS]) - AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_PROG_CPP]) AC_REQUIRE([AC_PROG_CXX]) - - AC_SUBST(CC) - AC_SUBST(FC) - AC_REQUIRE([AC_PROG_OBJC]) AC_REQUIRE([AC_PROG_OBJCXX]) - AC_SUBST(OBJC) - AC_SUBST(OBJCXX) - - AS_IF([test "x$CXX" = x], [AC_MSG_ERROR([a C++ compiler is missing])]) if test -f "$SAGE_LOCAL/bin/gcc"; then # Special value for SAGE_INSTALL_GCC if GCC is already installed @@ -269,15 +250,15 @@ SAGE_SPKG_CONFIGURE_BASE([gcc], [ AC_MSG_NOTICE(CFLAGS_O3_NON_NATIVE=$CFLAGS_O3_NON_NATIVE) # Copy to CXXFLAGS if this is not set. - if test "x$CXXFLAGS" = "x"; then + if test "x$ORIGINAL_CXXFLAGS" = "x"; then AC_SUBST(CXXFLAGS, "$CFLAGS") AC_SUBST(CXXFLAGS_O3, "$CFLAGS_O3") AC_SUBST(CXXFLAGS_NON_NATIVE, "$CFLAGS_NON_NATIVE") AC_SUBST(CXXFLAGS_O3_NON_NATIVE, "$CFLAGS_O3_NON_NATIVE") else - AC_SUBST(CXXFLAGS_03, "$CXXFLAGS") - AC_SUBST(CXXFLAGS_NON_NATIVE, "$CXXFLAGS") - AC_SUBST(CXXFLAGS_O3_NON_NATIVE, "$CXXFLAGS") + AC_SUBST(CXXFLAGS_03, "$ORIGINAL_CXXFLAGS") + AC_SUBST(CXXFLAGS_NON_NATIVE, "$ORIGINAL_CXXFLAGS") + AC_SUBST(CXXFLAGS_O3_NON_NATIVE, "$ORIGINAL_CXXFLAGS") fi ], , , [ diff --git a/build/pkgs/gfortran/spkg-configure.m4 b/build/pkgs/gfortran/spkg-configure.m4 index 09c0f99dbd2..0bd2aa0f0f1 100644 --- a/build/pkgs/gfortran/spkg-configure.m4 +++ b/build/pkgs/gfortran/spkg-configure.m4 @@ -1,9 +1,6 @@ SAGE_SPKG_CONFIGURE([gfortran], [ AC_REQUIRE([SAGE_SPKG_CONFIGURE_GCC]) - AC_REQUIRE([AC_PROG_FC]) - AC_SUBST(FC) - # Check that the Fortran compiler accepts free-format source code (as # opposed to the older fixed-format style from Fortran 77). # This helps verify the compiler works too, so if some idiot sets FC to @@ -26,27 +23,27 @@ SAGE_SPKG_CONFIGURE([gfortran], [ fi # Copy CFLAGS to FCFLAGS if this is not set. - if test "x$FCFLAGS" = "x"; then + if test "x$ORIGINAL_FCFLAGS" = "x"; then AC_SUBST(FCFLAGS, "$CFLAGS") AC_SUBST(FCFLAGS_O3, "$CFLAGS_O3") AC_SUBST(FCFLAGS_NON_NATIVE, "$CFLAGS_NON_NATIVE") AC_SUBST(FCFLAGS_O3_NON_NATIVE, "$CFLAGS_O3_NON_NATIVE") else - AC_SUBST(FCFLAGS_03, "$FCFLAGS") - AC_SUBST(FCFLAGS_NON_NATIVE, "$FCFLAGS") - AC_SUBST(FCFLAGS_O3_NON_NATIVE, "$FCFLAGS") + AC_SUBST(FCFLAGS_03, "$ORIGINAL_FCFLAGS") + AC_SUBST(FCFLAGS_NON_NATIVE, "$ORIGINAL_FCFLAGS") + AC_SUBST(FCFLAGS_O3_NON_NATIVE, "$ORIGINAL_FCFLAGS") fi # Copy FCFLAGS to F77FLAGS if this is not set. - if test "x$F77FLAGS" = "x"; then + if test "x$ORIGINAL_F77FLAGS" = "x"; then AC_SUBST(F77FLAGS, "$FCFLAGS") AC_SUBST(F77FLAGS_O3, "$FCFLAGS_O3") AC_SUBST(F77FLAGS_NON_NATIVE, "$FCFLAGS_NON_NATIVE") AC_SUBST(F77FLAGS_O3_NON_NATIVE, "$FCFLAGS_O3_NON_NATIVE") else - AC_SUBST(F77FLAGS_03, "$F77FLAGS") - AC_SUBST(F77FLAGS_NON_NATIVE, "$F77FLAGS") - AC_SUBST(F77FLAGS_O3_NON_NATIVE, "$F77FLAGS") + AC_SUBST(F77FLAGS_03, "$ORIGINAL_F77FLAGS") + AC_SUBST(F77FLAGS_NON_NATIVE, "$ORIGINAL_F77FLAGS") + AC_SUBST(F77FLAGS_O3_NON_NATIVE, "$ORIGINAL_F77FLAGS") fi ]) diff --git a/configure.ac b/configure.ac index 48f917fbb00..e29c740c1cb 100644 --- a/configure.ac +++ b/configure.ac @@ -316,51 +316,35 @@ AX_PROG_PERL_VERSION([5.8.0],[],[ AC_MSG_ERROR([Exiting, since AC_PACKAGE_NAME requires perl-5.8.0 or later]) ]) - - ############################################################################### -# Collect packages and check C/C++/Fortran compilers +# Check C/C++/Fortran compilers ############################################################################### -# Python version -AC_ARG_WITH([python], -[AS_HELP_STRING([--with-python=3], - [build and use Python 3 (default)])]) +# Save compiler flags as configured by the user. +AC_SUBST(ORIGINAL_CFLAGS, "$CFLAGS") +AC_SUBST(ORIGINAL_CXXFLAGS, "$CXXFLAGS") +AC_SUBST(ORIGINAL_FCFLAGS, "$FCFLAGS") +AC_SUBST(ORIGINAL_F77FLAGS, "$F77FLAGS") -case "$with_python" in - 3) SAGE_PYTHON_VERSION=3;; - 3*) AC_MSG_WARN([the only allowed value for --with-python is 3; specific Python 3.x versions cannot be requested using --with-python. For compatibility reasons, this is only a warning. Use './configure PYTHON3=/path/to/python3' to use a specific Python 3 binary for the Sage venv.]) - SAGE_PYTHON_VERSION=3;; - "") SAGE_PYTHON_VERSION=3;; - *) - AC_MSG_ERROR([the only allowed value for --with-python is 3. Support for Python 2 has been removed in Sage 9.2.]);; -esac -AC_SUBST(SAGE_PYTHON_VERSION) +SAGE_CHECK_CONDA_COMPILERS -# $(TOOLCHAIN) variable containing prerequisites for the build -SAGE_TOOLCHAIN=gcc -if test "$SAGE_INSTALL_CCACHE" = yes ; then - SAGE_TOOLCHAIN="$SAGE_TOOLCHAIN ccache" -fi -AC_SUBST([SAGE_TOOLCHAIN]) +AC_PROG_CC() +AC_PROG_CPP() +AC_PROG_CXX() +AC_PROG_FC() -AC_ARG_ENABLE([experimental-packages], - [AS_HELP_STRING([--enable-experimental-packages], - [allow installing experimental packages (default: no = ask for user confirmation for each package)])]) -AC_ARG_ENABLE([download-from-upstream-url], - [AS_HELP_STRING([--enable-download-from-upstream-url], - [allow downloading packages from their upstream URL if they cannot be found on the Sage mirrors])]) +AC_SUBST(CC) +AC_SUBST(FC) -SAGE_SPKG_OPTIONS="" -AS_IF([test "x$enable_experimental_packages" = "xyes"], [ - AS_VAR_APPEND([SAGE_SPKG_OPTIONS], [" -y"]) -]) -AS_IF([test "x$enable_download_from_upstream_url" = "xyes"], [ - AS_VAR_APPEND([SAGE_SPKG_OPTIONS], [" -o"]) -]) -AC_SUBST([SAGE_SPKG_OPTIONS]) +# On darwin, also set the objective C/C++ compilers +# Checking on all platforms doesn't hurt and stops +# configure from sending an error when run on non-darwin. +AC_PROG_OBJC() +AC_PROG_OBJCXX() +AC_SUBST(OBJC) +AC_SUBST(OBJCXX) -SAGE_SPKG_COLLECT() +AS_IF([test "x$CXX" = x], [AC_MSG_ERROR([a C++ compiler is missing])]) ############################################################################### @@ -404,11 +388,50 @@ AS_IF([echo "$ac_pwd" |grep " " >/dev/null], SAGE_CHECK_OSX_SUPPORTED() - ############################################################################### # Collect substitutions for build/make/Makefile.in ############################################################################### +# Python version +AC_ARG_WITH([python], +[AS_HELP_STRING([--with-python=3], + [build and use Python 3 (default)])]) + +case "$with_python" in + 3) SAGE_PYTHON_VERSION=3;; + 3*) AC_MSG_WARN([the only allowed value for --with-python is 3; specific Python 3.x versions cannot be requested using --with-python. For compatibility reasons, this is only a warning. Use './configure PYTHON3=/path/to/python3' to use a specific Python 3 binary for the Sage venv.]) + SAGE_PYTHON_VERSION=3;; + "") SAGE_PYTHON_VERSION=3;; + *) + AC_MSG_ERROR([the only allowed value for --with-python is 3. Support for Python 2 has been removed in Sage 9.2.]);; +esac +AC_SUBST(SAGE_PYTHON_VERSION) + +# $(TOOLCHAIN) variable containing prerequisites for the build +SAGE_TOOLCHAIN=gcc +if test "$SAGE_INSTALL_CCACHE" = yes ; then + SAGE_TOOLCHAIN="$SAGE_TOOLCHAIN ccache" +fi +AC_SUBST([SAGE_TOOLCHAIN]) + +AC_ARG_ENABLE([experimental-packages], + [AS_HELP_STRING([--enable-experimental-packages], + [allow installing experimental packages (default: no = ask for user confirmation for each package)])]) +AC_ARG_ENABLE([download-from-upstream-url], + [AS_HELP_STRING([--enable-download-from-upstream-url], + [allow downloading packages from their upstream URL if they cannot be found on the Sage mirrors])]) + +SAGE_SPKG_OPTIONS="" +AS_IF([test "x$enable_experimental_packages" = "xyes"], [ + AS_VAR_APPEND([SAGE_SPKG_OPTIONS], [" -y"]) +]) +AS_IF([test "x$enable_download_from_upstream_url" = "xyes"], [ + AS_VAR_APPEND([SAGE_SPKG_OPTIONS], [" -o"]) +]) +AC_SUBST([SAGE_SPKG_OPTIONS]) + +SAGE_SPKG_COLLECT() + # We need sage-env-config to exist before running this. # TODO: fix this in Trac #21524 touch "$SAGE_SRC/bin/sage-env-config" From 5eba95a00f6febd2a4877de342cb57534457fc46 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 19 Jun 2020 11:33:14 +0200 Subject: [PATCH 17/40] pari without native --- build/pkgs/cypari/spkg-install.in | 2 ++ build/pkgs/cysignals/spkg-install.in | 2 ++ build/pkgs/giac/spkg-install.in | 4 ++-- build/pkgs/gp2c/spkg-install.in | 3 +++ build/pkgs/lcalc/spkg-install.in | 2 ++ build/pkgs/pari/spkg-install.in | 2 +- build/pkgs/pari_jupyter/spkg-install.in | 2 ++ 7 files changed, 14 insertions(+), 3 deletions(-) diff --git a/build/pkgs/cypari/spkg-install.in b/build/pkgs/cypari/spkg-install.in index deba1bb42bb..47b5e3cc60a 100644 --- a/build/pkgs/cypari/spkg-install.in +++ b/build/pkgs/cypari/spkg-install.in @@ -1 +1,3 @@ +export CFLAGS=$CFLAGS_NON_NATIVE + cd src && sdh_pip_install . diff --git a/build/pkgs/cysignals/spkg-install.in b/build/pkgs/cysignals/spkg-install.in index 0894611a27e..72c3ec9211d 100644 --- a/build/pkgs/cysignals/spkg-install.in +++ b/build/pkgs/cysignals/spkg-install.in @@ -1,5 +1,7 @@ cd src +export CFLAGS=$CFLAGS_NON_NATIVE + # #29473: Override -Wp,-D_FORTIFY_SOURCE from Fedora's python3. export CPPFLAGS="$CPPFLAGS -Wp,-U_FORTIFY_SOURCE" diff --git a/build/pkgs/giac/spkg-install.in b/build/pkgs/giac/spkg-install.in index d6a931b3b10..30d570bde97 100644 --- a/build/pkgs/giac/spkg-install.in +++ b/build/pkgs/giac/spkg-install.in @@ -8,8 +8,8 @@ ############################################################# # If CFLAGS and CXXFLAGS are unset, giac looks to set -g -O2, # but if they are not empty, the -g -O2 is not added -CFLAGS="-g -O2 $CFLAGS" -CXXFLAGS="-g -O2 $CXXFLAGS" +CFLAGS=$CFLAGS_NON_NATIVE +CXXFLAGS=$CXXFLAGS_NON_NATIVE CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS" if [ `uname -m` = "ppc64" ]; then diff --git a/build/pkgs/gp2c/spkg-install.in b/build/pkgs/gp2c/spkg-install.in index 85b4e2d320a..c3608e87e3f 100644 --- a/build/pkgs/gp2c/spkg-install.in +++ b/build/pkgs/gp2c/spkg-install.in @@ -1,4 +1,7 @@ cd src + +export CFLAGS=$CFLAGS_NON_NATIVE + sdh_configure --with-paricfg=$SAGE_PARI_CFG sdh_make sdh_make_install diff --git a/build/pkgs/lcalc/spkg-install.in b/build/pkgs/lcalc/spkg-install.in index 9000051aa58..381b3f53042 100644 --- a/build/pkgs/lcalc/spkg-install.in +++ b/build/pkgs/lcalc/spkg-install.in @@ -4,6 +4,8 @@ if [ "$UNAME" = "Darwin" ]; then export LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names" fi +CXXFLAGS=$CXXFLAGS_NON_NATIVE + # Using pari in a C++17 file with "using namespace std doesn't # work due to a conflict between std::rank and pari's rank CXXFLAGS=$(echo "${CXXFLAGS}" | sed "s/-std=c++17//g") diff --git a/build/pkgs/pari/spkg-install.in b/build/pkgs/pari/spkg-install.in index 3134aadb353..6ddea50d89f 100644 --- a/build/pkgs/pari/spkg-install.in +++ b/build/pkgs/pari/spkg-install.in @@ -112,7 +112,7 @@ if [ $MACOSX_VERSION -ge 14 ]; then export MACOSX_DEPLOYMENT_TARGET=10.9 fi -export CFLAGS=$CFLAGS_O3 +export CFLAGS=$CFLAGS_O3_NON_NATIVE if [ "$SAGE_DEBUG" = yes ]; then diff --git a/build/pkgs/pari_jupyter/spkg-install.in b/build/pkgs/pari_jupyter/spkg-install.in index deba1bb42bb..47b5e3cc60a 100644 --- a/build/pkgs/pari_jupyter/spkg-install.in +++ b/build/pkgs/pari_jupyter/spkg-install.in @@ -1 +1,3 @@ +export CFLAGS=$CFLAGS_NON_NATIVE + cd src && sdh_pip_install . From 1102ac17ca79aac13e6bc783fcf0081c94cfb9cd Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Sat, 20 Jun 2020 14:15:08 +0200 Subject: [PATCH 18/40] lcalc for real --- build/pkgs/lcalc/spkg-install.in | 1 + 1 file changed, 1 insertion(+) diff --git a/build/pkgs/lcalc/spkg-install.in b/build/pkgs/lcalc/spkg-install.in index 381b3f53042..e92fd335014 100644 --- a/build/pkgs/lcalc/spkg-install.in +++ b/build/pkgs/lcalc/spkg-install.in @@ -4,6 +4,7 @@ if [ "$UNAME" = "Darwin" ]; then export LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names" fi +export CFLAGS=$CFLAGS_NON_NATIVE CXXFLAGS=$CXXFLAGS_NON_NATIVE # Using pari in a C++17 file with "using namespace std doesn't From d412f066fbe964a19b104fe5ec0610501073e3cd Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 26 Jun 2020 22:49:07 +0200 Subject: [PATCH 19/40] Revert "lcalc for real" This reverts commit 863862679f6a9cba3476b515dbbfe22ed31a6571. --- build/pkgs/lcalc/spkg-install.in | 1 - 1 file changed, 1 deletion(-) diff --git a/build/pkgs/lcalc/spkg-install.in b/build/pkgs/lcalc/spkg-install.in index e92fd335014..381b3f53042 100644 --- a/build/pkgs/lcalc/spkg-install.in +++ b/build/pkgs/lcalc/spkg-install.in @@ -4,7 +4,6 @@ if [ "$UNAME" = "Darwin" ]; then export LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names" fi -export CFLAGS=$CFLAGS_NON_NATIVE CXXFLAGS=$CXXFLAGS_NON_NATIVE # Using pari in a C++17 file with "using namespace std doesn't From 453c97b3432f1c0d4760b26a8d2fa1842e3f88cc Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 26 Jun 2020 22:49:13 +0200 Subject: [PATCH 20/40] Revert "pari without native" This reverts commit 3a43cd163ae4961f3b5f34c3d02570671a409373. --- build/pkgs/cypari/spkg-install.in | 2 -- build/pkgs/cysignals/spkg-install.in | 2 -- build/pkgs/giac/spkg-install.in | 4 ++-- build/pkgs/gp2c/spkg-install.in | 3 --- build/pkgs/lcalc/spkg-install.in | 2 -- build/pkgs/pari/spkg-install.in | 2 +- build/pkgs/pari_jupyter/spkg-install.in | 2 -- 7 files changed, 3 insertions(+), 14 deletions(-) diff --git a/build/pkgs/cypari/spkg-install.in b/build/pkgs/cypari/spkg-install.in index 47b5e3cc60a..deba1bb42bb 100644 --- a/build/pkgs/cypari/spkg-install.in +++ b/build/pkgs/cypari/spkg-install.in @@ -1,3 +1 @@ -export CFLAGS=$CFLAGS_NON_NATIVE - cd src && sdh_pip_install . diff --git a/build/pkgs/cysignals/spkg-install.in b/build/pkgs/cysignals/spkg-install.in index 72c3ec9211d..0894611a27e 100644 --- a/build/pkgs/cysignals/spkg-install.in +++ b/build/pkgs/cysignals/spkg-install.in @@ -1,7 +1,5 @@ cd src -export CFLAGS=$CFLAGS_NON_NATIVE - # #29473: Override -Wp,-D_FORTIFY_SOURCE from Fedora's python3. export CPPFLAGS="$CPPFLAGS -Wp,-U_FORTIFY_SOURCE" diff --git a/build/pkgs/giac/spkg-install.in b/build/pkgs/giac/spkg-install.in index 30d570bde97..d6a931b3b10 100644 --- a/build/pkgs/giac/spkg-install.in +++ b/build/pkgs/giac/spkg-install.in @@ -8,8 +8,8 @@ ############################################################# # If CFLAGS and CXXFLAGS are unset, giac looks to set -g -O2, # but if they are not empty, the -g -O2 is not added -CFLAGS=$CFLAGS_NON_NATIVE -CXXFLAGS=$CXXFLAGS_NON_NATIVE +CFLAGS="-g -O2 $CFLAGS" +CXXFLAGS="-g -O2 $CXXFLAGS" CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS" if [ `uname -m` = "ppc64" ]; then diff --git a/build/pkgs/gp2c/spkg-install.in b/build/pkgs/gp2c/spkg-install.in index c3608e87e3f..85b4e2d320a 100644 --- a/build/pkgs/gp2c/spkg-install.in +++ b/build/pkgs/gp2c/spkg-install.in @@ -1,7 +1,4 @@ cd src - -export CFLAGS=$CFLAGS_NON_NATIVE - sdh_configure --with-paricfg=$SAGE_PARI_CFG sdh_make sdh_make_install diff --git a/build/pkgs/lcalc/spkg-install.in b/build/pkgs/lcalc/spkg-install.in index 381b3f53042..9000051aa58 100644 --- a/build/pkgs/lcalc/spkg-install.in +++ b/build/pkgs/lcalc/spkg-install.in @@ -4,8 +4,6 @@ if [ "$UNAME" = "Darwin" ]; then export LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names" fi -CXXFLAGS=$CXXFLAGS_NON_NATIVE - # Using pari in a C++17 file with "using namespace std doesn't # work due to a conflict between std::rank and pari's rank CXXFLAGS=$(echo "${CXXFLAGS}" | sed "s/-std=c++17//g") diff --git a/build/pkgs/pari/spkg-install.in b/build/pkgs/pari/spkg-install.in index 6ddea50d89f..3134aadb353 100644 --- a/build/pkgs/pari/spkg-install.in +++ b/build/pkgs/pari/spkg-install.in @@ -112,7 +112,7 @@ if [ $MACOSX_VERSION -ge 14 ]; then export MACOSX_DEPLOYMENT_TARGET=10.9 fi -export CFLAGS=$CFLAGS_O3_NON_NATIVE +export CFLAGS=$CFLAGS_O3 if [ "$SAGE_DEBUG" = yes ]; then diff --git a/build/pkgs/pari_jupyter/spkg-install.in b/build/pkgs/pari_jupyter/spkg-install.in index 47b5e3cc60a..deba1bb42bb 100644 --- a/build/pkgs/pari_jupyter/spkg-install.in +++ b/build/pkgs/pari_jupyter/spkg-install.in @@ -1,3 +1 @@ -export CFLAGS=$CFLAGS_NON_NATIVE - cd src && sdh_pip_install . From f23e68c4c7cf3de2d09fe7d9c04080911f154652 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Sat, 27 Jun 2020 11:20:51 +0200 Subject: [PATCH 21/40] export SAGE_DEBUG, if this was enabled during configure --- build/bin/sage-build-env-config.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index 019838a8863..87acb56e29a 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -51,6 +51,9 @@ export ORIGINAL_F77FLAGS="@ORIGINAL_F77FLAGS@" # Export SAGE_FAT_BINARY if this was enabled during configure. export SAGE_FAT_BINARY="@SAGE_FAT_BINARY@" +# Export SAGE_DEBUG if this was enabled during configure. +export SAGE_DEBUG="@SAGE_DEBUG@" + # This is usually blank if the system GMP is used, or $SAGE_LOCAL otherwise export SAGE_GMP_PREFIX="@SAGE_GMP_PREFIX@" export SAGE_GMP_INCLUDE="@SAGE_GMP_INCLUDE@" From e9fb1a37af6ac08c29dff5a9cb062eccf60f761a Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Tue, 7 Jul 2020 10:18:33 +0200 Subject: [PATCH 22/40] allow debuggin of individual packages --- build/bin/sage-build-env-config.in | 29 --------- build/make/Makefile.in | 93 +++++++++++++++++++++++++++ build/pkgs/gcc/spkg-configure.m4 | 53 +++++++-------- build/pkgs/gfortran/spkg-configure.m4 | 25 ------- 4 files changed, 116 insertions(+), 84 deletions(-) diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index 87acb56e29a..3773602ba42 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -22,38 +22,9 @@ # The configured CXX without special flags added that enable C++11 support export SAGE_CXX_WITHOUT_STD="@SAGE_CXX_WITHOUT_STD@" -# The configured compilation flags -export CFLAGS="@CFLAGS@" -export CXXFLAGS="@CXXFLAGS@" -export FCFLAGS="@FCFLAGS@" -export F77FLAGS="@F77FLAGS@" - -export CFLAGS_O3="@CFLAGS_O3@" -export CXXFLAGS_O3="@CXXFLAGS_O3@" -export FCFLAGS_O3="@FCFLAGS_O3@" -export F77FLAGS_O3="@F77FLAGS_O3@" - -export CFLAGS_NON_NATIVE="@CFLAGS_NON_NATIVE@" -export CXXFLAGS_NON_NATIVE="@CXXFLAGS_NON_NATIVE@" -export FCFLAGS_NON_NATIVE="@FCFLAGS_NON_NATIVE@" -export F77FLAGS_NON_NATIVE="@F77FLAGS_NON_NATIVE@" - -export CFLAGS_O3_NON_NATIVE="@CFLAGS_O3_NON_NATIVE@" -export CXXFLAGS_O3_NON_NATIVE="@CXXFLAGS_O3_NON_NATIVE@" -export FCFLAGS_O3_NON_NATIVE="@FCFLAGS_O3_NON_NATIVE@" -export F77FLAGS_O3_NON_NATIVE="@F77FLAGS_O3_NON_NATIVE@" - -export ORIGINAL_CFLAGS="@ORIGINAL_CFLAGS@" -export ORIGINAL_CXXFLAGS="@ORIGINAL_CXXFLAGS@" -export ORIGINAL_FCFLAGS="@ORIGINAL_FCFLAGS@" -export ORIGINAL_F77FLAGS="@ORIGINAL_F77FLAGS@" - # Export SAGE_FAT_BINARY if this was enabled during configure. export SAGE_FAT_BINARY="@SAGE_FAT_BINARY@" -# Export SAGE_DEBUG if this was enabled during configure. -export SAGE_DEBUG="@SAGE_DEBUG@" - # This is usually blank if the system GMP is used, or $SAGE_LOCAL otherwise export SAGE_GMP_PREFIX="@SAGE_GMP_PREFIX@" export SAGE_GMP_INCLUDE="@SAGE_GMP_INCLUDE@" diff --git a/build/make/Makefile.in b/build/make/Makefile.in index ff3b49948c9..3dd8da3eb8a 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -26,6 +26,99 @@ SAGE_SPKG_INST=installed endif endif +# Optimization flags. +# We allow debugging of individual packages. + +# Export SAGE_DEBUG if this was enabled during configure, +# but be respectful of the current settings. +SAGE_DEBUG=@SAGE_DEBUG@ +export SAGE_DEBUG + +# The configured compilation flags +# The flags are printed by +# ``build/pkgs/gcc/spkg-configure.m4`` for convenience. +# Any changes to the defaults should be applied there as well. +CFLAGS=@ORIGINAL_CFLAGS@ +CXXFLAGS=@ORIGINAL_CXXFLAGS@ +FCFLAGS=@ORIGINAL_FCFLAGS@ +F77FLAGS=@ORIGINAL_F77FLAGS@ +ORIGINAL_CFLAGS:=$(CFLAGS) +ORIGINAL_CXXFLAGS:=$(CXXFLAGS) +ORIGINAL_FCFLAGS:=$(FCFLAGS) +ORIGINAL_F77FLAGS:=$(F77FLAGS) +export ORIGINAL_CFLAGS, ORIGINAL_CXXFLAGS, ORIGINAL_FCFLAGS, ORIGINAL_F77FLAGS + +SAGE_MARCH=@SAGE_MARCH@ + +ifeq ($(ORIGINAL_CFLAGS), ) +# Evaluate SAGE_DEBUG: +ifeq ($(SAGE_DEBUG), yes) +CFLAGS_NON_NATIVE=-Og -g +CFLAGS_O3_NON_NATIVE=-Og -g +SAGE_MARCH= +else +ifeq ($(SAGE_DEBUG), no) +CFLAGS_NON_NATIVE=-O2 +CFLAGS_O3_NON_NATIVE=-O3 +else +CFLAGS_NON_NATIVE=-O2 -g +CFLAGS_O3_NON_NATIVE=-O3 -g +endif +endif +export CFLAGS=$(CFLAGS_NON_NATIVE) $(SAGE_MARCH) +CFLAGS_O3:=$(CFLAGS_O3_NON_NATIVE) $(SAGE_MARCH) +else +# Respect user environment variable. +CFLAGS=$(ORIGINAL_CFLAGS) +CFLAGS_O3=$(ORIGINAL_CFLAGS) +CFLAGS_NON_NATIVE=$(ORIGINAL_CFLAGS) +CFLAGS_O3_NON_NATIVE=$(ORIGINAL_CFLAGS) +endif +export CFLAGS_NON_NATIVE, CFLAGS_O3_NON_NATIVE, CFLAGS_O3, CFLAGS + +# Copy to CXXFLAGS if this is not set. +ifeq ($(ORIGINAL_CXXFLAGS), ) +CXXFLAGS=$(CFLAGS) +CXXFLAGS_O3=$(CFLAGS_O3) +CXXFLAGS_NON_NATIVE=$(CFLAGS_NON_NATIVE) +CXXFLAGS_O3_NON_NATIVE=$(CFLAGS_O3_NON_NATIVE) +else +CXXFLAGS=$(ORIGINAL_CXXFLAGS) +CXXFLAGS_O3=$(ORIGINAL_CXXFLAGS) +CXXFLAGS_NON_NATIVE=$(ORIGINAL_CXXFLAGS) +CXXFLAGS_O3_NON_NATIVE=$(ORIGINAL_CXXFLAGS) +endif +export CXXFLAGS_NON_NATIVE, CXXFLAGS_O3_NON_NATIVE, CXXFLAGS_O3, CXXFLAGS + +# Copy CFLAGS to FCFLAGS if this is not set. +ifeq ($(ORIGINAL_FCFLAGS), ) +FCFLAGS=$(CFLAGS) +FCFLAGS_O3=$(CFLAGS_O3) +FCFLAGS_NON_NATIVE=$(CFLAGS_NON_NATIVE) +FCFLAGS_O3_NON_NATIVE=$(CFLAGS_O3_NON_NATIVE) +else +FCFLAGS=$(ORIGINAL_FCFLAGS) +FCFLAGS_O3=$(ORIGINAL_FCFLAGS) +FCFLAGS_NON_NATIVE=$(ORIGINAL_FCFLAGS) +FCFLAGS_O3_NON_NATIVE=$(ORIGINAL_FCFLAGS) +endif +export FCFLAGS_NON_NATIVE, FCFLAGS_O3_NON_NATIVE, FCFLAGS_O3, FCFLAGS + +# Copy FCFLAGS to F77FLAGS if this is not set. +ifeq ($(ORIGINAL_F77FLAGS), ) +F77FLAGS=$(FCFLAGS) +F77FLAGS_O3=$(FCFLAGS_O3) +F77FLAGS_NON_NATIVE=$(FCFLAGS_NON_NATIVE) +F77FLAGS_O3_NON_NATIVE=$(FCFLAGS_O3_NON_NATIVE) +else +F77FLAGS=$(ORIGINAL_F77FLAGS) +F77FLAGS_O3=$(ORIGINAL_F77FLAGS) +F77FLAGS_NON_NATIVE=$(ORIGINAL_F77FLAGS) +F77FLAGS_O3_NON_NATIVE=$(ORIGINAL_F77FLAGS) +endif +export F77FLAGS_NON_NATIVE, F77FLAGS_O3_NON_NATIVE, F77FLAGS_O3, F77FLAGS + + # Directory to keep track of which packages are installed INST = $(SAGE_SPKG_INST) diff --git a/build/pkgs/gcc/spkg-configure.m4 b/build/pkgs/gcc/spkg-configure.m4 index 9a2882e7e9e..d84753a7004 100644 --- a/build/pkgs/gcc/spkg-configure.m4 +++ b/build/pkgs/gcc/spkg-configure.m4 @@ -208,39 +208,44 @@ SAGE_SPKG_CONFIGURE_BASE([gcc], [ # Determine which compiler flags should be set. if test "x$sage_use_march_native" = "xno"; then - march="" + SAGE_MARCH="" elif test "x$SAGE_FAT_BINARY" = "xyes"; then - march="" - elif test "x$SAGE_DEBUG" = "xyes"; then - march="" + SAGE_MARCH="" elif test "x$sage_spkg_install_gcc" =" xyes"; then - march=" -march=native" + SAGE_MARCH=" -march=native" else - AX_CHECK_COMPILE_FLAG("-march=native", [march=" -march=native"], [march=""], [], []) + AX_CHECK_COMPILE_FLAG("-march=native", [SAGE_MARCH=" -march=native"], [SAGE_MARCH=""], [], []) fi + AC_SUBST(SAGE_MARCH) + # We will only export SAGE_MARCH for now and redo this later. + # (Allow debugging of individual packages.) + # But we print the messages for convenience. + if test "x$SAGE_DEBUG" = "xyes"; then + SAGE_MARCH="" + fi if test "x$ORIGINAL_CFLAGS" = "x"; then # Evaluate SAGE_DEBUG: if test "x$SAGE_DEBUG" = "xyes" ; then - AC_SUBST(CFLAGS_NON_NATIVE, "-Og -g") - AC_SUBST(CFLAGS_O3_NON_NATIVE, "-Og -g") + CFLAGS_NON_NATIVE="-Og -g" + CFLAGS_O3_NON_NATIVE="-Og -g" else if test "x$SAGE_DEBUG" = "xno" ; then - AC_SUBST(CFLAGS_NON_NATIVE, "-O2") - AC_SUBST(CFLAGS_O3_NON_NATIVE, "-O3") + CFLAGS_NON_NATIVE="-O2" + CFLAGS_O3_NON_NATIVE="-O3" else - AC_SUBST(CFLAGS_NON_NATIVE, "-O2 -g") - AC_SUBST(CFLAGS_O3_NON_NATIVE, "-O3 -g") + CFLAGS_NON_NATIVE="-O2 -g" + CFLAGS_O3_NON_NATIVE="-O3 -g" fi fi - AC_SUBST(CFLAGS, "${CFLAGS_NON_NATIVE}${march}") - AC_SUBST(CFLAGS_O3, "${CFLAGS_O3_NON_NATIVE}${march}") + CFLAGS="${CFLAGS_NON_NATIVE}${SAGE_MARCH} + CFLAGS_O3="${CFLAGS_O3_NON_NATIVE}${SAGE_MARCH} else # Respect user environment variable. - AC_SUBST(CFLAGS, "${CFLAGS}") - AC_SUBST(CFLAGS_O3, "${CFLAGS}") - AC_SUBST(CFLAGS_NON_NATIVE, "${CFLAGS}") - AC_SUBST(CFLAGS_O3_NON_NATIVE, "${CFLAGS}") + CFLAGS="${CFLAGS} + CFLAGS_O3="${CFLAGS} + CFLAGS_NON_NATIVE="${CFLAGS} + CFLAGS_O3_NON_NATIVE="${CFLAGS} fi AC_MSG_NOTICE(ORIGINAL_CFLAGS=$ORIGINAL_CFLAGS) @@ -249,18 +254,6 @@ SAGE_SPKG_CONFIGURE_BASE([gcc], [ AC_MSG_NOTICE(CFLAGS_NON_NATIVE=$CFLAGS_NON_NATIVE) AC_MSG_NOTICE(CFLAGS_O3_NON_NATIVE=$CFLAGS_O3_NON_NATIVE) - # Copy to CXXFLAGS if this is not set. - if test "x$ORIGINAL_CXXFLAGS" = "x"; then - AC_SUBST(CXXFLAGS, "$CFLAGS") - AC_SUBST(CXXFLAGS_O3, "$CFLAGS_O3") - AC_SUBST(CXXFLAGS_NON_NATIVE, "$CFLAGS_NON_NATIVE") - AC_SUBST(CXXFLAGS_O3_NON_NATIVE, "$CFLAGS_O3_NON_NATIVE") - else - AC_SUBST(CXXFLAGS_03, "$ORIGINAL_CXXFLAGS") - AC_SUBST(CXXFLAGS_NON_NATIVE, "$ORIGINAL_CXXFLAGS") - AC_SUBST(CXXFLAGS_O3_NON_NATIVE, "$ORIGINAL_CXXFLAGS") - fi - ], , , [ # Trac #27907: Find location of crti.o from the system CC, in case we build our own gcc AC_MSG_CHECKING([for the location of crti.o]) diff --git a/build/pkgs/gfortran/spkg-configure.m4 b/build/pkgs/gfortran/spkg-configure.m4 index 0bd2aa0f0f1..d75bbca9be5 100644 --- a/build/pkgs/gfortran/spkg-configure.m4 +++ b/build/pkgs/gfortran/spkg-configure.m4 @@ -21,29 +21,4 @@ SAGE_SPKG_CONFIGURE([gfortran], [ if test "x$sage_spkg_install_gcc" = "xyes" -o x$SAGE_INSTALL_GCC = xexists; then sage_spkg_install_gfortran=no fi - - # Copy CFLAGS to FCFLAGS if this is not set. - if test "x$ORIGINAL_FCFLAGS" = "x"; then - AC_SUBST(FCFLAGS, "$CFLAGS") - AC_SUBST(FCFLAGS_O3, "$CFLAGS_O3") - AC_SUBST(FCFLAGS_NON_NATIVE, "$CFLAGS_NON_NATIVE") - AC_SUBST(FCFLAGS_O3_NON_NATIVE, "$CFLAGS_O3_NON_NATIVE") - else - AC_SUBST(FCFLAGS_03, "$ORIGINAL_FCFLAGS") - AC_SUBST(FCFLAGS_NON_NATIVE, "$ORIGINAL_FCFLAGS") - AC_SUBST(FCFLAGS_O3_NON_NATIVE, "$ORIGINAL_FCFLAGS") - fi - - # Copy FCFLAGS to F77FLAGS if this is not set. - if test "x$ORIGINAL_F77FLAGS" = "x"; then - AC_SUBST(F77FLAGS, "$FCFLAGS") - AC_SUBST(F77FLAGS_O3, "$FCFLAGS_O3") - AC_SUBST(F77FLAGS_NON_NATIVE, "$FCFLAGS_NON_NATIVE") - AC_SUBST(F77FLAGS_O3_NON_NATIVE, "$FCFLAGS_O3_NON_NATIVE") - else - AC_SUBST(F77FLAGS_03, "$ORIGINAL_F77FLAGS") - AC_SUBST(F77FLAGS_NON_NATIVE, "$ORIGINAL_F77FLAGS") - AC_SUBST(F77FLAGS_O3_NON_NATIVE, "$ORIGINAL_F77FLAGS") - fi - ]) From 2ff56300b6ba53c0588f30e789f30108bf0fb179 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Sun, 16 Aug 2020 09:13:04 +0200 Subject: [PATCH 23/40] postpone `march=native` to later --- build/make/Makefile.in | 39 ++++++++-------------------- build/pkgs/eclib/spkg-install.in | 4 +-- build/pkgs/gap/spkg-install.in | 3 --- build/pkgs/gcc/spkg-configure.m4 | 41 +++++++----------------------- build/pkgs/gcc/spkg-install.in | 4 --- build/pkgs/mpfr/spkg-install.in | 2 +- build/pkgs/r/spkg-install.in | 4 +-- src/doc/en/developer/packaging.rst | 8 +----- 8 files changed, 25 insertions(+), 80 deletions(-) diff --git a/build/make/Makefile.in b/build/make/Makefile.in index e8090428466..f4c57840547 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -48,75 +48,56 @@ ORIGINAL_FCFLAGS:=$(FCFLAGS) ORIGINAL_F77FLAGS:=$(F77FLAGS) export ORIGINAL_CFLAGS, ORIGINAL_CXXFLAGS, ORIGINAL_FCFLAGS, ORIGINAL_F77FLAGS -SAGE_MARCH=@SAGE_MARCH@ - ifeq ($(ORIGINAL_CFLAGS), ) # Evaluate SAGE_DEBUG: ifeq ($(SAGE_DEBUG), yes) -CFLAGS_NON_NATIVE=-Og -g -CFLAGS_O3_NON_NATIVE=-Og -g -SAGE_MARCH= +CFLAGS=-Og -g +CFLAGS_O3=-Og -g else ifeq ($(SAGE_DEBUG), no) -CFLAGS_NON_NATIVE=-O2 -CFLAGS_O3_NON_NATIVE=-O3 +CFLAGS=-O2 +CFLAGS_O3=-O3 else -CFLAGS_NON_NATIVE=-O2 -g -CFLAGS_O3_NON_NATIVE=-O3 -g +CFLAGS=-O2 -g +CFLAGS_O3=-O3 -g endif endif -export CFLAGS=$(CFLAGS_NON_NATIVE) $(SAGE_MARCH) -CFLAGS_O3:=$(CFLAGS_O3_NON_NATIVE) $(SAGE_MARCH) else # Respect user environment variable. CFLAGS=$(ORIGINAL_CFLAGS) CFLAGS_O3=$(ORIGINAL_CFLAGS) -CFLAGS_NON_NATIVE=$(ORIGINAL_CFLAGS) -CFLAGS_O3_NON_NATIVE=$(ORIGINAL_CFLAGS) endif -export CFLAGS_NON_NATIVE, CFLAGS_O3_NON_NATIVE, CFLAGS_O3, CFLAGS +export CFLAGS_O3, CFLAGS # Copy to CXXFLAGS if this is not set. ifeq ($(ORIGINAL_CXXFLAGS), ) CXXFLAGS=$(CFLAGS) CXXFLAGS_O3=$(CFLAGS_O3) -CXXFLAGS_NON_NATIVE=$(CFLAGS_NON_NATIVE) -CXXFLAGS_O3_NON_NATIVE=$(CFLAGS_O3_NON_NATIVE) else CXXFLAGS=$(ORIGINAL_CXXFLAGS) CXXFLAGS_O3=$(ORIGINAL_CXXFLAGS) -CXXFLAGS_NON_NATIVE=$(ORIGINAL_CXXFLAGS) -CXXFLAGS_O3_NON_NATIVE=$(ORIGINAL_CXXFLAGS) endif -export CXXFLAGS_NON_NATIVE, CXXFLAGS_O3_NON_NATIVE, CXXFLAGS_O3, CXXFLAGS +export CXXFLAGS_O3, CXXFLAGS # Copy CFLAGS to FCFLAGS if this is not set. ifeq ($(ORIGINAL_FCFLAGS), ) FCFLAGS=$(CFLAGS) FCFLAGS_O3=$(CFLAGS_O3) -FCFLAGS_NON_NATIVE=$(CFLAGS_NON_NATIVE) -FCFLAGS_O3_NON_NATIVE=$(CFLAGS_O3_NON_NATIVE) else FCFLAGS=$(ORIGINAL_FCFLAGS) FCFLAGS_O3=$(ORIGINAL_FCFLAGS) -FCFLAGS_NON_NATIVE=$(ORIGINAL_FCFLAGS) -FCFLAGS_O3_NON_NATIVE=$(ORIGINAL_FCFLAGS) endif -export FCFLAGS_NON_NATIVE, FCFLAGS_O3_NON_NATIVE, FCFLAGS_O3, FCFLAGS +export FCFLAGS_O3, FCFLAGS # Copy FCFLAGS to F77FLAGS if this is not set. ifeq ($(ORIGINAL_F77FLAGS), ) F77FLAGS=$(FCFLAGS) F77FLAGS_O3=$(FCFLAGS_O3) -F77FLAGS_NON_NATIVE=$(FCFLAGS_NON_NATIVE) -F77FLAGS_O3_NON_NATIVE=$(FCFLAGS_O3_NON_NATIVE) else F77FLAGS=$(ORIGINAL_F77FLAGS) F77FLAGS_O3=$(ORIGINAL_F77FLAGS) -F77FLAGS_NON_NATIVE=$(ORIGINAL_F77FLAGS) -F77FLAGS_O3_NON_NATIVE=$(ORIGINAL_F77FLAGS) endif -export F77FLAGS_NON_NATIVE, F77FLAGS_O3_NON_NATIVE, F77FLAGS_O3, F77FLAGS +export F77FLAGS_O3, F77FLAGS # Directory to keep track of which packages are installed diff --git a/build/pkgs/eclib/spkg-install.in b/build/pkgs/eclib/spkg-install.in index 1611cfdd27d..9ccc0420e34 100644 --- a/build/pkgs/eclib/spkg-install.in +++ b/build/pkgs/eclib/spkg-install.in @@ -1,5 +1,5 @@ -CFLAGS="$CFLAGS_O3_NON_NATIVE" -CXXFLAGS="$CXXFLAGS_O3_NON_NATIVE" +CFLAGS="$CFLAGS_O3" +CXXFLAGS="$CXXFLAGS_O3" export CFLAGS CXXFLAGS diff --git a/build/pkgs/gap/spkg-install.in b/build/pkgs/gap/spkg-install.in index c986e59da6d..56e95338df1 100644 --- a/build/pkgs/gap/spkg-install.in +++ b/build/pkgs/gap/spkg-install.in @@ -4,9 +4,6 @@ cd src -export CFLAGS=$CFLAGS_NON_NATIVE -export CXXFLAGS=$CXXFLAGS_NON_NATIVE - GAP_BUILD_ROOT="$(pwd)" GAP_ROOT="$SAGE_LOCAL/share/gap" DESTDIR_GAP_ROOT="$SAGE_DESTDIR$GAP_ROOT" diff --git a/build/pkgs/gcc/spkg-configure.m4 b/build/pkgs/gcc/spkg-configure.m4 index de3148b78ae..0cedc4b61de 100644 --- a/build/pkgs/gcc/spkg-configure.m4 +++ b/build/pkgs/gcc/spkg-configure.m4 @@ -151,10 +151,6 @@ SAGE_SPKG_CONFIGURE_BASE([gcc], [ # Install our own GCC if the system-provided one is newer than 9.x. # See https://trac.sagemath.org/ticket/29456 SAGE_SHOULD_INSTALL_GCC([$CXX is g++ version $GXX_VERSION, which is too recent for this version of Sage]) - ], - [4.[[8-9]].*|5.[[0-1]].*], [ - # GCC less than 5.1 is not ready for AVX512. - sage_use_march_native=no ]) fi @@ -206,53 +202,34 @@ SAGE_SPKG_CONFIGURE_BASE([gcc], [ ]) fi - # Determine which compiler flags should be set. - if test "x$sage_use_march_native" = "xno"; then - SAGE_MARCH="" - elif test "x$SAGE_FAT_BINARY" = "xyes"; then - SAGE_MARCH="" - elif test "x$sage_spkg_install_gcc" =" xyes"; then - SAGE_MARCH=" -march=native" - else - AX_CHECK_COMPILE_FLAG("-march=native", [SAGE_MARCH=" -march=native"], [SAGE_MARCH=""], [], []) - fi - AC_SUBST(SAGE_MARCH) - - # We will only export SAGE_MARCH for now and redo this later. + # We redo this later. # (Allow debugging of individual packages.) # But we print the messages for convenience. - if test "x$SAGE_DEBUG" = "xyes"; then - SAGE_MARCH="" - fi if test "x$ORIGINAL_CFLAGS" = "x"; then # Evaluate SAGE_DEBUG: if test "x$SAGE_DEBUG" = "xyes" ; then - CFLAGS_NON_NATIVE="-Og -g" - CFLAGS_O3_NON_NATIVE="-Og -g" + CFLAGS="-Og -g" + CFLAGS_O3="-Og -g" else if test "x$SAGE_DEBUG" = "xno" ; then - CFLAGS_NON_NATIVE="-O2" - CFLAGS_O3_NON_NATIVE="-O3" + CFLAGS="-O2" + CFLAGS_O3="-O3" else - CFLAGS_NON_NATIVE="-O2 -g" - CFLAGS_O3_NON_NATIVE="-O3 -g" + CFLAGS="-O2 -g" + CFLAGS_O3="-O3 -g" fi fi - CFLAGS="${CFLAGS_NON_NATIVE}${SAGE_MARCH} - CFLAGS_O3="${CFLAGS_O3_NON_NATIVE}${SAGE_MARCH} + CFLAGS="${CFLAGS_NON_NATIVE} + CFLAGS_O3="${CFLAGS_O3_NON_NATIVE} else # Respect user environment variable. CFLAGS="${CFLAGS} CFLAGS_O3="${CFLAGS} - CFLAGS_NON_NATIVE="${CFLAGS} - CFLAGS_O3_NON_NATIVE="${CFLAGS} fi AC_MSG_NOTICE(ORIGINAL_CFLAGS=$ORIGINAL_CFLAGS) AC_MSG_NOTICE(CFLAGS=$CFLAGS) AC_MSG_NOTICE(CFLAGS_O3=$CFLAGS_O3) - AC_MSG_NOTICE(CFLAGS_NON_NATIVE=$CFLAGS_NON_NATIVE) - AC_MSG_NOTICE(CFLAGS_O3_NON_NATIVE=$CFLAGS_O3_NON_NATIVE) ], , , [ # Trac #27907: Find location of crti.o from the system CC, in case we build our own gcc diff --git a/build/pkgs/gcc/spkg-install.in b/build/pkgs/gcc/spkg-install.in index f7c8db1de19..819a9caba59 100644 --- a/build/pkgs/gcc/spkg-install.in +++ b/build/pkgs/gcc/spkg-install.in @@ -1,7 +1,3 @@ -# If we are building gcc ourselves, usually the system compiler isn't suitable. -export CFLAGS=$CFLAGS_NON_NATIVE -export CXXFLAGS=$CXXFLAGS_NON_NATIVE - # First, install any custom binaries or headers we created for macOS # workarounds for dir in bin include; do diff --git a/build/pkgs/mpfr/spkg-install.in b/build/pkgs/mpfr/spkg-install.in index 36663a48392..5e062603669 100644 --- a/build/pkgs/mpfr/spkg-install.in +++ b/build/pkgs/mpfr/spkg-install.in @@ -36,7 +36,7 @@ mpfr_configure() if [ "$SAGE_DEBUG" = yes ]; then # Disable optimization, add debug symbols: - required_cflags=$CFLAGS_NON_NATIVE + required_cflags=$CFLAGS echo >&2 "Warning: Building MPFR with SAGE_DEBUG=yes disables optimization." else # Add debug symbols by default, enable optimization, but do not (yet) diff --git a/build/pkgs/r/spkg-install.in b/build/pkgs/r/spkg-install.in index c63ff768f5b..e262131aa30 100644 --- a/build/pkgs/r/spkg-install.in +++ b/build/pkgs/r/spkg-install.in @@ -11,8 +11,8 @@ CPPFLAGS="$CPPFLAGS" # "for type of 'hidden' Fortran character lengths" # on ubuntu-bionic-minimal, ubuntu-eoan/focal-minimal, debian-buster/bullseye/sid-minimal, # linuxmint-19.3-minimal, archlinux-latest-minimal -CFLAGS="$CFLAGS_NON_NATIVE -fPIC" -FCFLAGS="$FCFLAGS_NON_NATIVE -fPIC" +CFLAGS="$CFLAGS -fPIC" +FCFLAGS="$FCFLAGS -fPIC" export CFLAGS CPPFLAGS FCFLAGS LDFLAGS diff --git a/src/doc/en/developer/packaging.rst b/src/doc/en/developer/packaging.rst index b065cf8bfb7..2e8a7a626b8 100644 --- a/src/doc/en/developer/packaging.rst +++ b/src/doc/en/developer/packaging.rst @@ -249,7 +249,7 @@ something like the following to install it: fi At build time :envvar:`CFLAGS`, :envvar:`CXXFLAGS`, :envvar:`FCFLAGS`, -and :envvar:`F77FLAGS` are usually set to ``-g -O2 -march=native`` +and :envvar:`F77FLAGS` are usually set to ``-g -O2`` (according to `debugging options <../installation/source.html#sage-debug>`_ and whether building `fat binaries <../installation/source.html#sage-fat-binary>`_). @@ -258,15 +258,9 @@ Slightly modified versions are available: .. CODE-BLOCK:: bash - # No ``-march=native``. - export CFLAGS=$CFLAGS_NON_NATIVE - # ``-O3`` instead of ``-O2``. export CFLAGS=$CFLAGS_O3 - # No ``-march=native`` and ``-O3`` instead of ``-O2``. - export CFLAGS=$CFLAGS_O3_NON_NATIVE - # Use flags as set by the user, possibly empty. export CFLAGS=$ORIGINAL_CFLAGS From 5f4d0b1c9696ea47784348164c4832a5c51178e4 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Sun, 18 Oct 2020 10:59:08 +0200 Subject: [PATCH 24/40] bash syntax again --- build/bin/sage-build-env.in | 85 ++++++++++++++++++++++++++++++ build/make/Makefile.in | 76 +------------------------- configure.ac | 2 +- src/bin/sage | 4 +- src/bin/sage-env-config.in | 2 +- src/doc/en/developer/packaging.rst | 4 +- 6 files changed, 94 insertions(+), 79 deletions(-) create mode 100644 build/bin/sage-build-env.in diff --git a/build/bin/sage-build-env.in b/build/bin/sage-build-env.in new file mode 100644 index 00000000000..a8c73b48b01 --- /dev/null +++ b/build/bin/sage-build-env.in @@ -0,0 +1,85 @@ +# -*- shell-script -*- + +########################################################################### +# +# Determine environment variables according to configuration. +# +# NOTES: +# - You must *source* this script instead of executing. +# - Use "return" instead of "exit" to signal a failure. Since this +# file is sourced, an "exit" here will actually exit src/bin/sage, +# which is probably not intended. +# - All environment variables set here should be *exported*, otherwise +# they won't be available in child programs. +# +# If you want to set all environment variables for your shell like +# they are during the build of Sage packages, type +# +# sage --buildsh +# +########################################################################## + +# Optimization flags. +# We allow debugging of individual packages. + +# Export SAGE_DEBUG if this was enabled during configure, +# but be respectful of the current settings. +export SAGE_DEBUG="@SAGE_DEBUG@" + +# The configured compilation flags +# The flags are printed by +# ``build/pkgs/gcc/spkg-configure.m4`` for convenience. +# Any changes to the defaults should be applied there as well. +export CFLAGS="@ORIGINAL_CFLAGS@" +export CXXFLAGS="@ORIGINAL_CXXFLAGS@" +export FCFLAGS="@ORIGINAL_FCFLAGS@" +export F77FLAGS="@ORIGINAL_F77FLAGS@" +export ORIGINAL_CFLAGS="$CFLAGS" +export ORIGINAL_CXXFLAGS="$CXXFLAGS" +export ORIGINAL_FCFLAGS="$FCFLAGS" +export ORIGINAL_F77FLAGS="$F77FLAGS" + +if [ -n "$ORIGINAL_CFLAGS" ]; then + # Evaluate SAGE_DEBUG: + if [ "$SAGE_DEBUG" == "yes" ]; then + export CFLAGS="-Og -g" + export CFLAGS_O3="-Og -g" + elif [ "$SAGE_DEBUG" == "no" ]; then + export CFLAGS="-O2" + export CFLAGS_O3="-O3" + else + export CFLAGS="-O2 -g" + export CFLAGS_O3="-O3 -g" + fi +else + # Respect user environment variable. + export CFLAGS="$ORIGINAL_CFLAGS" + export CFLAGS_O3="$ORIGINAL_CFLAGS" +fi + +# Copy to CXXFLAGS if this is not set. +if [ -n "$ORIGINAL_CXXFLAGS" ]; then + export CXXFLAGS="$CFLAGS" + export CXXFLAGS_O3="$CFLAGS_O3" +else + export CXXFLAGS="$ORIGINAL_CXXFLAGS" + export CXXFLAGS_O3="$ORIGINAL_CXXFLAGS" +fi + +# Copy CFLAGS to FCFLAGS if this is not set. +if [ -n "$ORIGINAL_FCFLAGS" ]; then + export FCFLAGS="$CFLAGS" + export FCFLAGS_O3="$CFLAGS_O3" +else + export FCFLAGS="$ORIGINAL_FCFLAGS" + export FCFLAGS_O3="$ORIGINAL_FCFLAGS" +fi + +# Copy FCFLAGS to F77FLAGS if this is not set. +if [ -n "$ORIGINAL_F77FLAGS" ]; then + export F77FLAGS="$FCFLAGS" + export F77FLAGS_O3="$FCFLAGS_O3" +else + export F77FLAGS="$ORIGINAL_F77FLAGS" + export F77FLAGS_O3="$ORIGINAL_F77FLAGS" +fi diff --git a/build/make/Makefile.in b/build/make/Makefile.in index c952b492da0..daa44aa1bad 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -26,80 +26,6 @@ SAGE_SPKG_INST=installed endif endif -# Optimization flags. -# We allow debugging of individual packages. - -# Export SAGE_DEBUG if this was enabled during configure, -# but be respectful of the current settings. -SAGE_DEBUG=@SAGE_DEBUG@ -export SAGE_DEBUG - -# The configured compilation flags -# The flags are printed by -# ``build/pkgs/gcc/spkg-configure.m4`` for convenience. -# Any changes to the defaults should be applied there as well. -CFLAGS=@ORIGINAL_CFLAGS@ -CXXFLAGS=@ORIGINAL_CXXFLAGS@ -FCFLAGS=@ORIGINAL_FCFLAGS@ -F77FLAGS=@ORIGINAL_F77FLAGS@ -ORIGINAL_CFLAGS:=$(CFLAGS) -ORIGINAL_CXXFLAGS:=$(CXXFLAGS) -ORIGINAL_FCFLAGS:=$(FCFLAGS) -ORIGINAL_F77FLAGS:=$(F77FLAGS) -export ORIGINAL_CFLAGS, ORIGINAL_CXXFLAGS, ORIGINAL_FCFLAGS, ORIGINAL_F77FLAGS - -ifeq ($(ORIGINAL_CFLAGS), ) -# Evaluate SAGE_DEBUG: -ifeq ($(SAGE_DEBUG), yes) -CFLAGS=-Og -g -CFLAGS_O3=-Og -g -else -ifeq ($(SAGE_DEBUG), no) -CFLAGS=-O2 -CFLAGS_O3=-O3 -else -CFLAGS=-O2 -g -CFLAGS_O3=-O3 -g -endif -endif -else -# Respect user environment variable. -CFLAGS=$(ORIGINAL_CFLAGS) -CFLAGS_O3=$(ORIGINAL_CFLAGS) -endif -export CFLAGS_O3, CFLAGS - -# Copy to CXXFLAGS if this is not set. -ifeq ($(ORIGINAL_CXXFLAGS), ) -CXXFLAGS=$(CFLAGS) -CXXFLAGS_O3=$(CFLAGS_O3) -else -CXXFLAGS=$(ORIGINAL_CXXFLAGS) -CXXFLAGS_O3=$(ORIGINAL_CXXFLAGS) -endif -export CXXFLAGS_O3, CXXFLAGS - -# Copy CFLAGS to FCFLAGS if this is not set. -ifeq ($(ORIGINAL_FCFLAGS), ) -FCFLAGS=$(CFLAGS) -FCFLAGS_O3=$(CFLAGS_O3) -else -FCFLAGS=$(ORIGINAL_FCFLAGS) -FCFLAGS_O3=$(ORIGINAL_FCFLAGS) -endif -export FCFLAGS_O3, FCFLAGS - -# Copy FCFLAGS to F77FLAGS if this is not set. -ifeq ($(ORIGINAL_F77FLAGS), ) -F77FLAGS=$(FCFLAGS) -F77FLAGS_O3=$(FCFLAGS_O3) -else -F77FLAGS=$(ORIGINAL_F77FLAGS) -F77FLAGS_O3=$(ORIGINAL_F77FLAGS) -endif -export F77FLAGS_O3, F77FLAGS - - # Directory to keep track of which packages are installed INST = $(SAGE_SPKG_INST) @@ -649,6 +575,7 @@ $(1)-no-deps: . '$$(SAGE_ROOT)/src/bin/sage-env-config' && \ . '$$(SAGE_ROOT)/src/bin/sage-env' && \ . '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \ + . '$$(SAGE_ROOT)/build/bin/sage-build-env' && \ sage-logger -p '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-install' '$$(SAGE_LOGS)/$(1)-$(2).log' touch "$$(INST)/$(1)-$(2)" @@ -657,6 +584,7 @@ $(1)-uninstall: . '$$(SAGE_ROOT)/src/bin/sage-env-config' && \ . '$$(SAGE_ROOT)/src/bin/sage-env' && \ . '$$(SAGE_ROOT)/build/bin/sage-build-env-config' && \ + . '$$(SAGE_ROOT)/build/bin/sage-build-env' && \ '$$(SAGE_ROOT)/build/pkgs/$(1)/spkg-uninstall' -rm -f "$$(INST)/$(1)-$(2)" diff --git a/configure.ac b/configure.ac index 9867f68c19e..d3005eb76bb 100644 --- a/configure.ac +++ b/configure.ac @@ -411,7 +411,7 @@ SAGE_SPKG_COLLECT() dnl AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([build/make/Makefile-auto build/make/Makefile]) -AC_CONFIG_FILES([src/bin/sage-env-config build/bin/sage-build-env-config]) +AC_CONFIG_FILES([src/bin/sage-env-config build/bin/sage-build-env-config build/bin/sage-build-env]) AC_CONFIG_FILES([build/pkgs/sage_conf/src/sage_conf.py build/pkgs/sage_conf/src/setup.cfg]) diff --git a/src/bin/sage b/src/bin/sage index 5ac6b4d4ce7..1dadb18c342 100755 --- a/src/bin/sage +++ b/src/bin/sage @@ -655,9 +655,11 @@ if [ "$1" = '-sh' -o "$1" = '--sh' -o "$1" = '-buildsh' -o "$1" = '--buildsh' ]; exit 1 fi . "$SAGE_ROOT"/build/bin/sage-build-env-config || (echo "error: Error sourcing $SAGE_ROOT/build/bin/sage-build-env-config"; exit 1) + . "$SAGE_ROOT"/build/bin/sage-build-env || (echo "error: Error sourcing $SAGE_ROOT/build/bin/sage-build-env"; exit 1) export SAGE_SHPROMPT_PREFIX=sage-buildsh # We export it so that recursive invocation of 'sage-sh' from a sage-buildsh shows the sage-buildsh prompt; - # this makes sense because all environment variables set in build/bin/sage-build-env-config are exported. + # this makes sense because all environment variables set in build/bin/sage-build-env-config + # and build/bin/sage-build-env are exported. fi shift # If $SHELL is unset, default to bash diff --git a/src/bin/sage-env-config.in b/src/bin/sage-env-config.in index fbd88585ffd..1ab85337bf6 100644 --- a/src/bin/sage-env-config.in +++ b/src/bin/sage-env-config.in @@ -17,7 +17,7 @@ # file. # - Environment variables that are only needed at the time of building # SPKGs or sagelib should be set in build/bin/sage-build-env-config -# instead. +# or build/bin/sage-build-env instead. # - Configuration variables that are only needed by the Sage runtime, # but not as environment variables, should instead be set in # build/pkgs/sage_conf/src/sage_conf.py diff --git a/src/doc/en/developer/packaging.rst b/src/doc/en/developer/packaging.rst index 8314f03d7c1..a417df20993 100644 --- a/src/doc/en/developer/packaging.rst +++ b/src/doc/en/developer/packaging.rst @@ -330,8 +330,8 @@ It needs to be an executable shell script; it is not subject to the templating described in the previous section. Sage runs ``spkg-install`` from the directory ``$SAGE_ROOT/build/pkgs/`` -in the environment obtained by sourcing the files ``src/bin/sage-env`` and -``build/bin/sage-build-env-config``. +in the environment obtained by sourcing the files ``src/bin/sage-env``, +``build/bin/sage-build-env-config``, and ``build/bin/sage-build-env``. .. _section-sdh-helpers: From a913bbd97fa2deff1daa54c27b6dd5b17996e289 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Sun, 18 Oct 2020 11:56:57 +0200 Subject: [PATCH 25/40] correct detextion of empty values --- build/bin/sage-build-env.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/build/bin/sage-build-env.in b/build/bin/sage-build-env.in index a8c73b48b01..296bd66fb25 100644 --- a/build/bin/sage-build-env.in +++ b/build/bin/sage-build-env.in @@ -39,12 +39,12 @@ export ORIGINAL_CXXFLAGS="$CXXFLAGS" export ORIGINAL_FCFLAGS="$FCFLAGS" export ORIGINAL_F77FLAGS="$F77FLAGS" -if [ -n "$ORIGINAL_CFLAGS" ]; then +if [ "x$ORIGINAL_CFLAGS" == "x" ]; then # Evaluate SAGE_DEBUG: - if [ "$SAGE_DEBUG" == "yes" ]; then + if [ "x$SAGE_DEBUG" == "xyes" ]; then export CFLAGS="-Og -g" export CFLAGS_O3="-Og -g" - elif [ "$SAGE_DEBUG" == "no" ]; then + elif [ "x$SAGE_DEBUG" == "xno" ]; then export CFLAGS="-O2" export CFLAGS_O3="-O3" else @@ -58,7 +58,7 @@ else fi # Copy to CXXFLAGS if this is not set. -if [ -n "$ORIGINAL_CXXFLAGS" ]; then +if [ "x$ORIGINAL_CXXFLAGS" == "x" ]; then export CXXFLAGS="$CFLAGS" export CXXFLAGS_O3="$CFLAGS_O3" else @@ -67,7 +67,7 @@ else fi # Copy CFLAGS to FCFLAGS if this is not set. -if [ -n "$ORIGINAL_FCFLAGS" ]; then +if [ "x$ORIGINAL_FCFLAGS" == "x" ]; then export FCFLAGS="$CFLAGS" export FCFLAGS_O3="$CFLAGS_O3" else @@ -76,7 +76,7 @@ else fi # Copy FCFLAGS to F77FLAGS if this is not set. -if [ -n "$ORIGINAL_F77FLAGS" ]; then +if [ "x$ORIGINAL_F77FLAGS" == "x" ]; then export F77FLAGS="$FCFLAGS" export F77FLAGS_O3="$FCFLAGS_O3" else From d979c2251c191e1a661fcfd5cd89dc5f83750fb7 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 26 Oct 2020 18:08:48 +0100 Subject: [PATCH 26/40] do not generate `sage-build-env`; respect environment settings at make time --- .../bin/{sage-build-env.in => sage-build-env} | 11 +--------- build/bin/sage-build-env-config.in | 20 +++++++++++++++++++ configure.ac | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) rename build/bin/{sage-build-env.in => sage-build-env} (87%) diff --git a/build/bin/sage-build-env.in b/build/bin/sage-build-env similarity index 87% rename from build/bin/sage-build-env.in rename to build/bin/sage-build-env index 296bd66fb25..d66151f385d 100644 --- a/build/bin/sage-build-env.in +++ b/build/bin/sage-build-env @@ -21,19 +21,10 @@ # Optimization flags. # We allow debugging of individual packages. - -# Export SAGE_DEBUG if this was enabled during configure, -# but be respectful of the current settings. -export SAGE_DEBUG="@SAGE_DEBUG@" - -# The configured compilation flags +# # The flags are printed by # ``build/pkgs/gcc/spkg-configure.m4`` for convenience. # Any changes to the defaults should be applied there as well. -export CFLAGS="@ORIGINAL_CFLAGS@" -export CXXFLAGS="@ORIGINAL_CXXFLAGS@" -export FCFLAGS="@ORIGINAL_FCFLAGS@" -export F77FLAGS="@ORIGINAL_F77FLAGS@" export ORIGINAL_CFLAGS="$CFLAGS" export ORIGINAL_CXXFLAGS="$CXXFLAGS" export ORIGINAL_FCFLAGS="$FCFLAGS" diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index 3773602ba42..b45927da496 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -25,6 +25,26 @@ export SAGE_CXX_WITHOUT_STD="@SAGE_CXX_WITHOUT_STD@" # Export SAGE_FAT_BINARY if this was enabled during configure. export SAGE_FAT_BINARY="@SAGE_FAT_BINARY@" +# Export SAGE_DEBUG if this was enabled during configure, +# but be respectful of the current settings. +if [ "x$SAGE_DEBUG" == "x" ]; then + export SAGE_DEBUG="@SAGE_DEBUG@" +fi + +# The configured compilation flags. +if [ "x$CFLAGS" == "x" ]; then + export CFLAGS="@ORIGINAL_CFLAGS@" +fi +if [ "x$CXXFLAGS" == "x" ]; then + export CXXFLAGS="@ORIGINAL_CXXFLAGS@" +fi +if [ "x$FCFLAGS" == "x" ]; then + export FCFLAGS="@ORIGINAL_FCFLAGS@" +fi +if [ "x$F77FLAGS" == "x" ]; then + export F77FLAGS="@ORIGINAL_F77FLAGS@" +fi + # This is usually blank if the system GMP is used, or $SAGE_LOCAL otherwise export SAGE_GMP_PREFIX="@SAGE_GMP_PREFIX@" export SAGE_GMP_INCLUDE="@SAGE_GMP_INCLUDE@" diff --git a/configure.ac b/configure.ac index d3005eb76bb..9867f68c19e 100644 --- a/configure.ac +++ b/configure.ac @@ -411,7 +411,7 @@ SAGE_SPKG_COLLECT() dnl AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([build/make/Makefile-auto build/make/Makefile]) -AC_CONFIG_FILES([src/bin/sage-env-config build/bin/sage-build-env-config build/bin/sage-build-env]) +AC_CONFIG_FILES([src/bin/sage-env-config build/bin/sage-build-env-config]) AC_CONFIG_FILES([build/pkgs/sage_conf/src/sage_conf.py build/pkgs/sage_conf/src/setup.cfg]) From e898e33f2e3fb3413bc2d94e8e6aa6c94c0abe0f Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Tue, 27 Oct 2020 09:23:38 +0100 Subject: [PATCH 27/40] more natural naming --- build/bin/sage-build-env-config.in | 8 ++++---- configure.ac | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index b45927da496..e521974683c 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -33,16 +33,16 @@ fi # The configured compilation flags. if [ "x$CFLAGS" == "x" ]; then - export CFLAGS="@ORIGINAL_CFLAGS@" + export CFLAGS="@CFLAGS@" fi if [ "x$CXXFLAGS" == "x" ]; then - export CXXFLAGS="@ORIGINAL_CXXFLAGS@" + export CXXFLAGS="@CXXFLAGS@" fi if [ "x$FCFLAGS" == "x" ]; then - export FCFLAGS="@ORIGINAL_FCFLAGS@" + export FCFLAGS="@FCFLAGS@" fi if [ "x$F77FLAGS" == "x" ]; then - export F77FLAGS="@ORIGINAL_F77FLAGS@" + export F77FLAGS="@F77FLAGS@" fi # This is usually blank if the system GMP is used, or $SAGE_LOCAL otherwise diff --git a/configure.ac b/configure.ac index 9867f68c19e..9b6aefeaeda 100644 --- a/configure.ac +++ b/configure.ac @@ -313,10 +313,10 @@ AX_PROG_PERL_VERSION([5.8.0],[],[ ############################################################################### # Save compiler flags as configured by the user. -AC_SUBST(ORIGINAL_CFLAGS, "$CFLAGS") -AC_SUBST(ORIGINAL_CXXFLAGS, "$CXXFLAGS") -AC_SUBST(ORIGINAL_FCFLAGS, "$FCFLAGS") -AC_SUBST(ORIGINAL_F77FLAGS, "$F77FLAGS") +AC_SUBST(CFLAGS, "$CFLAGS") +AC_SUBST(CXXFLAGS, "$CXXFLAGS") +AC_SUBST(FCFLAGS, "$FCFLAGS") +AC_SUBST(F77FLAGS, "$F77FLAGS") SAGE_CHECK_CONDA_COMPILERS From 77bc7433b983a4187c5c36e872f724cb75181f7d Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 13 Nov 2020 15:30:58 +0100 Subject: [PATCH 28/40] move all logic to buil/bin/sage-build-env --- build/bin/sage-build-env | 32 ++++++++++++++++++++++-------- build/bin/sage-build-env-config.in | 16 ++++----------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/build/bin/sage-build-env b/build/bin/sage-build-env index d66151f385d..3a017865934 100644 --- a/build/bin/sage-build-env +++ b/build/bin/sage-build-env @@ -20,16 +20,32 @@ ########################################################################## # Optimization flags. -# We allow debugging of individual packages. # -# The flags are printed by -# ``build/pkgs/gcc/spkg-configure.m4`` for convenience. -# Any changes to the defaults should be applied there as well. -export ORIGINAL_CFLAGS="$CFLAGS" -export ORIGINAL_CXXFLAGS="$CXXFLAGS" -export ORIGINAL_FCFLAGS="$FCFLAGS" -export ORIGINAL_F77FLAGS="$F77FLAGS" +# The compiler flags are set in order of priority by +# 1) environment variables +# 2) flags set at configuration time +if [ "x$CFLAGS" == "x" ]; then + export $ORIGINAL_CFLAGS = "$CONFIGURED_CFLAGS" +else + export $ORIGINAL_CFLAGS = "$CFLAGS" +fi +if [ "x$CXXFLAGS" == "x" ]; then + export $ORIGINAL_CXXFLAGS = "$CONFIGURED_CXXFLAGS" +else + export $ORIGINAL_CXXFLAGS = "$CXXFLAGS" +fi +if [ "x$FCFLAGS" == "x" ]; then + export $ORIGINAL_FCFLAGS = "$CONFIGURED_FCFLAGS" +else + export $ORIGINAL_FCFLAGS = "$FCFLAGS" +fi +if [ "x$F77FLAGS" == "x" ]; then + export $ORIGINAL_F77FLAGS = "$CONFIGURED_F77FLAGS" +else + export $ORIGINAL_F77FLAGS = "$F77FLAGS" +fi +# We optimize according to $SAGE_DEBUG. if [ "x$ORIGINAL_CFLAGS" == "x" ]; then # Evaluate SAGE_DEBUG: if [ "x$SAGE_DEBUG" == "xyes" ]; then diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index e521974683c..29ad8f10961 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -32,18 +32,10 @@ if [ "x$SAGE_DEBUG" == "x" ]; then fi # The configured compilation flags. -if [ "x$CFLAGS" == "x" ]; then - export CFLAGS="@CFLAGS@" -fi -if [ "x$CXXFLAGS" == "x" ]; then - export CXXFLAGS="@CXXFLAGS@" -fi -if [ "x$FCFLAGS" == "x" ]; then - export FCFLAGS="@FCFLAGS@" -fi -if [ "x$F77FLAGS" == "x" ]; then - export F77FLAGS="@F77FLAGS@" -fi +export CONFIGURED_CFLAGS="@CFLAGS@" +export CONFIGURED_CXXFLAGS="@CXXFLAGS@" +export CONFIGURED_FCFLAGS="@FCFLAGS@" +export CONFIGURED_F77FLAGS="@F77FLAGS@" # This is usually blank if the system GMP is used, or $SAGE_LOCAL otherwise export SAGE_GMP_PREFIX="@SAGE_GMP_PREFIX@" From e2023d20fe0ea3475877884a3b36206621223018 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 13 Nov 2020 15:34:46 +0100 Subject: [PATCH 29/40] removed message in gcc/spkg-configure.m4 --- build/pkgs/gcc/spkg-configure.m4 | 40 ++++---------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/build/pkgs/gcc/spkg-configure.m4 b/build/pkgs/gcc/spkg-configure.m4 index 51ce20f5d47..5b5de33bc8e 100644 --- a/build/pkgs/gcc/spkg-configure.m4 +++ b/build/pkgs/gcc/spkg-configure.m4 @@ -51,11 +51,11 @@ AC_DEFUN([SAGE_CHECK_BROKEN_GCC], [ SAGE_SPKG_CONFIGURE_BASE([gcc], [ - AC_REQUIRE([AC_PROG_CC]) - AC_REQUIRE([AC_PROG_CPP]) - AC_REQUIRE([AC_PROG_CXX]) - AC_REQUIRE([AC_PROG_OBJC]) - AC_REQUIRE([AC_PROG_OBJCXX]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_PROG_CPP]) + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([AC_PROG_OBJC]) + AC_REQUIRE([AC_PROG_OBJCXX]) if test -f "$SAGE_LOCAL/bin/gcc"; then # Special value for SAGE_INSTALL_GCC if GCC is already installed @@ -201,36 +201,6 @@ SAGE_SPKG_CONFIGURE_BASE([gcc], [ SAGE_SRC="$SAGE_SRC" ]) fi - - # We redo this later. - # (Allow debugging of individual packages.) - # But we print the messages for convenience. - if test "x$ORIGINAL_CFLAGS" = "x"; then - # Evaluate SAGE_DEBUG: - if test "x$SAGE_DEBUG" = "xyes" ; then - CFLAGS="-Og -g" - CFLAGS_O3="-Og -g" - else - if test "x$SAGE_DEBUG" = "xno" ; then - CFLAGS="-O2" - CFLAGS_O3="-O3" - else - CFLAGS="-O2 -g" - CFLAGS_O3="-O3 -g" - fi - fi - CFLAGS="${CFLAGS_NON_NATIVE} - CFLAGS_O3="${CFLAGS_O3_NON_NATIVE} - else - # Respect user environment variable. - CFLAGS="${CFLAGS} - CFLAGS_O3="${CFLAGS} - fi - - AC_MSG_NOTICE(ORIGINAL_CFLAGS=$ORIGINAL_CFLAGS) - AC_MSG_NOTICE(CFLAGS=$CFLAGS) - AC_MSG_NOTICE(CFLAGS_O3=$CFLAGS_O3) - ], , , [ # Trac #27907: Find location of crti.o from the system CC, in case we build our own gcc AC_MSG_CHECKING([for the location of crti.o]) From b6e5b1110ed267f13b7e41cbb1ba04a86113a3a3 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 30 Nov 2020 09:08:24 +0100 Subject: [PATCH 30/40] fixed shell syntax --- build/bin/sage-build-env | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build/bin/sage-build-env b/build/bin/sage-build-env index 3a017865934..bf0029f2e5f 100644 --- a/build/bin/sage-build-env +++ b/build/bin/sage-build-env @@ -25,24 +25,24 @@ # 1) environment variables # 2) flags set at configuration time if [ "x$CFLAGS" == "x" ]; then - export $ORIGINAL_CFLAGS = "$CONFIGURED_CFLAGS" + export $ORIGINAL_CFLAGS="$CONFIGURED_CFLAGS" else - export $ORIGINAL_CFLAGS = "$CFLAGS" + export $ORIGINAL_CFLAGS="$CFLAGS" fi if [ "x$CXXFLAGS" == "x" ]; then - export $ORIGINAL_CXXFLAGS = "$CONFIGURED_CXXFLAGS" + export $ORIGINAL_CXXFLAGS="$CONFIGURED_CXXFLAGS" else - export $ORIGINAL_CXXFLAGS = "$CXXFLAGS" + export $ORIGINAL_CXXFLAGS="$CXXFLAGS" fi if [ "x$FCFLAGS" == "x" ]; then - export $ORIGINAL_FCFLAGS = "$CONFIGURED_FCFLAGS" + export $ORIGINAL_FCFLAGS="$CONFIGURED_FCFLAGS" else - export $ORIGINAL_FCFLAGS = "$FCFLAGS" + export $ORIGINAL_FCFLAGS="$FCFLAGS" fi if [ "x$F77FLAGS" == "x" ]; then - export $ORIGINAL_F77FLAGS = "$CONFIGURED_F77FLAGS" + export $ORIGINAL_F77FLAGS="$CONFIGURED_F77FLAGS" else - export $ORIGINAL_F77FLAGS = "$F77FLAGS" + export $ORIGINAL_F77FLAGS="$F77FLAGS" fi # We optimize according to $SAGE_DEBUG. From 431d14ce9603452194a366c5fec6c9295fae1b20 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 30 Nov 2020 09:15:34 +0100 Subject: [PATCH 31/40] source in sage-spkg --- build/bin/sage-spkg | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg index c497a29ca38..35851f6aee2 100755 --- a/build/bin/sage-spkg +++ b/build/bin/sage-spkg @@ -171,12 +171,19 @@ fi . sage-env-config . sage-env - if [ $? -ne 0 ]; then error_msg "Error setting environment variables by sourcing sage-env" exit 1 fi +. sage-build-env-config +. sage-build-env + +if [ $? -ne 0 ]; then + error_msg "Error setting environment variables by sourcing sage-build-env" + exit 1 +fi + if [ -z "$SAGE_BUILD_DIR" ]; then export SAGE_BUILD_DIR="$SAGE_LOCAL/var/tmp/sage/build" fi From 9c5e8a245aae24288d3a922666c3abbe41a44747 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 30 Nov 2020 09:23:55 +0100 Subject: [PATCH 32/40] add references to `bin/sage-build-env` and `bin/sage-build-env-config` --- build/make/Makefile.in | 4 ++++ build/pkgs/sagelib/src/setup.py | 2 ++ src/setup.py | 2 ++ 3 files changed, 8 insertions(+) diff --git a/build/make/Makefile.in b/build/make/Makefile.in index b487b9ac6aa..ba7b74d10ea 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -550,6 +550,8 @@ endif # $(AM_V_at)cd '$SAGE_ROOT' && \\ # . '$SAGE_ROOT/src/bin/sage-env-config' && \\ # . '$SAGE_ROOT/src/bin/sage-env' && \\ +# . '$SAGE_ROOT/src/bin/sage-build-env-config' && \\ +# . '$SAGE_ROOT/src/bin/sage-build-env' && \\ # sage-logger -p '$SAGE_ROOT/build/pkgs//spkg-install' '$(SAGE_LOGS)/.log' # # : $(INST)/- @@ -558,6 +560,8 @@ endif # -$(AM_V_at)cd '$SAGE_ROOT' && \\ # . '$SAGE_ROOT/src/bin/sage-env-config' && \\ # . '$SAGE_ROOT/src/bin/sage-env' && \\ +# . '$SAGE_ROOT/src/bin/sage-build-env-config' && \\ +# . '$SAGE_ROOT/src/bin/sage-build-env' && \\ # '$SAGE_ROOT/build/pkgs/$PKG_NAME/spkg-uninstall' # Positional arguments: diff --git a/build/pkgs/sagelib/src/setup.py b/build/pkgs/sagelib/src/setup.py index b740bf96894..10d63884782 100755 --- a/build/pkgs/sagelib/src/setup.py +++ b/build/pkgs/sagelib/src/setup.py @@ -149,6 +149,8 @@ 'bin/sage-env', 'bin/sage-env-config', # sage-env-config.in -- not to be installed', + 'bin/sage-build-env', + 'bin/sage-build-env-config', 'bin/sage-gdb-commands', 'bin/sage-grep', 'bin/sage-grepdoc', diff --git a/src/setup.py b/src/setup.py index cad807eca0e..cbe469876ec 100755 --- a/src/setup.py +++ b/src/setup.py @@ -149,6 +149,8 @@ 'bin/sage-env', 'bin/sage-env-config', # sage-env-config.in -- not to be installed', + 'bin/sage-build-env', + 'bin/sage-build-env-config', 'bin/sage-gdb-commands', 'bin/sage-grep', 'bin/sage-grepdoc', From 4b8933b0aec03722e34fa1a6d2573a22c3edfedc Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 30 Nov 2020 09:30:04 +0100 Subject: [PATCH 33/40] remove incorrect `$` in `build/bin/sage-build-env` --- build/bin/sage-build-env | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/build/bin/sage-build-env b/build/bin/sage-build-env index bf0029f2e5f..3d4c4c49047 100644 --- a/build/bin/sage-build-env +++ b/build/bin/sage-build-env @@ -25,24 +25,24 @@ # 1) environment variables # 2) flags set at configuration time if [ "x$CFLAGS" == "x" ]; then - export $ORIGINAL_CFLAGS="$CONFIGURED_CFLAGS" + export ORIGINAL_CFLAGS="$CONFIGURED_CFLAGS" else - export $ORIGINAL_CFLAGS="$CFLAGS" + export ORIGINAL_CFLAGS="$CFLAGS" fi if [ "x$CXXFLAGS" == "x" ]; then - export $ORIGINAL_CXXFLAGS="$CONFIGURED_CXXFLAGS" + export ORIGINAL_CXXFLAGS="$CONFIGURED_CXXFLAGS" else - export $ORIGINAL_CXXFLAGS="$CXXFLAGS" + export ORIGINAL_CXXFLAGS="$CXXFLAGS" fi if [ "x$FCFLAGS" == "x" ]; then - export $ORIGINAL_FCFLAGS="$CONFIGURED_FCFLAGS" + export ORIGINAL_FCFLAGS="$CONFIGURED_FCFLAGS" else - export $ORIGINAL_FCFLAGS="$FCFLAGS" + export ORIGINAL_FCFLAGS="$FCFLAGS" fi if [ "x$F77FLAGS" == "x" ]; then - export $ORIGINAL_F77FLAGS="$CONFIGURED_F77FLAGS" + export ORIGINAL_F77FLAGS="$CONFIGURED_F77FLAGS" else - export $ORIGINAL_F77FLAGS="$F77FLAGS" + export ORIGINAL_F77FLAGS="$F77FLAGS" fi # We optimize according to $SAGE_DEBUG. From 071b8ccc520b1b1c6b419465da76a26cec99f694 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 30 Nov 2020 18:01:27 +0100 Subject: [PATCH 34/40] Revert "add references to `bin/sage-build-env` and `bin/sage-build-env-config`" This reverts commit 9c5e8a245aae24288d3a922666c3abbe41a44747. --- build/make/Makefile.in | 4 ---- build/pkgs/sagelib/src/setup.py | 2 -- src/setup.py | 2 -- 3 files changed, 8 deletions(-) diff --git a/build/make/Makefile.in b/build/make/Makefile.in index ba7b74d10ea..b487b9ac6aa 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -550,8 +550,6 @@ endif # $(AM_V_at)cd '$SAGE_ROOT' && \\ # . '$SAGE_ROOT/src/bin/sage-env-config' && \\ # . '$SAGE_ROOT/src/bin/sage-env' && \\ -# . '$SAGE_ROOT/src/bin/sage-build-env-config' && \\ -# . '$SAGE_ROOT/src/bin/sage-build-env' && \\ # sage-logger -p '$SAGE_ROOT/build/pkgs//spkg-install' '$(SAGE_LOGS)/.log' # # : $(INST)/- @@ -560,8 +558,6 @@ endif # -$(AM_V_at)cd '$SAGE_ROOT' && \\ # . '$SAGE_ROOT/src/bin/sage-env-config' && \\ # . '$SAGE_ROOT/src/bin/sage-env' && \\ -# . '$SAGE_ROOT/src/bin/sage-build-env-config' && \\ -# . '$SAGE_ROOT/src/bin/sage-build-env' && \\ # '$SAGE_ROOT/build/pkgs/$PKG_NAME/spkg-uninstall' # Positional arguments: diff --git a/build/pkgs/sagelib/src/setup.py b/build/pkgs/sagelib/src/setup.py index 10d63884782..b740bf96894 100755 --- a/build/pkgs/sagelib/src/setup.py +++ b/build/pkgs/sagelib/src/setup.py @@ -149,8 +149,6 @@ 'bin/sage-env', 'bin/sage-env-config', # sage-env-config.in -- not to be installed', - 'bin/sage-build-env', - 'bin/sage-build-env-config', 'bin/sage-gdb-commands', 'bin/sage-grep', 'bin/sage-grepdoc', diff --git a/src/setup.py b/src/setup.py index cbe469876ec..cad807eca0e 100755 --- a/src/setup.py +++ b/src/setup.py @@ -149,8 +149,6 @@ 'bin/sage-env', 'bin/sage-env-config', # sage-env-config.in -- not to be installed', - 'bin/sage-build-env', - 'bin/sage-build-env-config', 'bin/sage-gdb-commands', 'bin/sage-grep', 'bin/sage-grepdoc', From c51e752495cf323c27f089c2cd2d870fbd3abad6 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Mon, 30 Nov 2020 18:04:18 +0100 Subject: [PATCH 35/40] correct comments to makefile --- build/make/Makefile.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/make/Makefile.in b/build/make/Makefile.in index b487b9ac6aa..97d648f95f9 100644 --- a/build/make/Makefile.in +++ b/build/make/Makefile.in @@ -550,6 +550,8 @@ endif # $(AM_V_at)cd '$SAGE_ROOT' && \\ # . '$SAGE_ROOT/src/bin/sage-env-config' && \\ # . '$SAGE_ROOT/src/bin/sage-env' && \\ +# . '$SAGE_ROOT/build/bin/sage-build-env-config' && \\ +# . '$SAGE_ROOT/build/bin/sage-build-env' && \\ # sage-logger -p '$SAGE_ROOT/build/pkgs//spkg-install' '$(SAGE_LOGS)/.log' # # : $(INST)/- @@ -558,6 +560,8 @@ endif # -$(AM_V_at)cd '$SAGE_ROOT' && \\ # . '$SAGE_ROOT/src/bin/sage-env-config' && \\ # . '$SAGE_ROOT/src/bin/sage-env' && \\ +# . '$SAGE_ROOT/build/bin/sage-build-env-config' && \\ +# . '$SAGE_ROOT/build/bin/sage-build-env' && \\ # '$SAGE_ROOT/build/pkgs/$PKG_NAME/spkg-uninstall' # Positional arguments: From aa7ecd6ef0fd94e9d3a42c1c496f2138cc76fc91 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Thu, 3 Dec 2020 18:51:15 +0100 Subject: [PATCH 36/40] fix that we might have changed $FCFLAGS during configure --- build/bin/sage-build-env | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/build/bin/sage-build-env b/build/bin/sage-build-env index 3d4c4c49047..ebe24994aba 100644 --- a/build/bin/sage-build-env +++ b/build/bin/sage-build-env @@ -78,8 +78,15 @@ if [ "x$ORIGINAL_FCFLAGS" == "x" ]; then export FCFLAGS="$CFLAGS" export FCFLAGS_O3="$CFLAGS_O3" else - export FCFLAGS="$ORIGINAL_FCFLAGS" - export FCFLAGS_O3="$ORIGINAL_FCFLAGS" + # If `FCFLAGS` wasn't set, it might have been set to ` -ffree-form` + # during configuration. + if [ "x$ORIGINAL_FCFLAGS" == "x -ffree-form" ]; then + export FCFLAGS="$CFLAGS -ffree-form" + export FCFLAGS_O3="$CFLAGS_O3 -ffree-form" + else + export FCFLAGS="$ORIGINAL_FCFLAGS" + export FCFLAGS_O3="$ORIGINAL_FCFLAGS" + fi fi # Copy FCFLAGS to F77FLAGS if this is not set. From 94326db15e38576990696e59347cb857a5ecb73e Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Thu, 3 Dec 2020 19:35:45 +0100 Subject: [PATCH 37/40] better solution for dealing with -ffree-form --- build/bin/sage-build-env | 11 ++--------- build/bin/sage-build-env-config.in | 8 ++++---- configure.ac | 8 ++++---- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/build/bin/sage-build-env b/build/bin/sage-build-env index ebe24994aba..3d4c4c49047 100644 --- a/build/bin/sage-build-env +++ b/build/bin/sage-build-env @@ -78,15 +78,8 @@ if [ "x$ORIGINAL_FCFLAGS" == "x" ]; then export FCFLAGS="$CFLAGS" export FCFLAGS_O3="$CFLAGS_O3" else - # If `FCFLAGS` wasn't set, it might have been set to ` -ffree-form` - # during configuration. - if [ "x$ORIGINAL_FCFLAGS" == "x -ffree-form" ]; then - export FCFLAGS="$CFLAGS -ffree-form" - export FCFLAGS_O3="$CFLAGS_O3 -ffree-form" - else - export FCFLAGS="$ORIGINAL_FCFLAGS" - export FCFLAGS_O3="$ORIGINAL_FCFLAGS" - fi + export FCFLAGS="$ORIGINAL_FCFLAGS" + export FCFLAGS_O3="$ORIGINAL_FCFLAGS" fi # Copy FCFLAGS to F77FLAGS if this is not set. diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index 29ad8f10961..7d42cdad717 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -32,10 +32,10 @@ if [ "x$SAGE_DEBUG" == "x" ]; then fi # The configured compilation flags. -export CONFIGURED_CFLAGS="@CFLAGS@" -export CONFIGURED_CXXFLAGS="@CXXFLAGS@" -export CONFIGURED_FCFLAGS="@FCFLAGS@" -export CONFIGURED_F77FLAGS="@F77FLAGS@" +export CONFIGURED_CFLAGS="@CONFIGURED_CFLAGS@" +export CONFIGURED_CXXFLAGS="@CONFIGURED_CXXFLAGS@" +export CONFIGURED_FCFLAGS="@CONFIGURED_FCFLAGS@" +export CONFIGURED_F77FLAGS="@CONFIGURED_F77FLAGS@" # This is usually blank if the system GMP is used, or $SAGE_LOCAL otherwise export SAGE_GMP_PREFIX="@SAGE_GMP_PREFIX@" diff --git a/configure.ac b/configure.ac index 659c258f0a6..d819fa5576d 100644 --- a/configure.ac +++ b/configure.ac @@ -313,10 +313,10 @@ AX_PROG_PERL_VERSION([5.8.0],[],[ ############################################################################### # Save compiler flags as configured by the user. -AC_SUBST(CFLAGS, "$CFLAGS") -AC_SUBST(CXXFLAGS, "$CXXFLAGS") -AC_SUBST(FCFLAGS, "$FCFLAGS") -AC_SUBST(F77FLAGS, "$F77FLAGS") +AC_SUBST(CONFIGURED_CFLAGS, "$CFLAGS") +AC_SUBST(CONFIGURED_CXXFLAGS, "$CXXFLAGS") +AC_SUBST(CONFIGURED_FCFLAGS, "$FCFLAGS") +AC_SUBST(CONFIGURED_F77FLAGS, "$F77FLAGS") SAGE_CHECK_CONDA_COMPILERS From 87dae61577f33d1572ae140ee32fe32b3470e7d4 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Thu, 3 Dec 2020 21:05:39 +0100 Subject: [PATCH 38/40] keep FCFLAGS during gfortran configure --- build/bin/sage-build-env-config.in | 8 ++++---- build/pkgs/gfortran/spkg-configure.m4 | 17 +++++++++++++++++ configure.ac | 8 ++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/build/bin/sage-build-env-config.in b/build/bin/sage-build-env-config.in index 7d42cdad717..29ad8f10961 100644 --- a/build/bin/sage-build-env-config.in +++ b/build/bin/sage-build-env-config.in @@ -32,10 +32,10 @@ if [ "x$SAGE_DEBUG" == "x" ]; then fi # The configured compilation flags. -export CONFIGURED_CFLAGS="@CONFIGURED_CFLAGS@" -export CONFIGURED_CXXFLAGS="@CONFIGURED_CXXFLAGS@" -export CONFIGURED_FCFLAGS="@CONFIGURED_FCFLAGS@" -export CONFIGURED_F77FLAGS="@CONFIGURED_F77FLAGS@" +export CONFIGURED_CFLAGS="@CFLAGS@" +export CONFIGURED_CXXFLAGS="@CXXFLAGS@" +export CONFIGURED_FCFLAGS="@FCFLAGS@" +export CONFIGURED_F77FLAGS="@F77FLAGS@" # This is usually blank if the system GMP is used, or $SAGE_LOCAL otherwise export SAGE_GMP_PREFIX="@SAGE_GMP_PREFIX@" diff --git a/build/pkgs/gfortran/spkg-configure.m4 b/build/pkgs/gfortran/spkg-configure.m4 index dde19d22bfb..73a0346b0df 100644 --- a/build/pkgs/gfortran/spkg-configure.m4 +++ b/build/pkgs/gfortran/spkg-configure.m4 @@ -31,6 +31,16 @@ AC_DEFUN([SAGE_MUST_INSTALL_GFORTRAN], [ fi ]) +dnl This macro saves current FCFLAGS for later use. +AC_DEFUN([SAGE_SAVE_FCFLAGS], [ + sage_saved_fcflags=$FCFLAGS +]) + +dnl This macro restores saved FCFLAGS. +AC_DEFUN([SAGE_RESTORE_FCFLAGS], [ + FCFLAGS=$sage_saved_fcflags +]) + SAGE_SPKG_CONFIGURE([gfortran], [ AC_REQUIRE([SAGE_SPKG_CONFIGURE_GCC]) @@ -40,12 +50,19 @@ SAGE_SPKG_CONFIGURE([gfortran], [ # This helps verify the compiler works too, so if some idiot sets FC to # /usr/bin/ls, we will at least know it's not a working Fortran # compiler. + AC_REQUIRE([SAGE_SAVE_FCFLAGS]) AC_FC_FREEFORM([SAGE_HAVE_FC_FREEFORM=yes], [ AC_MSG_NOTICE([Your Fortran compiler does not accept free-format source code]) AC_MSG_NOTICE([which means the compiler is either seriously broken, or]) AC_MSG_NOTICE([is too old to build Sage.]) SAGE_HAVE_FC_FREEFORM=no]) + # AC_FC_FREEFORM may have added flags. + # However, it is up to the individual package how they invoke the + # Fortran compiler. + # We only check here, whether the compiler is suitable. + AC_REQUIRE([SAGE_RESTORE_FCFLAGS]) + AS_VAR_IF(SAGE_HAVE_FC_FREEFORM, [no], [ AS_VAR_SET(sage_spkg_install_gfortran, [yes]) ]) diff --git a/configure.ac b/configure.ac index d819fa5576d..659c258f0a6 100644 --- a/configure.ac +++ b/configure.ac @@ -313,10 +313,10 @@ AX_PROG_PERL_VERSION([5.8.0],[],[ ############################################################################### # Save compiler flags as configured by the user. -AC_SUBST(CONFIGURED_CFLAGS, "$CFLAGS") -AC_SUBST(CONFIGURED_CXXFLAGS, "$CXXFLAGS") -AC_SUBST(CONFIGURED_FCFLAGS, "$FCFLAGS") -AC_SUBST(CONFIGURED_F77FLAGS, "$F77FLAGS") +AC_SUBST(CFLAGS, "$CFLAGS") +AC_SUBST(CXXFLAGS, "$CXXFLAGS") +AC_SUBST(FCFLAGS, "$FCFLAGS") +AC_SUBST(F77FLAGS, "$F77FLAGS") SAGE_CHECK_CONDA_COMPILERS From 7577dd41f29981722e970606664cfc8651b6a6bb Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Fri, 4 Dec 2020 08:34:47 +0100 Subject: [PATCH 39/40] added quotes --- build/pkgs/gfortran/spkg-configure.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/pkgs/gfortran/spkg-configure.m4 b/build/pkgs/gfortran/spkg-configure.m4 index 73a0346b0df..e867f39ff48 100644 --- a/build/pkgs/gfortran/spkg-configure.m4 +++ b/build/pkgs/gfortran/spkg-configure.m4 @@ -33,12 +33,12 @@ AC_DEFUN([SAGE_MUST_INSTALL_GFORTRAN], [ dnl This macro saves current FCFLAGS for later use. AC_DEFUN([SAGE_SAVE_FCFLAGS], [ - sage_saved_fcflags=$FCFLAGS + sage_saved_fcflags="$FCFLAGS" ]) dnl This macro restores saved FCFLAGS. AC_DEFUN([SAGE_RESTORE_FCFLAGS], [ - FCFLAGS=$sage_saved_fcflags + FCFLAGS="$sage_saved_fcflags" ]) From 3bb309944b7e8542b2ac88ed3c9d9a60e68644d7 Mon Sep 17 00:00:00 2001 From: Jonathan Kliem Date: Thu, 10 Dec 2020 09:18:26 +0100 Subject: [PATCH 40/40] prepare preciouos variables --- configure.ac | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/configure.ac b/configure.ac index 659c258f0a6..b7773be6bff 100644 --- a/configure.ac +++ b/configure.ac @@ -91,12 +91,16 @@ AC_ARG_ENABLE([fat-binary], [AC_SUBST(SAGE_FAT_BINARY, "yes")], []) +AC_ARG_VAR(SAGE_FAT_BINARY, set to "yes" to build binaries that will run on the widest range of target CPUs (but not relocatable)) + AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug={no|symbols|yes}], [controls debugging support: "no" debugging; debugging "symbols" (default); build debug version ("yes")])], [AC_SUBST(SAGE_DEBUG, $enableval)], []) +AC_ARG_VAR(SAGE_DEBUG, controls debugging support: "no" debugging; debugging "symbols" (default); build debug version ("yes")) + # Check whether we are on a supported platform AC_CANONICAL_BUILD() AC_CANONICAL_HOST() @@ -313,10 +317,15 @@ AX_PROG_PERL_VERSION([5.8.0],[],[ ############################################################################### # Save compiler flags as configured by the user. +# We have to redo this, because otherwise `AC_PROG_CC` will just overwrite them. AC_SUBST(CFLAGS, "$CFLAGS") AC_SUBST(CXXFLAGS, "$CXXFLAGS") AC_SUBST(FCFLAGS, "$FCFLAGS") AC_SUBST(F77FLAGS, "$F77FLAGS") +AC_ARG_VAR(CFLAGS, C compiler flags) +AC_ARG_VAR(CXXFLAGS, C compiler flags) +AC_ARG_VAR(FCFLAGS, Fortran compiler flags) +AC_ARG_VAR(F77CFLAGS, Fortran 77 compiler flags) SAGE_CHECK_CONDA_COMPILERS