Skip to content

Running the libc++ Benchmarks on Windows with MinGW #162879

@c8ef

Description

@c8ef

I'm attempting to run a libc++ benchmark on Windows MinGW using the latest mstorsjo/llvm-mingw toolchain.

Initially, executing ./bin/llvm-lit.py a.bench resulted in an ld.lld error:

ld.lld: error: undefined symbol: __declspec(dllimport) benchmark::internal::InitializeStreams()
>>> referenced by C:/Users/xxx/AppData/Local/Temp/sort_heap-a87419.o:(__cxx_global_var_init)
NOTE: a relevant symbol '_ZN9benchmark8internal17InitializeStreamsEv' is available in C:/Users/xxx/Desktop/llvm-project/build/libcxx/test/benchmarks/google-benchmark/lib/libbenchmark.a but cannot be used because it is not an import library.

After some searching, I added the -DBENCHMARK_STATIC_DEFINE flag. However, a new error occurred:

ld.lld: error: undefined symbol: __declspec(dllimport) SHGetValueA
>>> referenced by libbenchmark.a(sysinfo.cc.obj):(benchmark::CPUInfo::CPUInfo())
clang-21: error: linker command failed with exit code 1 (use -v to see invocation)

Adding -lShlwapi finally resolved the issue.

Since I'm not a Windows/MinGW expert, I was wondering if there's a way to make running the benchmark work out of the box.

ref:

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.platform:windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions