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

Commit

Permalink
Merge branch 'u/gh-kliem/gather_and_clean_up_compile_flags' of git://…
Browse files Browse the repository at this point in the history
…trac.sagemath.org/sage into u/gh-kliem/gather_and_clean_up_compile_flags_new
  • Loading branch information
Jonathan Kliem committed Oct 17, 2020
2 parents 1e728ac + 2ff5630 commit b6cf7c1
Show file tree
Hide file tree
Showing 38 changed files with 192 additions and 274 deletions.
7 changes: 5 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,9 @@
# 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@"

# 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 +44,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 +53,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
74 changes: 74 additions & 0 deletions build/make/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,80 @@ 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)

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
40 changes: 35 additions & 5 deletions build/pkgs/gcc/spkg-configure.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -201,6 +201,36 @@ 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])
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
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
8 changes: 0 additions & 8 deletions build/pkgs/gsl/spkg-install.in
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 0 additions & 6 deletions build/pkgs/iml/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: 1 addition & 6 deletions build/pkgs/iml/spkg-install.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 0 additions & 8 deletions build/pkgs/latte_int/spkg-check.in
Original file line number Diff line number Diff line change
@@ -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
15 changes: 0 additions & 15 deletions build/pkgs/lcalc/spkg-build.in
Original file line number Diff line number Diff line change
@@ -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=""
Expand Down
Loading

0 comments on commit b6cf7c1

Please sign in to comment.