Chapter 10. Red Hat Developer Toolset Images

Red Hat Developer Toolset is a Red Hat offering for developers on the Red Hat Enterprise Linux platform. It provides a complete set of development and performance analysis tools that can be installed and used on multiple versions of Red Hat Enterprise Linux. Executables built with the Red Hat Developer Toolset toolchain can then also be deployed and run on multiple versions of Red Hat Enterprise Linux. For detailed compatibility information, see Red Hat Developer Toolset user Guide, section 1.3 Compatibility.

10.1. Running Red Hat Developer Toolset Tools from Pre-Built Container Images

To display general usage information for pre-built Red Hat Developer Toolset docker-formatted container images that you have already pulled to your local machine, run the following command as root:

# docker run image_name usage

To launch an interactive shell within a pre-built docker-formatted container image, run the following command as root:

# docker run -ti image_name /bin/bash -l

In both of the above commands, substitute the image_name parameter with the name of the container image you pulled to your local system and now want to use.

For example, to launch an interactive shell within the container image with selected toolchain components, run the following command as root:

# docker run -ti rhscl/devtoolset-7-toolchain-rhel7 /bin/bash -l

Example 10.1. Using GCC in the Pre-Built Red Hat Developer Toolset Toolchain Image

This example illustrates how to obtain and launch the pre-built docker-formatted container image with selected toolchain components of the Red Hat Developer Toolset and how to run the gcc compiler within that image.

  1. Make sure you have a Docker environment set up properly on your system by following instructions at Getting Docker in RHEL 7.
  2. Pull the pre-built toolchain Red Hat Developer Toolset container image from the official Red Hat Container Registry:

    # docker pull rhscl/devtoolset-7-toolchain-rhel7
  3. To launch the container image with an interactive shell, issue the following command:

    # docker run -ti rhscl/devtoolset-7-toolchain-rhel7 /bin/bash -l
  4. To launch the container as a regular (non-root) user, use the sudo command. To map a directory from the host system to the container file system, include the -v (or --volume) option in the docker command:

    $ sudo docker run -v ~/Source:/src -ti rhscl/devtoolset-7-toolchain-rhel7 /bin/bash -l

    In the above command, the host’s ~/Source/ directory is mounted as the /src/ directory within the container.

  5. Once you are in the container’s interactive shell, you can run Red Hat Developer Toolset tools as expected. For example, to verify the version of the gcc compiler, run:

    bash-4.2$ gcc -v
    [...]
    gcc version 6.3.1 20170216 (Red Hat 6.3.1-3) (GCC)

10.2. Using Container Images Built from Dockerfiles

Dockerfiles are available for selected Red Hat Developer Toolset components. Dockerfiles are text files that contain instructions for automated building of docker-formatted container images.

Red Hat Developer Toolset 7.0 for Red Hat Enterprise Linux 7 is distributed with the following Dockerfiles:

  • devtoolset-7-toolchain
  • devtoolset-7-perftools

10.2.1. Obtaining Dockerfiles

The Red Hat Developer Toolset Dockerfiles are provided by the package devtoolset-7-dockerfiles. The package contains individual Dockerfiles for building docker-formatted container images with individual components and a meta-Dockerfile for building a docker-formatted container image with all the components offered. To be able to use the Dockerfiles, install this package by executing:

# yum install devtoolset-7-dockerfiles

Use the RHSM channel rhel-server-rhscl-7-rpms. In order to enable it, follow the instructions at Getting Access to Red Hat Developer Toolset.

10.2.2. Building Container Images

Change to the directory where the Dockerfile is installed and run the following command as root:

# docker build -t image_name

Replace image_name with the desired name for the new image.

Example 10.2. Building a Container Image with a Red Hat Developer Toolset Component

