This is guide howto build older GCC using newer one in Fedora. Currently GCC 13 on Fedora 40 using GCC 14. This is needed for running NVIDIA CUDA on Fedora 40.

Check video version of guide, howto build GCC 13 on Fedora 40 using GCC 14:

Support inttf:

Buy Me a Coffee:

Build and Install GCC 13 on Fedora 40 using GCC 14

I use here sudo command for root user commands, if you don’t have/use sudo, then just use your root account directly.

1. Install Needed Packages to Build GCC 13

sudo dnf groupinstall "Development tools"

sudo dnf install mpfr-devel gmp-devel libmpc-devel \
zlib-devel glibc-devel.i686 glibc-devel isl-devel \
g++ gcc-gnat gcc-gdc libgphobos-static

2. Download GCC 13 and signature file

You can use any GCC mirror from GCC mirror sites.

wget https://ftp.gwdg.de/pub/misc/gcc/releases/gcc-13.2.0/gcc-13.2.0.tar.xz \
https://ftp.gwdg.de/pub/misc/gcc/releases/gcc-13.2.0/gcc-13.2.0.tar.xz.sig

3. Verify downloaded GCC package

inttf@fedora:~$ gpg --verify gcc-13.2.0.tar.xz.sig gcc-13.2.0.tar.xz
gpg: Signature made Thu 27 Jul 2023 11:48:25 AM EEST
gpg:                using RSA key 6C35B99309B5FA62
gpg: Can't check signature: No public key
inttf@fedora:~$ gpg --recv-keys 6C35B99309B5FA62
gpg: key 6C35B99309B5FA62: 1 duplicate signature removed
gpg: key 6C35B99309B5FA62: public key "Jakub Jelinek <[email protected]>" imported
gpg: Total number processed: 1
gpg:               imported: 1
inttf@fedora:~$ gpg --verify gcc-13.2.0.tar.xz.sig gcc-13.2.0.tar.xz
gpg: Signature made Thu 27 Jul 2023 11:48:25 AM EEST
gpg:                using RSA key 6C35B99309B5FA62
gpg: Good signature from "Jakub Jelinek <[email protected]>" [unknown]
gpg:                 aka "[jpeg image of size 2839]" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: D3A9 3CAD 751C 2AF4 F8C7  AD51 6C35 B993 09B5 FA62

4. Extract GCC tar.xz

tar xvf gcc-13.2.0.tar.xz

5. Make build directory

cd gcc-13.2.0
mkdir build
cd build

6. Configure GCC 13

../configure --enable-bootstrap \
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto \
--prefix=/usr --program-suffix=-13.2 --mandir=/usr/share/man \
--infodir=/usr/share/info --enable-shared --enable-threads=posix \
--enable-checking=release --enable-multilib --with-system-zlib \
--enable-__cxa_atexit --disable-libunwind-exceptions \
--enable-gnu-unique-object --enable-linker-build-id \
--with-gcc-major-version-only --enable-libstdcxx-backtrace \
--with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu \
--enable-plugin --enable-initfini-array --with-isl \
--enable-offload-targets=nvptx-none --enable-offload-defaulted \
--enable-gnu-indirect-function --enable-cet --with-tune=generic \
--with-arch_32=i686 --build=x86_64-redhat-linux \
--with-build-config=bootstrap-lto --enable-link-serialization=1 \
--with-default-libstdcxx-abi=new --with-build-config=bootstrap-lto

7. Build GCC 13

Use -j parameter to build using multiple cores

make

## OR ##

make -j6

8. Install GCC 13 on Fedora 40

sudo make install

9. Check GCC 13 Installation

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,m2,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-14.0.1-20240411/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none,amdgcn-amdhsa --enable-offload-defaulted --without-cuda-driver --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.1 20240411 (Red Hat 14.0.1-0) (GCC)

$ gcc-13.2 -v
Using built-in specs.
COLLECT_GCC=gcc-13.2
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/13/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr --program-suffix=-13.2 --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-libstdcxx-zoneinfo=/usr/share/zoneinfo --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-offload-targets=nvptx-none --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1 --with-default-libstdcxx-abi=new --with-build-config=bootstrap-lto
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (GCC)

10. Uninstall GCC 13

cd build/gcc

sudo make uninstall

11. Support inttf

Buy Me a Coffee: