build: Set LLVM_BUILD_STATIC/CLANG_BUILD_STATIC when linking statically.

This is needed since LLVM 20, particularly for Windows.
This commit is contained in:
Alex Rønne Petersen 2025-04-08 23:11:32 +02:00
parent 7733b5dbe6
commit 1bfc71d4da
2 changed files with 10 additions and 0 deletions

View file

@ -698,6 +698,13 @@ add_library(zigcpp STATIC ${ZIG_CPP_SOURCES})
target_compile_features(zigcpp PRIVATE cxx_std_17)
set_target_properties(zigcpp PROPERTIES POSITION_INDEPENDENT_CODE ${ZIG_PIE})
if(LLVM_LINK_MODE STREQUAL "static")
target_compile_definitions(zigcpp PRIVATE
LLVM_BUILD_STATIC
CLANG_BUILD_STATIC
)
endif()
if(NOT MSVC)
if(MINGW)
target_compile_options(zigcpp PRIVATE -Wno-format)

View file

@ -706,6 +706,9 @@ const exe_cflags = [_][]const u8{
"-Wno-type-limits",
"-Wno-missing-braces",
"-Wno-comment",
// `exe_cflags` is only used for static linking.
"-DLLVM_BUILD_STATIC",
"-DCLANG_BUILD_STATIC",
};
fn addCmakeCfgOptionsToExe(