Building libunwind - linux-on-ibm-z/docs GitHub Wiki

Building libunwind

Below versions of Libunwind are available in respective distributions at the time creation of these build instructions:

  • RHEL (9.0, 9.2, 9.3) have 1.6.2
  • SLES 15 SP5 has 1.5.0

The instructions provided below specify the steps to build libunwind v1.8.1 on Linux on IBM Z for following distributions:

  • RHEL (7.8, 7.9, 8.6, 8.8, 8.9, 9.0, 9.2, 9.3)
  • SLES (12 SP5, 15 SP5)
  • Ubuntu (20.04, 22.04, 23.10)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.
  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Step 1: Building and installing libunwind

1.1) Install dependencies

  • RHEL (7.8, 7.9)

    sudo yum install automake git make texinfo libtool bzip2
    
    • Build and Install GCC 9.2.0

          sudo yum install -y hostname tar zip gcc-c++ unzip python3 cmake curl wget gcc vim patch binutils-devel tcl gettext
          GCC_VERSION=9.2.0
          wget https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.gz
          tar -xf gcc-${GCC_VERSION}.tar.gz
          cd gcc-${GCC_VERSION}
          ./contrib/download_prerequisites
          mkdir objdir
          cd objdir
          ../configure --prefix=/opt/gcc --enable-languages=c,c++ --with-arch=zEC12 --with-long-double-128 \
               --build=s390x-linux-gnu --host=s390x-linux-gnu --target=s390x-linux-gnu                  \
               --enable-threads=posix --with-system-zlib --disable-multilib
          make -j $(nproc)
          sudo make install
          sudo ln -sf /opt/gcc/bin/gcc /usr/bin/gcc
          sudo ln -sf /opt/gcc/bin/g++ /usr/bin/g++
          sudo ln -sf /opt/gcc/bin/g++ /usr/bin/c++
          export PATH=/opt/gcc/bin:"$PATH"
          export LD_LIBRARY_PATH=/opt/gcc/lib64:"$LD_LIBRARY_PATH"
          export C_INCLUDE_PATH=/opt/gcc/lib/gcc/s390x-linux-gnu/${GCC_VERSION}/include
          export CPLUS_INCLUDE_PATH=/opt/gcc/lib/gcc/s390x-linux-gnu/${GCC_VERSION}/include
          sudo ln -sf /opt/gcc/lib64/libstdc++.so.6.0.24 /lib64/libstdc++.so.6
          sudo ln -sf /opt/gcc/lib64/libatomic.so.1 /lib64/libatomic.so.1
      
  • RHEL (8.6, 8.8, 8.9, 9.0, 9.2, 9.3)

sudo yum install automake gcc git make libtool gcc-c++
  • SLES 12 SP5
sudo zypper install -y automake gcc7 git make texinfo libtool pkg-config gcc7-c++
sudo rm -rf /usr/bin/gcc /usr/bin/g++ /usr/bin/cc
sudo ln -s /usr/bin/gcc-7 /usr/bin/gcc
sudo ln -s /usr/bin/g++-7 /usr/bin/g++
sudo ln -s /usr/bin/gcc /usr/bin/cc
  • SLES 15 SP5
sudo zypper install automake gcc git make texinfo libtool pkg-config gcc-c++
  • Ubuntu (20.04, 22.04, 23.10)
sudo apt-get update
sudo apt-get install automake gcc g++ git make texinfo libtool libltdl-dev pkg-config

1.2) Build and install Libunwind

cd $SOURCE_ROOT
git clone -b v1.8.1 https://github.com/libunwind/libunwind
cd libunwind
autoreconf -i
./configure
make
sudo make install

1.3) Run Unit and Performance Tests (Optional)

cd $SOURCE_ROOT/libunwind
make check
cd $SOURCE_ROOT/libunwind/tests
make perf

Note: Testcases such as Gtest-resume-sig-rt, Ltest-resume-sig-rt may fail on RHEL 7.x and Ubuntu 23.10 but will pass on rerun.

References