[clang] [libclang][Cygwin] Use __declspec(dllexport) for libclang on Cygwin (PR #147122)

Tomohiro Kashiwada via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 5 17:19:27 PDT 2025


kikairoya wrote:

> > Before merge this, requires #147108
> 
> Can you elaborate on why this is needed - what happens without it - wouldn't that issue be happening already now in regular win32 builds so far?

The linker reports undefined reference to clang_install_aborting_llvm_fatal_error_handler, and cannot run testsuite.

```
FAILED: tools/clang/unittests/libclang/CrashTests/libclangCrashTests.exe
: && /usr/bin/g++.exe  -pipe -Wa,-mbig-obj -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -fno-common -Woverloaded-virtual -O2 -DNDEBUG -Wl,--enable-auto-import -Wl,--stack,16777216    -Wl,--gc-sections tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o -o tools/clang/unittests/libclang/CrashTests/libclangCrashTests.exe -Wl,--out-implib,tools/clang/unittests/libclang/CrashTests/liblibclangCrashTests.dll.a -Wl,--major-image-version,0,--minor-image-version,0  lib/libLLVMSupport.a  lib/libllvm_gtest_main.a  lib/libllvm_gtest.a  lib/libclang.dll.a  lib/libLLVMSupport.a  -lrt  -ldl  -lm  /usr/lib/libz.dll.a  /usr/lib/libzstd.dll.a  lib/libLLVMDemangle.a  -lpthread && :
/usr/lib/gcc/x86_64-pc-cygwin/15/../../../../x86_64-pc-cygwin/bin/ld: tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o:LibclangCrashTest.cpp:(.text+0x21d): undefined reference to `clang_install_aborting_llvm_fatal_error_handler'
/usr/lib/gcc/x86_64-pc-cygwin/15/../../../../x86_64-pc-cygwin/bin/ld: tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o:LibclangCrashTest.cpp:(.text+0x61f): undefined reference to `clang_install_aborting_llvm_fatal_error_handler'
/usr/lib/gcc/x86_64-pc-cygwin/15/../../../../x86_64-pc-cygwin/bin/ld: tools/clang/unittests/libclang/CrashTests/CMakeFiles/libclangCrashTests.dir/LibclangCrashTest.cpp.o:LibclangCrashTest.cpp:(.text+0x624): undefined reference to `clang_uninstall_llvm_fatal_error_handler'
collect2: エラー: ld はステータス 1 で終了しました
```

For regular Win32 targets, this unittest is disabled.

https://github.com/llvm/llvm-project/blob/4406a457b7cf3713dc9bea67bd7b68ecb61966bd/clang/unittests/CMakeLists.txt#L98-L102


https://github.com/llvm/llvm-project/pull/147122


More information about the cfe-commits mailing list