llvm / llvm/llvm-project

[libcxx][tests] Tests using llvm-libc++-shared.cfg.in fail on systems with GLIBC < 2.34

Open
#223,108 0 comments 0 reactions 0 assignees View on GitHub
libc++ test-suite
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

### Reproducer

```
ARG ver=26.04
FROM ubuntu:${ver}

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y \
build-essential \
clang \
git \
ninja-build \
python3 \
python3-pip \
&& python3 -m pip install cmake==3.31.6 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /work
```
Using the above `ubuntu.dockerfile` and an llvm-project checkout in the same directory, run the same libcxx test on AArch64 Ubuntu-20.04 and 22.04.

```
for VER in 20.04 22.04; do \
docker build --build-arg ver="$VER" -f ubuntu.dockerfile -t "libcxx-build:$VER" . ;\
docker run --rm -it \
-v "$PWD/llvm-project":/work/src:ro \
-v "$PWD/build-libcxx-$VER":/work/build \
libcxx-build:$VER \
bash -lc '
set -euxo pipefail

# Build bootstrap Clang using Ubuntu $VER GCC.
cmake --fresh \
-S /work/src/llvm \
-B /work/build/bootstrap \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_TARGETS_TO_BUILD=AArch64 \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_BENCHMARKS=OFF

cmake --build /work/build/bootstrap --target clang --parallel "$(nproc)"

/work/build/bootstrap/bin/clang++ --version

# Build libc++, libc++abi, and libunwind with bootstrap Clang.
cmake --fresh \
-S /work/src/runtimes \
-B /work/build/runtimes \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=/work/build/bootstrap/bin/clang \
-DCMAKE_CXX_COMPILER=/work/build/bootstrap/bin/clang++ \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
-DLIBCXXABI_ENABLE_STATIC_UNWINDER=ON

cmake --build /work/build/runtimes --target cxx-test-depends --parallel "$(nproc)"

/work/build/runtimes/bin/llvm-lit -sv /work/src/libcxx/test/std/utilities/utility/mem.res/mem.res/mem.res.public/dtor.pass.cpp
';\
done
```

### Result
The test passes on Ubuntu-22.04. On Ubuntu-20.04 it fails.
```
# .---command stderr------------
# | /usr/bin/ld: /work/build/runtimes/libcxx/test-suite-install/lib/libc++experimental.a(libunwind.cpp.o): undefined reference to symbol 'dladdr@@GLIBC_2.17'
# | /usr/bin/ld: /lib/aarch64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
# | clang++: error: linker command failed with exit code 1 (use -v to see invocation)
# `-----------------------------
# error: command failed with exit status: 1

--

********************
********************
Failed Tests (1):
llvm-libc++-shared.cfg.in :: std/utilities/utility/mem.res/mem.res/mem.res.public/dtor.pass.cpp
```

I believe this is because applications in old platforms such as RHEL-8, Ubuntu-22, where the GLIBC version is < 2.34, requires linking with `-ldl`, which the libcxx tests using the `llvm-libc++-shared.cfg.in` configuration does not do.
Recent platforms with GLIBC >= 2.34 do not need to link with `-ldl` anymore. https://lwn.net/Articles/864920/

Contributor guide

Open the contributing guide

Research direction

Start with the llvm-libc++-shared.cfg.in configuration and reproduce the failure using the provided Ubuntu 20.04 and 22.04 commands. Run llvm-lit on std/utilities/utility/mem.res/mem.res/mem.res.public/dtor.pass.cpp and compare the linker inputs. Done means the test passes on both systems without the DSO-missing-from-command-line error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, linux
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.