To build a docker-formatted container image for deploying the perftools tools in a container, follow the instructions below:

  1. Make sure you have a Docker environment set up properly on your system by following instructions at Getting Docker in RHEL 7.
  2. Install the package containing the Red Hat Developer Toolset Dockerfiles:

    # yum install devtoolset-7-dockerfiles
  3. Determine where the Dockerfile for the required component is located:

    # rpm -ql devtoolset-7-dockerfiles | grep "perftools-docker/Dockerfile"
    /opt/rh/devtoolset-7/root/usr/share/devtoolset-7-dockerfiles/rhel7/devtoolset-7-perftools-docker/Dockerfile
  4. Change to the directory where the required Dockerfile is installed:

    # cd /opt/rh/devtoolset-7/root/usr/share/devtoolset-7-dockerfiles/rhel7/devtoolset-7-perftools-docker/
  5. Build the container image:

    # docker build -t devtoolset-7-my-perftools .

    Replace devtoolset-7-my-perftools with the name you wish to assign to your resulting container image.

10.2.3. Running Red Hat Developer Toolset Tools from Custom-Built Container Images

To display general usage information for images built from Red Hat Developer Toolset Dockerfiles (see Section 10.2.2, “Building Container Images”), run the following command as root:

docker run image_name container-usage

To launch an interactive shell within a docker-formatted container image you built, run the following command as root:

docker run -ti image_name /bin/bash -l

In both of the above commands, substitute the image_name parameter with the name of the container image you chose when building it.

Example 10.3. Using elfutils in a Custom-Built Red Hat Developer Toolset Image

This example illustrates how to launch a custom-built docker-formatted container image with the elfutils component and how to run the eu-size tool within that image.

  1. To launch the container image with an interactive shell, issue the following command:

    # docker run -ti devtoolset-7-my-perftools /bin/bash -l
  2. To launch the container as a regular (non-root) user, use the sudo command. To map a directory from the host system to the container file system, include the -v (or --volume) option in the docker command:

    $ sudo docker run -v ~/Source:/src -ti devtoolset-7-my-perftools /bin/bash -l

    In the above command, the host’s ~/Source/ directory is mounted as the /src/ directory within the container.

  3. Once you are in the container’s interactive shell, you can run Red Hat Developer Toolset tools as expected. For example, to verify the version of the eu-size tool, run:

    bash-4.2$ eu-size -V
    size (elfutils) 0.168
    [...]

10.3. Additional Resources

For more information about Red Hat Developer Toolset, see the following online resources:

10.4. Red Hat Developer Toolset Toolchain

10.4.1. Description

The Red Hat Developer Toolset Toolchain images provide the GNU Compiler Collection (GCC) and GNU Debugger (GDB).

The rhscl/devtoolset-8-toolchain-rhel7 image provides content corresponding to the following packages:

ComponentVersionPackage

gcc

8.2.1

devtoolset-8-gcc

g++

devtoolset-8-gcc-c++

gfortran

devtoolset-8-gcc-fortran

gdb

8.2

devtoolset-8-gdb

Additionally, the devtoolset-8-binutils package is included as a dependency.

The rhscl/devtoolset-7-toolchain-rhel7 image provides content corresponding to the following packages:

ComponentVersionPackage

gcc

7.3.1

devtoolset-7-gcc

g++

devtoolset-7-gcc-c++

gfortran

devtoolset-7-gcc-fortran

gdb

8.0.1

devtoolset-7-gdb

10.4.2. Access

To pull the rhscl/devtoolset-8-toolchain-rhel7 image, run the following command as root:

# docker pull registry.access.redhat.com/rhscl/devtoolset-8-toolchain-rhel7

To pull the rhscl/devtoolset-7-toolchain-rhel7 image, run the following command as root:

# docker pull registry.access.redhat.com/rhscl/devtoolset-7-toolchain-rhel7

10.5. Red Hat Developer Toolset Performance Tools

10.5.1. Description

The Red Hat Developer Toolset Performance Tools images provide a number of profiling and performance measurement tools.

