gcc: The GNU Compiler Collection or other suitable C and C++ compilers#
This package represents the required C and C++ compilers.
GCC (GNU Compiler Collection) versions 8.x to 12.x are supported.
Clang (LLVM) is also supported.
The required Fortran compiler is represented by the package
For example, if your C compiler is
clang, your C++ compiler is
clang++, and your Fortran compiler is
flang, then you would
need to run:
$ ./configure CC=clang CXX=clang++ FC=flang
Vendor and versions of the C and C++ compilers should match.
Users of older Linux distributions (in particular,
debian-stretch or older,
linuxmint-18 or older)
should upgrade their systems before attempting to install Sage from
source. Users of
opensuse-15.x can install a versioned
gcc system package
and then use:
$ ./configure CC=gcc-8 CXX=g++-8 FC=gfortran-8
or similar. Users on
ubuntu can also install a modern compiler
toolchain using the ubuntu-toolchain-r ppa.
ubuntu-trusty, also the package
binutils-2.26 is required;
after installing it, make it available using
PATH="/usr/lib/binutils-2.26/bin:$PATH". Instead of upgrading their
distribution, users of
centos-7 can install a modern compiler
toolchain using Redhat’s devtoolset.
This package uses the non-standard default
configure --with-system-gcc=force, giving an error at
time when no suitable system compilers are configured.
You can override this using
./configure --without-system-gcc. In
this case, Sage builds and installs the GNU Compiler Collection,
including the C, C++ and Fortran compiler. This is not recommended.
You will need suitable C and C++ compilers from which GCC can
bootstrap itself. There are some known problems with old assemblers,
in particular when building the
packages. You should ensure that your assembler understands all
instructions for your processor. On Linux, this means you need a
recent version of
binutils (not provided by an SPKG); on macOS
you need a recent version of Xcode.
gfortran SPKG becomes a no-op in this case.)
Building Sage from source on Apple Silicon (M1/M2) requires the use of
Apple’s Command Line Tools, and those tools include a suitable
gcc SPKG is not suitable for M1/M2; building it
will likely fail.
GPL version 2 or version 3
Equivalent System Packages#
$ sudo pacman -S gcc
$ apt-cyg install gcc-core gcc-g++ gcc-fortran
$ sudo apt-get install gcc g++
$ sudo yum install gcc gcc-c++ gcc-gfortran
$ sudo pkg install lang/gcc9
$ brew install gcc
$ sudo zypper install gcc-c++
$ sudo xbps-install gcc
If the system package is installed, ./configure will check whether it can be used.