[build] msquic: fix static MinGW linking

This commit is contained in:
Geoffrey McRae
2026-09-30 16:36:21 +10:00
parent cd27ffb06e
commit c8196b9f99
3 changed files with 32 additions and 1 deletions

View File

@@ -82,6 +82,9 @@ function(lg_add_static_msquic)
find_program(LG_MSQUIC_WINDRES
NAMES "${MINGW64_TRIPLE}-windres" x86_64-w64-mingw32-windres
REQUIRED)
find_program(LG_MSQUIC_DLLTOOL
NAMES "${MINGW64_TRIPLE}-dlltool" x86_64-w64-mingw32-dlltool
REQUIRED)
# MsQuic's Windows sources use the CL command-line ABI and its monolithic
# archive rule uses lib.exe syntax. Compile those sources with clang-cl,
@@ -90,6 +93,29 @@ function(lg_add_static_msquic)
set(LG_MSQUIC_IMPORT_DIR "${LG_MSQUIC_BINARY_DIR}/mingw-imports")
file(MAKE_DIRECTORY "${LG_MSQUIC_IMPORT_DIR}")
set(LG_MSQUIC_SECUR32EX_DEF
"${LG_MSQUIC_IMPORT_DIR}/secur32ex.def")
set(LG_MSQUIC_SECUR32EX_LIBRARY
"${LG_MSQUIC_IMPORT_DIR}/secur32ex.lib")
file(WRITE "${LG_MSQUIC_SECUR32EX_DEF}"
"LIBRARY secur32.dll\n"
"EXPORTS\n"
" QueryContextAttributesExW\n")
execute_process(
COMMAND "${LG_MSQUIC_DLLTOOL}"
--input-def "${LG_MSQUIC_SECUR32EX_DEF}"
--output-lib "${LG_MSQUIC_SECUR32EX_LIBRARY}"
RESULT_VARIABLE LG_MSQUIC_DLLTOOL_RESULT
ERROR_VARIABLE LG_MSQUIC_DLLTOOL_ERROR)
if(NOT LG_MSQUIC_DLLTOOL_RESULT EQUAL 0)
message(FATAL_ERROR
"Unable to create the extended Secur32 import library: "
"${LG_MSQUIC_DLLTOOL_ERROR}")
endif()
list(APPEND LG_MSQUIC_SYSTEM_LIBRARIES
"${LG_MSQUIC_SECUR32EX_LIBRARY}")
foreach(LG_MSQUIC_SYSTEM_LIBRARY
onecore
secur32

View File

@@ -111,6 +111,7 @@ list(APPEND MSQUIC_CLANG_CL_OPTIONS
"/clang:-Wno-int-conversion"
"/clang:-Wno-unused-function"
"/clang:-Wno-incompatible-pointer-types"
"/clang:-Wno-duplicate-decl-specifier"
"/FI${MSQUIC_COMPAT_HEADER}")
list(JOIN MSQUIC_CLANG_CL_OPTIONS " " MSQUIC_CLANG_CL_FLAGS)

View File

@@ -22,7 +22,7 @@
#define _H_LG_MSQUIC_MINGW_COMPAT_
#ifndef FORCEINLINE
#define FORCEINLINE __inline__ __attribute__((__always_inline__))
#define FORCEINLINE __forceinline
#endif
#ifndef EXTERN_C_START
@@ -43,6 +43,10 @@
#include <string.h>
#ifndef __cplusplus
#define inline static __inline__
#endif
#undef UNREFERENCED_PARAMETER
#define UNREFERENCED_PARAMETER(parameter) ((void)(parameter))