Compilers on SUSE Linux
If you are new to SUSE Linux, you might have wondered why the C compiler on the system is so old. For example, on a SUSE Linux Enterprise Server (SLES) 12 Service Pack (SP) 3 system running on X86-64, the default gcc is version 4.8-6.189! Why isn’t the C compiler a newer version, like gcc version 8?
A SUSE Linux system can have multiple versions of the gcc compiler. The first type of compiler, the one used to compile the version of SUSE Linux that you are running, is known as the “System Compiler”. The “System Compiler” usually does not change throughout the life of the SLES version because changing it would greatly complicate creating patches to maintain the operating system. For example, gcc 4.8 is the SLES 12 “System Compiler” used to compile all SLES 12 releases including all Service Packs. gcc 7-3.3.22 is the “System Compiler” for SLES 15.
The other type of compilers available on SLES are known as a “Toolchain Compilers”. These are the primary compilers for application development and are periodically updated with patches and new stable compiler versions as they become available. Usually there is more than one version available at any point in time. Most developers want to use newer compilers for application development because they provide additional optimization and functionality.
Installing the newer “Toolchain” compilers is easy, but first you must understand a little about the SUSE Linux Modules concept.
SUSE Linux Modules Introduction
SUSE introduced the concept of operating system Modules in SLES 12. SLES Modules are groups of packages with similar use cases and support status that are grouped together into a Module and delivered via a unique repository. SUSE introduced the Module concept to allow delivery of the latest technology in areas of rapid innovation without having to wait for the next SLES Service Pack. SUSE fully maintains and supports the Modules through your SUSE Linux subscription.
With the introduction of SLES 15, Modules have become even more important because the entire SUSE Linux OS is packaged as modules. The SLES 15 installation media consists of a unified Installer and a minimal system for deploying, updating, and registering SUSE Linux Enterprise Server or other SUSE products. Even the ls and ps commands are part of “Basesystem Module 15” module in SLES 15.
During deployment you can add functionality by selecting modules and extensions to be installed. The availability of certain modules or extensions depends on the product you chose in the first step of this installation. For example, in SLES 15, the HPC Module is only available if you selected the SUSE Linux Enterprise for HPC product during the initial installation.
SUSE Linux Modules enable you to install just the set of packages required for the machine’s purpose, making the system lean, fast, and more secure. This modular packaging approach also makes it easy to provide tailor-made images for container and cloud environments. Modules can be added or removed at any time during the lifecycle of the system, allowing you to easily adjust the system to changing requirements. See the Modules Quick Start Guide for more information.
Please note that just activating a Module does not install the packages from that Module—you need to do that separately after activating a Module. To use a package from a Module generally requires two steps: 1) activating the Module and 2) installing the desired packages. Some Modules are pre-activated based on the product you installed. For example, the HPC Module is automatically activated when you install SUSE Linux for High Performance Computing 15.
The Development Tools Module is the SLES 15 Module that includes the most recent compilers such as gcc, debuggers, and other development tools (over 500 packages for SLES 15). The Toolchain Module provided access to newer compilers for SLES 12.
Activating the Development Tools Module using YaST
- Start YaST. # Requires root privileges
- Click Add System Extensions or Modules.
- Select Development Tools Module.
- Press Next to start the activation process for the Development Tools Module
Installing a package (gcc8) from the Development Tools Module
Once the Development Tools Module is activated, you can install packages from the Module. This example uses gcc8.
- Start YaST and click Software then Software management
- Type gcc8 in the search field and click Search.
- Select gcc8 and click Accept.
The gcc8 compiler will now be installed.
And that’s it! You have successfully activated the Development Tools Module and installed gcc8.
Activating the Development Tools Module on SLES 15 using the command line
Now let’s take a different approach and use the command line to perform the same tasks. You will need to have root privileges to perform most of these steps either by su to root or using sudo.
- Activate the Development Tools Module.
sudo SUSEConnect -p sle-module-development-tools/15/x86_64
- Verify that the Development Tools Module is activated.
sudo SUSEConnect –l
In this example, the BaseSystem, Development Tools, Desktop Applications, and Web and Scripting Modules are activated. The other Modules and Extensions are available for activation.
- Check the status of gcc on this system.
zypper search gcc
You can see that the system C compiler is gcc7 and is installed (i) and gcc8 is available for installation.
- Install the gcc8 compiler.
sudo zypper install gcc8 # Must be root
- Verify that the gcc8 compiler was installed
zypper search gcc8
- Check the gcc8 version.
You should now understand how to activate a SUSE Module and install a package from the module. This same approach can be applied to the other SUSE Modules, such as the HPC Module. Modules are a key concept of SUSE product packaging, particularly for SLES 15.