Skip to content

Commit f24d2c0

Browse files
committed
On Windows with vcpkg, always use header-only mode.
1 parent 1948501 commit f24d2c0

2 files changed

Lines changed: 18 additions & 26 deletions

File tree

cpp/src/arrow/CMakeLists.txt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,15 @@ if(TARGET simdjson::simdjson)
747747
endif()
748748
endif()
749749
endif()
750+
751+
# Final fallback: On Windows with vcpkg, always use header-only mode.
752+
# vcpkg's simdjson package provides a stub library that doesn't contain
753+
# the actual implementation, so we must compile it ourselves.
754+
if(NOT ARROW_SIMDJSON_HEADER_ONLY AND WIN32 AND VCPKG_TARGET_TRIPLET)
755+
message(STATUS "simdjson: forcing header-only mode for Windows vcpkg build")
756+
set(ARROW_SIMDJSON_HEADER_ONLY TRUE)
757+
endif()
758+
750759
message(STATUS "simdjson: ARROW_SIMDJSON_HEADER_ONLY=${ARROW_SIMDJSON_HEADER_ONLY}")
751760
endif()
752761

@@ -1070,20 +1079,15 @@ else()
10701079
endif()
10711080

10721081
if(ARROW_JSON)
1073-
# simdjson_impl.cc provides the simdjson implementation when using header-only mode.
1074-
# The source file itself handles the necessary #defines (SIMDJSON_IMPLEMENTATION,
1075-
# SIMDJSON_BUILDING_WINDOWS_DYNAMIC_LIBRARY) based on compile-time conditions.
1076-
# We always include it when ARROW_JSON is built to ensure simdjson symbols are available.
1077-
# When simdjson is used as a proper library (non-header-only), the guards in the source
1078-
# file prevent duplicate symbol definitions.
1082+
# In header-only mode, we need to compile the simdjson implementation ourselves.
1083+
# Detection of header-only mode was done earlier and stored in ARROW_SIMDJSON_HEADER_ONLY.
10791084
set(ARROW_SIMDJSON_IMPL_SRC "")
1080-
if(TARGET simdjson::simdjson)
1081-
# Always compile simdjson_impl.cc to provide implementation symbols
1085+
if(TARGET simdjson::simdjson AND ARROW_SIMDJSON_HEADER_ONLY)
10821086
set(ARROW_SIMDJSON_IMPL_SRC json/simdjson_impl.cc)
10831087
# Skip unity build for this file to avoid issues with simdjson's implementation macros
10841088
set_source_files_properties(json/simdjson_impl.cc
10851089
PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
1086-
message(STATUS "simdjson: including simdjson_impl.cc (header-only=${ARROW_SIMDJSON_HEADER_ONLY})")
1090+
message(STATUS "simdjson: including simdjson_impl.cc for header-only mode")
10871091
endif()
10881092
arrow_add_object_library(ARROW_JSON
10891093
extension/fixed_shape_tensor.cc

cpp/src/arrow/json/simdjson_impl.cc

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,19 @@
1616
// under the License.
1717

1818
// This file provides simdjson's implementation when the library is header-only.
19+
// CMake only includes this file in the build when header-only mode is detected.
20+
//
1921
// SIMDJSON_IMPLEMENTATION must be defined before including simdjson.h to
2022
// instantiate the implementation. On Windows DLL builds, we also need
2123
// SIMDJSON_BUILDING_WINDOWS_DYNAMIC_LIBRARY to export global data symbols.
22-
//
23-
// SIMDJSON_HEADER_ONLY is set by CMake (via target_compile_definitions or
24-
// simdjson's INTERFACE_COMPILE_DEFINITIONS) when simdjson is used in header-only mode.
25-
26-
// Only compile the implementation in header-only mode
27-
#if defined(SIMDJSON_HEADER_ONLY)
2824

29-
// Enable the implementation
30-
#ifndef SIMDJSON_IMPLEMENTATION
25+
// Enable the implementation - this file is only compiled in header-only mode
3126
#define SIMDJSON_IMPLEMENTATION 1
32-
#endif
3327

34-
// On Windows, when building a DLL, we need to export simdjson's global symbols
28+
// On Windows, when building a DLL, we need to export simdjson's global symbols.
29+
// ARROW_EXPORTING is defined by CMake for shared library builds.
3530
#if defined(_WIN32) && defined(ARROW_EXPORTING)
36-
#ifndef SIMDJSON_BUILDING_WINDOWS_DYNAMIC_LIBRARY
3731
#define SIMDJSON_BUILDING_WINDOWS_DYNAMIC_LIBRARY 1
3832
#endif
39-
#endif
4033

4134
#include <simdjson.h>
42-
43-
#else
44-
// Not in header-only mode - simdjson library provides the implementation
45-
// This file is still compiled but produces no code
46-
#endif // SIMDJSON_HEADER_ONLY

0 commit comments

Comments
 (0)