Skip to content

Commit 6710943

Browse files
committed
Link MSVC runtime library statically
This change makes all CMake targets to use `-MT`/`-MTd` compilation flags for Windows MSVC builds. This way the MSVC runtime library is linked statically and the workaround for VS2019 added in duckdb/duckdb#17991 is no longer necessary. `extension-ci-tools` PR: duckdb/extension-ci-tools#276 Ref: duckdblabs/duckdb-internal#2036
1 parent 4c468b7 commit 6710943

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

.github/workflows/Java.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ jobs:
463463
shell: cmd
464464
run: |
465465
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
466+
dumpbin.exe /imports build\release\libduckdb_java.so_windows_amd64
466467
dumpbin.exe /exports build\release\libduckdb_java.so_windows_amd64
467468
468469
- name: Java Tests
@@ -544,15 +545,15 @@ jobs:
544545
shell: cmd
545546
run: |
546547
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsarm64.bat"
548+
dumpbin.exe /imports build\release\libduckdb_java.so_windows_arm64
547549
dumpbin.exe /exports build\release\libduckdb_java.so_windows_arm64
548550
549-
# Test runs are failing because windows_arm64 extensions are missing
550551
- name: Java Tests
551552
if: ${{ inputs.skip_tests != 'true' }}
552553
shell: bash
553554
run: |
554555
java -version
555-
make test || true
556+
make test
556557
557558
- name: Deploy
558559
shell: bash

CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ cmake_minimum_required(VERSION 3.5...3.29)
1111
set(CMAKE_CXX_STANDARD "11" CACHE STRING "C++ standard to enforce")
1212
set(CMAKE_VERBOSE_MAKEFILE OFF)
1313
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
14+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
1415

1516
if(NOT JNI_FOUND OR NOT Java_FOUND)
1617
message(FATAL_ERROR "No compatible Java/JNI found")
@@ -634,10 +635,7 @@ target_compile_definitions(duckdb_java PRIVATE
634635
-DDUCKDB_EXTENSION_AUTOLOAD_DEFAULT
635636
-DDUCKDB_EXTENSION_AUTOINSTALL_DEFAULT)
636637

637-
if(MSVC)
638-
target_compile_definitions(duckdb_java PRIVATE
639-
-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
640-
else()
638+
if(NOT MSVC)
641639
target_compile_definitions(duckdb_java PRIVATE
642640
-DDUCKDB_EXTENSION_JEMALLOC_LINKED)
643641
endif()

CMakeLists.txt.in

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ cmake_minimum_required(VERSION 3.5...3.29)
1111
set(CMAKE_CXX_STANDARD "11" CACHE STRING "C++ standard to enforce")
1212
set(CMAKE_VERBOSE_MAKEFILE OFF)
1313
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
14+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
1415

1516
if(NOT JNI_FOUND OR NOT Java_FOUND)
1617
message(FATAL_ERROR "No compatible Java/JNI found")
@@ -152,10 +153,7 @@ target_compile_definitions(duckdb_java PRIVATE
152153
-DDUCKDB_EXTENSION_AUTOLOAD_DEFAULT
153154
-DDUCKDB_EXTENSION_AUTOINSTALL_DEFAULT)
154155

155-
if(MSVC)
156-
target_compile_definitions(duckdb_java PRIVATE
157-
-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
158-
else()
156+
if(NOT MSVC)
159157
target_compile_definitions(duckdb_java PRIVATE
160158
-DDUCKDB_EXTENSION_JEMALLOC_LINKED)
161159
endif()

0 commit comments

Comments
 (0)