-
Notifications
You must be signed in to change notification settings - Fork 56
Building libc6 compat
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 24.04 has
1.2.4
- Ubuntu 24.10 has
1.2.5
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 (8.8, 8.10, 9.2. 9.4, 9.5)
- SLES 15 SP6
- Ubuntu (20.04, 22.04, 24.04)
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 (8.8, 8.10, 9.2. 9.4, 9.5)
sudo yum install -y gcc gcc-c++ make wget tar
-
SLES 15 SP6
sudo zypper install -y gcc gcc-c++ make wget tar bzip2 zlib-devel gzip
-
Ubuntu (20.04, 22.04, 24.04)
sudo apt-get update sudo apt-get install -y gcc g++ tar wget make cmake bzip2 zlib1g-dev g++-multilib
-
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.
The information provided in this article is accurate at the time of writing, but on-going development in the open-source projects involved may make the information incorrect or obsolete. Please open issue or contact us on IBM Z Community if you have any questions or feedback.