Building libc6 compat - linux-on-ibm-z/docs GitHub Wiki
Below version of libc6-compat (musl-libc) is available in respective distributions at the time of creation of these build instructions:
- Ubuntu 20.04 has
1.1.24
- Ubuntu 22.04 has
1.2.2
- Ubuntu 23.10 has
1.2.3
The instructions provided below specify the steps to build libc6-compat version 1.2.5 on Linux on IBM Z for the 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
If you want to build libc6-compat using manual steps, go to Step 2.
Use the following commands to build libc6-compat using the build script. Please make sure you have wget installed.
wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/libc6-compat/1.2.5/build_libc6compat.sh
# Build libc6-compat
bash build_libc6compat.sh
If the build completes successfully, go to STEP 4. In case of error, check logs
for more details or go to STEP 2 to follow manual build steps.
-
RHEL (7.8, 7.9, 8.6, 8.8, 8.9, 9.0, 9.2. 9.3)
sudo yum install -y gcc gcc-c++ make wget tar
-
SLES (12 SP5, 15 SP5)
sudo zypper install -y gcc gcc-c++ make wget tar bzip2 zlib-devel gzip
-
Ubuntu (20.04, 22.04)
sudo apt-get update sudo apt-get install -y gcc g++ tar wget make cmake bzip2 zlib1g-dev g++-multilib
-
Ubuntu 23.10
sudo apt-get update sudo apt-get install -y gcc-10 g++-10 tar wget make cmake bzip2 zlib1g-dev g++-10-multilib sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-10 40 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 40 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 40 sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-10 40
-
Download source code
export SOURCE_ROOT=/<source_root> cd $SOURCE_ROOT wget http://git.musl-libc.org/cgit/musl/snapshot/musl-1.2.5.tar.gz tar -xzf musl-1.2.5.tar.gz
-
Build and Install libc6-compat
cd $SOURCE_ROOT/musl-1.2.5 ./configure make sudo make install
Note: By default, configure installs to a prefix of "/usr/local/musl". This differs from the behavior of most configure scripts, and is chosen specifically to avoid clashing with libraries already present on the system. DO NOT set the prefix to "/usr", "/usr/local", or "/" unless you're upgrading libc on an existing musl-based system. Doing so will break your existing system when you run "make install" and it may be difficult to recover.
- After installing, you should be able to use musl via the musl-gcc wrapper. For example:
cat > hello.c <<EOF
#include <stdio.h>
int main()
{
printf("hello, world!\n");
return 0;
}
EOF
/usr/local/musl/bin/musl-gcc hello.c
./a.out
Note: The above program should compile and execute successfully printing the string hello, world
.
Notes:
- To configure autoconf-based program to compile and link against musl, set the CC variable to musl-gcc when running configure, as in:
CC=musl-gcc ./configure ...
- You will probably also want to use --prefix when building libraries to ensure that they are installed under the musl prefix and not in the main host system library directories.