Red Hat Training

A Red Hat training course is available for RHEL 8

Chapter 15. Using the GCC Toolset container images

The GCC Toolset 10 components are available in the two container images:

  • GCC Toolset 10 Toolchain
  • GCC Toolset 10 Perftools

The GCC Toolset container images are based on the rhel8 base image and are available for all architectures supported by RHEL 8:

  • AMD and Intel 64-bit architectures
  • The 64-bit ARM architecture
  • IBM Power Systems, Little Endian
  • 64-bit IBM Z

15.1. GCC Toolset container images contents

Tools versions provided in the GCC Toolset 10 container images match the GCC Toolset 10 components versions.

The GCC Toolset 10 Toolchain contents

The rhel8/gcc-toolset-10-toolchain image provides the GCC compiler, the GDB debugger, and other development-related tools. The container image consists of the following components:

ComponentPackage

gcc

gcc-toolset-10-gcc

g++

gcc-toolset-10-gcc-c++

gfortran

gcc-toolset-10-gcc-gfortran

gdb

gcc-toolset-10-gdb

The GCC Toolset 10 Perftools contents

The rhel8/gcc-toolset-10-perftools image provides a number of tools for debugging, performance monitoring, and further analysis of the applications. The container image consists of the following components:

ComponentPackage

Valgrind

gcc-toolset-10-valgrind

SystemTap

gcc-toolset-10-systemtap

Dyninst

gcc-toolset-10-dyninst

elfutils

gcc-toolset-10-elfutils

Additional resources

15.2. Accessing and running the GCC Toolset container images

The following section describes how to access and run the GCC Toolset container images.

Prerequisites

  • Podman is installed.

Procedure

  1. Access the Red Hat Container Registry using your Customer Portal credentials:

    $ podman login registry.redhat.io
    Username: username
    Password: ********
  2. Pull a container image you require by running a relevant command as root:

    # podman pull registry.redhat.io/rhel8/gcc-toolset-10-toolchain
    # podman pull registry.redhat.io/rhel8/gcc-toolset-10-perftools
    Note

    On RHEL 8.1 and later versions, you can set up your system to work with containers as a non-root user. For details, see Running containers as root or rootless.

  3. Optional: Check that pulling was successful by running a command that lists all container images on your local system:

    # podman images
  4. Run a container by launching a bash shell inside a container:

    # podman run -it image_name /bin/bash

    The -i option creates an interactive session; without this option the shell opens and instantly exits.

    The -t option opens a terminal session; without this option you cannot type anything to the shell.

Additional resources

15.3. Example: Using the GCC Toolset 10 Toolchain container image

This example shows how to pull and start using the GCC Toolset 10 Toolchain container image.

Prerequisites

  • Podman is installed.

Procedure

  1. Access the Red Hat Container Registry using your Customer Portal credentials:

    $ podman login registry.redhat.io
    Username: username
    Password: ********
  2. Pull the container image as root:

    # podman pull registry.redhat.io/rhel8/gcc-toolset-10-toolchain
  3. Launch the container image with an interactive shell as root:

    # podman run -it registry.redhat.io/rhel8/gcc-toolset-10-toolchain /bin/bash
  4. Run the GCC Toolset tools as expected. For example, to verify the gcc compiler version, run:

    bash-4.4$ gcc -v
    ...
    gcc version 10.2.1 20200804 (Red Hat 10.2.1-2) (GCC)
  5. To list all packages provided in the container, run:

    bash-4.4$ rpm -qa

15.4. Using SystemTap from the GCC Toolset 10 Perftools container image

The SystemTap tool is distributed in the GCC Toolset 10 Perftools container image. To use this tool, follow the steps listed below.

Prerequisites

  • The GCC Toolset 10 Perftools container image is pulled.

Procedure

  1. Run the image with super-user privileges:

    $ podman run -u root -it --privileged --ipc=host --net=host --pid=host registry.redhat.io/rhel8/gcc-toolset-{gcct-ver}-perftools /bin/bash

    To learn more about super privileged containers, see Running super privileged containers.

  2. Make sure the following packages are installed in the container or install them:

    • kernel
    • kernel-devel
    • kernel-debuginfo

      Important

      The version and release numbers of the above-mentioned kernel packages must match the version and release numbers of the kernel running on the host system.

      • To check the version and release numbers of the host system kernel, run:

        $ uname -r
        4.18.0-193.el8.x86_64
      • To install matching versions of the packages, run the package installation command with the uname command output. For example:

        # yum install kernel-devel-$(uname -r)
      • To install the kernel-debuginfo package, first enable the debug repository by running the following command as root:

        # subscription-manager repos --enable=rhel-8-for-x86_64-baseos-debug-rpms

        To learn more about installing debuginfo packages on RHEL systems, see How can I download or install debuginfo packages for RHEL systems?

  3. Optional: To avoid repeating these steps and reuse this preconfigured container in the future, consider saving it by running:

    $ podman commit new-container-image-name