I feel foolish because I figured it out right after posting, but I figured I'd share because it isn't intuitive and hopefully this will save someone some time.
The package you want to install is not gcc. You want to install gcc-toolset-9. You will notice after installation that you will still get 8.x if you do a gcc --version. gcc-toolset-9 installs to /opt. The idea is to give you a separate development environment. See this documentation. After installation you can run the updated gcc with /opt/rh/gcc-toolset-9/<username>/bin/gcc.
As @Stephen Kitt pointed out, you can actually get a shell with the updated toolset by running scl enable gcc-toolset-9 bash. Running this command will open a new bash session with the environment variables appropriately updated.
You can also run gcc v.9 directly with scl enable gcc-toolset-9 gcc <your_gcc_args>. See this documentation for details.
rhel - How to install gcc 9.X on RHEL8? - Unix & Linux Stack Exchange
rhel8 - How to Install devtoolset 8 in RHEL 8 image - Stack Overflow
linux - "scl load gcc-toolset-11" run failed - Stack Overflow
linux - On el8/el9/newer, how do you get newer versions of software like python3, gcc, java, etc? - Stack Overflow
devtoolset is called gcc-toolset in RHEL8.
The following commands worked for me:
microdnf install -y gcc-toolset-12
scl enable gcc-toolset-12 bash
gcc --version
# gcc (GCC) 12.1.1 20220628 (Red Hat 12.1.1-3)
According to that article, you can check if you have access to Red Hat Software Collections (RHSCL) by running the following command by the root user:
$ su -
# subscription-manager repos --list | egrep rhscl
If you have, enable necessary software repo and then install devtoolset:
# subscription-manager repos --enable rhel-7-server-optional-rpms
# yum install devtoolset-8
According to the man page for gcc-toolset-11, it only supports the enable command. It also states that you can run scl gcc-toolset-11 enable bash to execute the bash command with the gcc-toolset-11 environment, which should be equivalent to what the load command would do.
Example:
[root@localhost ~]# scl enable gcc-toolset-11 bash [root@localhost ~]# gcc --version gcc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9.1.0.3) Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [root@localhost ~]# exit exit [root@localhost ~]# gcc --version gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-18.0.2) Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. [root@localhost ~]#
Try to use enable instead of load .
See reference: CentOS Software Collections (SCL)
Currently there is only gcc-11.2 available in the repo of RHEL 9 Beta. Is there any plan from Redhat to ship some other backward compatible gcc compilers (gcc-8.5, gcc-toolset-9, etc. included in RHEL 8), or only newer versions will be introduced into RHEL 9 appstream? It will be of great convenient to have such packages and fulfill compilation requirements of old stuff like CUDA.