Skip to content

Commit 1bfc71d

Browse files
committed
build: Set LLVM_BUILD_STATIC/CLANG_BUILD_STATIC when linking statically.
This is needed since LLVM 20, particularly for Windows.
1 parent 7733b5d commit 1bfc71d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,13 @@ add_library(zigcpp STATIC ${ZIG_CPP_SOURCES})
698698
target_compile_features(zigcpp PRIVATE cxx_std_17)
699699
set_target_properties(zigcpp PROPERTIES POSITION_INDEPENDENT_CODE ${ZIG_PIE})
700700

701+
if(LLVM_LINK_MODE STREQUAL "static")
702+
target_compile_definitions(zigcpp PRIVATE
703+
LLVM_BUILD_STATIC
704+
CLANG_BUILD_STATIC
705+
)
706+
endif()
707+
701708
if(NOT MSVC)
702709
if(MINGW)
703710
target_compile_options(zigcpp PRIVATE -Wno-format)

build.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,9 @@ const exe_cflags = [_][]const u8{
706706
"-Wno-type-limits",
707707
"-Wno-missing-braces",
708708
"-Wno-comment",
709+
// `exe_cflags` is only used for static linking.
710+
"-DLLVM_BUILD_STATIC",
711+
"-DCLANG_BUILD_STATIC",
709712
};
710713

711714
fn addCmakeCfgOptionsToExe(

0 commit comments

Comments
 (0)