Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge commit '3bb309944b7e8542b2ac88ed3c9d9a60e68644d7' of git://trac…
Browse files Browse the repository at this point in the history
….sagemath.org/sage into t/29124/script-packages-prereq-toolchain-bootstrap
  • Loading branch information
Matthias Koeppe committed Dec 13, 2020
2 parents 571cc49 + 3bb3099 commit c529729
Show file tree
Hide file tree
Showing 42 changed files with 233 additions and 274 deletions.
92 changes: 92 additions & 0 deletions build/bin/sage-build-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# -*- 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.
#
# 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
export CFLAGS="-Og -g"
export CFLAGS_O3="-Og -g"
elif [ "x$SAGE_DEBUG" == "xno" ]; 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 [ "x$ORIGINAL_CXXFLAGS" == "x" ]; 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 [ "x$ORIGINAL_FCFLAGS" == "x" ]; 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 [ "x$ORIGINAL_F77FLAGS" == "x" ]; then
export F77FLAGS="$FCFLAGS"
export F77FLAGS_O3="$FCFLAGS_O3"
else
export F77FLAGS="$ORIGINAL_F77FLAGS"
export F77FLAGS_O3="$ORIGINAL_F77FLAGS"
fi
19 changes: 17 additions & 2 deletions build/bin/sage-build-env-config.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@
# The configured CXX without special flags added that enable C++11 support
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.
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@"
export SAGE_GMP_INCLUDE="@SAGE_GMP_INCLUDE@"
Expand All @@ -41,7 +56,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=<prefix> 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

Expand All @@ -50,7 +65,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=<prefix> 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

Expand Down
9 changes: 8 additions & 1 deletion build/bin/sage-spkg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions build/make/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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/<pkgname>/spkg-install' '$(SAGE_LOGS)/<pkgname>.log'
#
# <pkgname>: $(INST)/<pkgname>-<pkgvers>
Expand All @@ -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:
Expand All @@ -577,6 +581,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)"

Expand All @@ -585,6 +590,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)"

Expand Down
4 changes: 0 additions & 4 deletions build/pkgs/e_antic/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions build/pkgs/ecl/spkg-install.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 3 additions & 11 deletions build/pkgs/eclib/spkg-install.in
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
8 changes: 4 additions & 4 deletions build/pkgs/ecm/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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."
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion build/pkgs/flint/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions build/pkgs/fplll/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions build/pkgs/gap/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions build/pkgs/gc/spkg-check.in
Original file line number Diff line number Diff line change
@@ -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
7 changes: 0 additions & 7 deletions build/pkgs/gc/spkg-install.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions build/pkgs/gf2x/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ cp "$SAGE_ROOT"/config/config.* config

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
Expand Down
17 changes: 17 additions & 0 deletions build/pkgs/gfortran/spkg-configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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])
])
Expand Down
10 changes: 0 additions & 10 deletions build/pkgs/gmp/spkg-install.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit c529729

Please sign in to comment.