The rhscl/devtoolset-8-perftools-rhel7 image provides the following components:

ComponentVersionPackage

dwz

0.12

devtoolset-8-dwz

Dyninst

9.3.2

devtoolset-8-dyninst

elfutils

0.174

devtoolset-8-elfutils

ltrace

0.7.91

devtoolset-8-ltrace

make

4.2.1

devtoolset-8-make

memstomp

0.1.5

devtoolset-8-memstomp

OProfile

1.3.0

devtoolset-8-oprofile

strace

4.24

devtoolset-8-strace

SystemTap

3.3

devtoolset-8-systemtap

Valgrind

3.14.0

devtoolset-8-valgrind

The rhscl/devtoolset-7-perftools-rhel7 image provides the following components:

ComponentVersionPackage

dwz

0.12

devtoolset-7-dwz

Dyninst

9.3.2

devtoolset-7-dyninst

elfutils

0.170

devtoolset-7-elfutils

ltrace

0.7.91

devtoolset-7-ltrace

make

4.2.1

devtoolset-7-make

memstomp

0.1.5

devtoolset-7-memstomp

OProfile

1.2.0

devtoolset-7-oprofile

strace

4.17

devtoolset-7-strace

SystemTap

3.1

devtoolset-7-systemtap

Valgrind

3.13.0

devtoolset-7-valgrind

Additionally, the devtoolset-7-gcc and devtoolset-7-binutils packages are included as a dependency.

10.5.2. Access

To pull the rhscl/devtoolset-8-perftools-rhel7 image, run the following command as root:

# docker pull registry.access.redhat.com/rhscl/devtoolset-8-perftools-rhel7

To pull the rhscl/devtoolset-7-perftools-rhel7 image, run the following command as root:

# docker pull registry.access.redhat.com/rhscl/devtoolset-7-perftools-rhel7

10.5.3. Usage

Using the SystemTap Tool from Container Images

When using the SystemTap tool from a container image, additional configuration is required, and the container needs to be run with special command-line options.

The following three conditions need to be met:

  1. The image needs to be run with super-user privileges. To do this, run the image using the following command:

    ~]$ docker run --ti --privileged --ipc=host --net=host --pid=host devtoolset-7-my-perftools /bin/bash -l

    To use the pre-built perftools image, substitute the image name for devtoolset-7-perftools-rhel7 in the above command.

  2. The following kernel packages need to be installed in the container:

    • kernel
    • kernel-devel
    • kernel-debuginfo

      The version and release numbers of the above packages must match the version and release numbers of the kernel running on the host system. Run the following command to determine the version and release numbers of the hosts system’s kernel:

      ~]$ uname -r
      3.10.0-514.10.2.el7.x86_64

      Note that the kernel-debuginfo package is only available from the Debug channel. Enable the rhel-7-server-debug-rpms repository as described in TODO WHERE. For more information on how to get access to debuginfo packages, see https://access.redhat.com/site/solutions/9907.

      To install the required packages with the correct version, use the yum package manager and the output of the uname command. For example, to install the correct version of the kernel package, run the following command as root:

      ~]# yum install -y kernel-$(uname -r)
  3. Save the container to a reusable image by executing the docker commit command. To save a custom-built SystemTap container:

    ~]$ docker commit devtoolset-7-systemtap-$(uname -r)

10.5.4. Known Issues

  • SystemTap in devtoolset-6-perftools can not be used

    The SystemTap tool requires the GCC compiler to be present as /usr/bin/gcc, and support retpolines. However, this is not the case in the devtoolset-6-perftools container. As a consequence, SystemTap in this container fails to run any script, and produces the following error message:

    *** CONFIG_RETPOLINE=y, but not supported by the compiler.

    As a result, SystemTap from devtoolset-6-perftools can not be used.

    To work around this issue, install GCC in the container before running SystemTap :

    # yum install gcc -y
    # stap ...

    (BZ#1614809)