From b6f0bf2df0f6baadc345a9d146599197a5b46e9f Mon Sep 17 00:00:00 2001 From: _ov4 Date: Fri, 16 Oct 2026 09:19:30 +0000 Subject: fix(build): statically link MinGW XML manifest dependencies Replace LLVMWindowsManifest's XML import library with static XML, iconv and zlib archives. Check the Windows compiler's PE imports before the restricted-PATH package smoke test. Co-Authored-By: Claude Fable 5.1 --- cmake/NativeCompiler.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cmake') diff --git a/cmake/NativeCompiler.cmake b/cmake/NativeCompiler.cmake index 35c7f41..bd536f4 100644 --- a/cmake/NativeCompiler.cmake +++ b/cmake/NativeCompiler.cmake @@ -74,6 +74,21 @@ target_sources(cpsc PRIVATE tools/driver/NativeCompiler.cc) target_include_directories(cpsc PRIVATE ${CLANG_INCLUDE_DIRS} ${LLD_INCLUDE_DIRS} "${CMAKE_BINARY_DIR}/native-runtime") target_link_libraries(cpsc PRIVATE clangDriver ${cpsc_linker_libraries}) +if(MINGW AND TARGET LibXml2::LibXml2) + # LLD's COFF manifest support reaches libxml2 through LLVMWindowsManifest. + # An explicit .dll.a in that interface bypasses the driver's -static flag. + cpsc_find_dependency(LIBRARY CPSC_STATIC_xml2 REQUIRED NAMES libxml2.a) + cpsc_find_dependency(LIBRARY CPSC_STATIC_iconv REQUIRED NAMES libiconv.a) + add_library(CPSCStaticXML2 INTERFACE) + # The prebuilt LLVM archive uses dllimport references. Load XML definitions + # before LLD resolves those references to local symbols. + target_link_libraries(CPSCStaticXML2 INTERFACE + -Wl,--whole-archive "${CPSC_STATIC_xml2}" -Wl,--no-whole-archive + "${CPSC_STATIC_iconv}" "${CPSC_STATIC_z}" bcrypt) + get_target_property(cpsc_manifest_libs LLVMWindowsManifest INTERFACE_LINK_LIBRARIES) + list(TRANSFORM cpsc_manifest_libs REPLACE "^LibXml2::LibXml2$" CPSCStaticXML2) + set_property(TARGET LLVMWindowsManifest PROPERTY INTERFACE_LINK_LIBRARIES "${cpsc_manifest_libs}") +endif() # Distribution Clang/LLD archives can still name the shared LLVM umbrella # library in their imported interfaces. Resolve those edges to static archives. add_library(CPSCStaticLLVM INTERFACE) -- cgit v1.3.1-4-g156e