From 708f8896fa7a7db9f48cb5897b8e10896e31ae7d Mon Sep 17 00:00:00 2001 From: buchel_k Date: Thu, 21 May 2026 14:16:08 +0200 Subject: [PATCH] more details for how to bring the desired compiler to your shell --- .../configuration/software/gcc_compilers.md | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/docs/admin-guide/configuration/software/gcc_compilers.md b/docs/admin-guide/configuration/software/gcc_compilers.md index 2851ba4c..d0ba7e83 100644 --- a/docs/admin-guide/configuration/software/gcc_compilers.md +++ b/docs/admin-guide/configuration/software/gcc_compilers.md @@ -13,7 +13,7 @@ https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/develop To see which versions of the gcc-toolset are available on your system, you can use the following command: ```bash -[root@test ~]# dnf search gcc-toolset | egrep 'gcc-toolset-[0-9]{2}.x86_64' +[root@test ~]# dnf search gcc-toolset | egrep 'gcc-toolset-[0-9]+.x86_64' Last metadata expiration check: 1 day, 7:28:21 ago on Wed 20 May 2026 06:28:36 AM CEST. gcc-toolset-12.x86_64 : Package that installs gcc-toolset-12 gcc-toolset-13.x86_64 : Package that installs gcc-toolset-13 @@ -30,26 +30,21 @@ gcc-toolset-12 After installing the desired gcc-toolset package, you can use the `scl enable` command to switch to the desired version of GCC for a single command or for the current shell session. -To use a specific version of GCC for a single command, you can use the following syntax: +To use a specific version of GCC for a single command, you can use the following syntax (the `$COMMAND` needs to be one single argument string): ```bash -[root@test ~]# scl enable gcc-toolset-12 $COMMAND +[root@test ~]# scl enable gcc-toolset-12 "$COMMAND" ``` +or to spawn a new shell with the compiler ready: ```bash -[root@test ~]# scl enable gcc-toolset-N bash - -[root@test ~]# gcc -v -Using built-in specs. -COLLECT_GCC=gcc -COLLECT_LTO_WRAPPER=/opt/rh/gcc-toolset-12/root/usr/libexec/gcc/x86_64-redhat-linux/12/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,lto --prefix=/opt/rh/gcc-toolset-12/root/usr --mandir=/opt/rh/gcc-toolset-12/root/usr/share/man --infodir=/opt/rh/gcc-toolset-12/root/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-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-12.2.1-20221121/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux -Thread model: posix -Supported LTO compression algorithms: zlib zstd -gcc version 12.2.1 20221121 (Red Hat 12.2.1-7) (GCC) +[root@test ~]# scl enable gcc-toolset-12 bash ``` +To load it into the current shell do (e.g. to be used in `~/.bashrc`): +```bash +source scl_source enable gcc-toolset-12 +``` + + !!! note - In most cases we recommend to use the gcc version shipped with the RHEL version. Beside that we recommend to use the latest version of the gcc-toolset available for your RHEL version, as it will include the latest bug fixes and security patches. + In most cases we recommend to use the gcc version shipped with the RHEL version.