c++clangstdrhellibc++

can't find libc++ packages on el9


I have a c++ application that I automatically build and release for various platforms. I use docker images to build for Linux distros.

Recently I ran into a libstdc++ bug in std::regex (very old, confirmed, but not fixed, bug), so I decided to switch to clang and libc++. This worked fine for debian based distros and macos already used clang. But my enterprise Linux builds are another story.

I was using the redhat/ubi9 image, and I've tried CentOS stream 9 and Alma, but I can't find a repo that has libc++ and/or the corresponding devel packages, and libc++ doesn't seem to be bundled with the llvm-toolset package either.

I've included EPEL, enabled 'code ready builder' and every other extra repo I could find, but no libc++, and nothing found when I grep the entire filesystem after installing every clang and llvm package I could find.

Please help, and please don't suggest building libc++ from source. That would be a giant waste of CI build time.

EDIT: I've also tried various names like libcxx libcpp, and used dnf search, with no results.

Here's a minimal DockerFile that demonstrates the issue:

# syntax=docker/dockerfile:1.2

FROM almalinux:9 as builder

RUN dnf install -y 'dnf-command(config-manager)'
RUN dnf config-manager -y --set-enabled crb
RUN dnf update -y && \
    dnf install -y llvm-toolset && \
    dnf clean all
RUN /usr/bin/crb enable

RUN dnf install -y epel-release

# would install libc++, libc++-devel etc here, but packages are not available, even with different name variations like libcxx etc

# to demonstrate that libc++ was not bundled with the llvm-tooset, this fails:

RUN echo '#include <iostream> int main() { std::cout << "Hello, World!\\n"; return 0; }' > hello.cpp
RUN clang++ -stdlib=libc++ -o hello hello.cpp

It fails on the last line because libc++ isn't installed:

0.326 hello.cpp:1:10: fatal error: 'iostream' file not found
0.326     1 | #include <iostream> int main() { std::cout << "Hello, World!\\n"; return 0; }
0.326       |          ^~~~~~~~~~

Looks like others have run into the same issue Someone went to the effort to rebuild the RPMs from upstream: https://github.com/luscent/libcxx-el9/


Solution

  • Answering my own question: AFAIK there is no 'proper' EL9 repo hosting libc++ packages

    There is, however, a way to build the RPMs so they can be self hosted. I believe this [1] github repo has basically taken the RPM sources from upstream (Fedora) and made them available to build for EL9. There are also binary packages for x84_64 in the github release section, but it's probably not wise to trust those, and just build the RPMs yourself.

    I'd be happy to retract this answer if there was a 'proper' EL9 repo to avoid the self build and host option. I'd also be interested if anyone knows the reason for the fact there is no official EL9 libcxx package.

    [1] https://github.com/luscent/libcxx-el9/