[libcxx] [testing] [benchmarks] How to build libcxx benchmark tests? (original) (raw)

November 5, 2024, 2:14pm 1

I am trying to build libcxx benchmark tests as I need to run some benchmarks. I have successfully built llvm and libcxx using the so-called bootstrapping build as documented in libcxx ducumentation:

cmake -S llvm -B build -G "Ninja" \
-DLLVM_ENABLE_PROJECTS="clang" \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DCMAKE_BUILD_TYPE=Release \
-DLIBCXX_INCLUDE_BENCHMARKS=ON \
-DLLVM_USE_LINKER=lld \
-DLLVM_OPTIMIZED_TABLEGEN=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache

Then I proceed the build as follows:

ninja -C build -j 8

It took about 2 hours to complete the above build.

I then proceed to build the benchmarks by following instructions in Testing libc++ — libc++ documentation :

ninja -C build cxx-benchmarks

Unfortunately, I always get the following error:

ninja: Entering directory `build'
ninja: error: unknown target 'cxx-benchmarks'

Could someone please help me resolve this issue? Thank you very much!

ldionne November 5, 2024, 7:33pm 2

I would recommend using the default build instead of a bootstrapping build. Your invocation would look like:

cmake -S runtimes -B build -G "Ninja" \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
-DCMAKE_BUILD_TYPE=Release \
-DLIBCXX_INCLUDE_BENCHMARKS=ON

And then you should have the cxx-benchmarks target.

This exactly solves my problem. Thank you so much.