Skip to content

GH-50581: [C++][R] Use bundled simdjson for C++ wrapper builds#50587

Merged
rok merged 11 commits into
apache:mainfrom
Reranko05:R-simdjson-bundle
Jul 24, 2026
Merged

GH-50581: [C++][R] Use bundled simdjson for C++ wrapper builds#50587
rok merged 11 commits into
apache:mainfrom
Reranko05:R-simdjson-bundle

Conversation

@Reranko05

@Reranko05 Reranko05 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Rationale

The R build may pick up a system-installed simdjson when simdjson_SOURCE is not explicitly set. This causes build failures in environments where the system version is incompatible or unsuitable for the build.

What changes are included?

This change defaults simdjson_SOURCE to BUNDLED when it is not already set, ensuring C++ wrapper builds invoked through build_arrow_static.sh use the bundled simdjson by default, while still allowing users to override it explicitly.

This addresses the macOS CRAN release and ubuntu-r-only-r (AUTO deps) failures reported in GH-50581.

Related: #50581

@Reranko05
Reranko05 requested a review from assignUser as a code owner July 22, 2026 01:26
Copilot AI review requested due to automatic review settings July 22, 2026 01:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #50581 has been automatically assigned in GitHub to PR creator.

@kou kou added the CI: Extra: R Run extra R CI label Jul 22, 2026
@kou

kou commented Jul 22, 2026

Copy link
Copy Markdown
Member

@github-actions crossbow submit -g r

@github-actions

This comment was marked as outdated.

@Reranko05

Copy link
Copy Markdown
Contributor Author

@kou It looks like the remaining failures are related to the ongoing simdjson version discussion. If we go with requiring simdjson 4.0+ and falling back to the bundled version when the system package is too old, I think that should address this issue.

@rok

rok commented Jul 22, 2026

Copy link
Copy Markdown
Member

I don't think this is isolated to R, e.g. see windows python nightly failure and you can check other nightlies.
I think the approach is correct though and don't worry too much about this, we have until the next release to fix it :D

@kou

kou commented Jul 23, 2026

Copy link
Copy Markdown
Member

Could you try this?

diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 1677b188b9..dc8629669f 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -2828,7 +2828,7 @@ function(build_simdjson)
       TRUE
       PARENT_SCOPE)
 
-  list(APPEND ARROW_BUNDLED_STATIC_LIBS simdjson::simdjson)
+  list(APPEND ARROW_BUNDLED_STATIC_LIBS simdjson)
   set(ARROW_BUNDLED_STATIC_LIBS
       "${ARROW_BUNDLED_STATIC_LIBS}"
       PARENT_SCOPE)
@@ -2845,6 +2845,11 @@ if(ARROW_WITH_SIMDJSON)
                      ${ARROW_SIMDJSON_REQUIRED_VERSION}
                      IS_RUNTIME_DEPENDENCY
                      FALSE)
+  if(SIMDJSON_VENDORED)
+    add_library(arrow::simdjson ALIAS simdjson)
+  else()
+    add_library(arrow::simdjson ALIAS simdjson::simdjson)
+  endif()
 endif()
 
 function(build_rapidjson)
diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt
index e792574a18..0b21fec605 100644
--- a/cpp/src/arrow/CMakeLists.txt
+++ b/cpp/src/arrow/CMakeLists.txt
@@ -1044,7 +1044,7 @@ if(ARROW_JSON)
                            json/parser.cc
                            json/reader.cc)
   foreach(ARROW_JSON_TARGET ${ARROW_JSON_TARGETS})
-    target_link_libraries(${ARROW_JSON_TARGET} PRIVATE RapidJSON simdjson::simdjson)
+    target_link_libraries(${ARROW_JSON_TARGET} PRIVATE RapidJSON arrow::simdjson)
   endforeach()
 else()
   set(ARROW_JSON_TARGET_SHARED)

This will fix the following case:

https://github.com/ursacomputing/crossbow/actions/runs/29887151358/job/88819918379#step:6:8835

/usr/bin/ar: /usr/lib/x86_64-linux-gnu/libsimdjson.so.9.0.0: file format not recognized

Copilot AI review requested due to automatic review settings July 23, 2026 03:06
@Reranko05
Reranko05 requested a review from pitrou as a code owner July 23, 2026 03:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Reranko05

Copy link
Copy Markdown
Contributor Author

@github-actions crossbow submit -g r

@github-actions

Copy link
Copy Markdown
Only contributors can submit requests to this bot. Please ask someone from the community for help with getting the first commit in.
The Archery job run can be found at: https://github.com/apache/arrow/actions/runs/29979508366

@kou

kou commented Jul 23, 2026

Copy link
Copy Markdown
Member

@github-actions crossbow submit -g r

@github-actions

This comment was marked as outdated.

@Reranko05

Copy link
Copy Markdown
Contributor Author

@kou I suspect the remaining Crossbow failures may be related to changes in the JsonWriter PR that haven't been merged yet (for example, it adds simdjson_SOURCE=BUNDLED to the R Docker test configuration, which seems relevant to the Ubuntu failure).

@kou

kou commented Jul 23, 2026

Copy link
Copy Markdown
Member

test-r-macos-as-cran:

https://github.com/ursacomputing/crossbow/actions/runs/29981142927/job/89122965972#step:9:1373

In file included from /Users/runner/work/crossbow/crossbow/arrow/cpp/src/arrow/json/object_parser.cc:20:
/opt/homebrew/include/simdjson.h:3106:10: error: expected concept name with optional arguments
 3106 |     } -> std::convertible_to<typename std::remove_cvref_t<T>::value_type>;
      |          ^
/opt/homebrew/include/simdjson.h:3127:8: error: no member named 'ranges' in namespace 'std'
 3127 |   std::ranges::input_range<T> && !string_like<T> && !concepts::string_view_keyed_map<T>;
      |   ~~~~~^
/opt/homebrew/include/simdjson.h:3127:28: error: 'T' does not refer to a value
 3127 |   std::ranges::input_range<T> && !string_like<T> && !concepts::string_view_keyed_map<T>;
      |                            ^
/opt/homebrew/include/simdjson.h:3125:20: note: declared here
 3125 | template <typename T>
      |                    ^
/opt/homebrew/include/simdjson.h:3127:34: error: expected identifier
 3127 |   std::ranges::input_range<T> && !string_like<T> && !concepts::string_view_keyed_map<T>;
      |                                  ^
/opt/homebrew/include/simdjson.h:3140:17: error: expected concept name with optional arguments
 3140 |     { c[i] } -> std::convertible_to<typename Container::value_type>;
      |                 ^
In file included from /var/folders/8j/sfr9qqcj73j4p6nhwcfpr0th0000gn/T/RtmpjwvCVB/file223d386e52a2/_deps/azure_sdk-src/sdk/core/azure-core/src/http/request_activity_policy.cpp:4:
/var/folders/8j/sfr9qqcj73j4p6nhwcfpr0th0000gn/T/RtmpjwvCVB/file223d386e52a2/_deps/azure_sdk-src/sdk/core/azure-core/inc/azure/core/http/policies/policy.hpp:429:20: warning: virtual method 'ShouldRetryOnTransportFailure' is inside a 'final' class and can never be overridden [-Wunnecessary-virtual-specifier]
  429 |       virtual bool ShouldRetryOnTransportFailure(
      |                    ^
/var/folders/8j/sfr9qqcj73j4p6nhwcfpr0th0000gn/T/RtmpjwvCVB/file223d386e52a2/_deps/azure_sdk-src/sdk/core/azure-core/inc/azure/core/http/policies/policy.hpp:435:20: warning: virtual method 'ShouldRetryOnResponse' is inside a 'final' class and can never be overridden [-Wunnecessary-virtual-specifier]
  435 |       virtual bool ShouldRetryOnResponse(
      |                    ^
/opt/homebrew/include/simdjson.h:63624:19: error: no member named 'invocable' in namespace 'std'
 63624 |     requires std::invocable<Func, value>
       |                   ^~~~~~~~~
/opt/homebrew/include/simdjson.h:63823:19: error: no member named 'invocable' in namespace 'std'
 63823 |     requires std::invocable<Func, arm64::ondemand::value>
       |                   ^~~~~~~~~
/opt/homebrew/include/simdjson.h:65348:19: error: no member named 'invocable' in namespace 'std'
 65348 |     requires std::invocable<Func, value>
       |                   ^~~~~~~~~
/opt/homebrew/include/simdjson.h:65478:19: error: no member named 'invocable' in namespace 'std'
 65478 |     requires std::invocable<Func, arm64::ondemand::value>
       |                   ^~~~~~~~~
/opt/homebrew/include/simdjson.h:66395:19: error: no member named 'invocable' in namespace 'std'
 66395 |     requires std::invocable<Func, value>
       |                   ^~~~~~~~~
/opt/homebrew/include/simdjson.h:66622:19: error: no member named 'invocable' in namespace 'std'
 66622 |     requires std::invocable<Func, value>
       |                   ^~~~~~~~~
/opt/homebrew/include/simdjson.h:66714:19: error: no member named 'invocable' in namespace 'std'
 66714 |     requires std::invocable<Func, arm64::ondemand::value>
       |                   ^~~~~~~~~
/opt/homebrew/include/simdjson.h:66805:19: error: no member named 'invocable' in namespace 'std'
 66805 |     requires std::invocable<Func, arm64::ondemand::value>
       |                   ^~~~~~~~~
/opt/homebrew/include/simdjson.h:67472:19: error: no member named 'invocable' in namespace 'std'
 67472 |     requires std::invocable<Func, value>
       |                   ^~~~~~~~~
/opt/homebrew/include/simdjson.h:67628:19: error: no member named 'invocable' in namespace 'std'
 67628 |     requires std::invocable<Func, arm64::ondemand::value>
       |                   ^~~~~~~~~
/opt/homebrew/include/simdjson.h:67910:16: error: no type named 'unsigned_integral' in namespace 'std'
 67910 | template <std::unsigned_integral T>
       |           ~~~~~^
/opt/homebrew/include/simdjson.h:67911:51: error: unknown type name 'T'
 67911 | error_code tag_invoke(deserialize_tag, auto &val, T &out) noexcept {
       |                                                   ^
/opt/homebrew/include/simdjson.h:67912:38: error: template argument for template type parameter must be a type
 67912 |   using limits = std::numeric_limits<T>;
       |                                      ^
/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/limits:442:17: note: template parameter is declared here
  442 | template <class _Tp>
      |                 ^
In file included from /Users/runner/work/crossbow/crossbow/arrow/cpp/src/arrow/json/object_parser.cc:20:
/opt/homebrew/include/simdjson.h:67916:12: error: use of undeclared identifier 'limits'
 67916 |   if (x > (limits::max)()) {
       |            ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

It seems that we can't build simdjson with AppleClang 21:

https://github.com/ursacomputing/crossbow/actions/runs/29981142927/job/89122965972#step:9:56

-- The C compiler identification is AppleClang 21.0.0.21000101
-- The CXX compiler identification is AppleClang 21.0.0.21000101

@kou

kou commented Jul 23, 2026

Copy link
Copy Markdown
Member

test-r-depsource-system:

https://github.com/ursacomputing/crossbow/actions/runs/29981142748/job/89122965384#step:6:3165

simdjson_SOURCE=BUNDLED

https://github.com/ursacomputing/crossbow/actions/runs/29981142748/job/89122965384#step:7:361

CMake Error at cmake_modules/ThirdpartyToolchain.cmake:316 (message):
  Couldn't find simdjson >= 3.0.0

It seems that simdjson_SOURCE=BUNDLED environment variable isn't used.

Could you try this?

diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh
index e7f453bb64..8c8d9d6b95 100755
--- a/r/inst/build_arrow_static.sh
+++ b/r/inst/build_arrow_static.sh
@@ -107,8 +107,9 @@ ${CMAKE_WRAPPER} ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \
     -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON \
     -DCMAKE_UNITY_BUILD=${CMAKE_UNITY_BUILD:-OFF} \
     -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR} \
-    -Dre2_SOURCE=${re2_SOURCE:-BUNDLED} \
     -Dabsl_SOURCE=${absl_SOURCE:-BUNDLED} \
+    -Dre2_SOURCE=${re2_SOURCE:-BUNDLED} \
+    -Dsimdjson_SOURCE=${simdjson_SOURCE:-} \
     -Dxsimd_SOURCE=${xsimd_SOURCE:-} \
     -Dzstd_SOURCE=${zstd_SOURCE:-} \
     ${EXTRA_CMAKE_FLAGS} \

@kou

kou commented Jul 23, 2026

Copy link
Copy Markdown
Member

It seems that r-recheck-most failures are unrelated.
I've re-run it.

Copilot AI review requested due to automatic review settings July 23, 2026 10:18
@raulcd

raulcd commented Jul 24, 2026

Copy link
Copy Markdown
Member

Thanks @Reranko05 @rok I think that if we update the image revision for the Windows wheels, using -Dsimdjson_SOURCE=BUNDLED is unnecessary.

@Reranko05

Copy link
Copy Markdown
Contributor Author

Thanks @raulcd, I will revert the workaround and update the image revision instead.

Copilot AI review requested due to automatic review settings July 24, 2026 11:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Reranko05

Copy link
Copy Markdown
Contributor Author

@raulcd I have reverted the previous workaround and bumped the Windows wheel image revision. Could you please re-run the Crossbow jobs.

@raulcd

raulcd commented Jul 24, 2026

Copy link
Copy Markdown
Member

@github-actions crossbow submit wheel-windows-cp314-cp314t-*

@github-actions

Copy link
Copy Markdown

Revision: e470cf0

Submitted crossbow builds: ursacomputing/crossbow @ actions-ebacba2792

Task Status
wheel-windows-cp314-cp314t-amd64 GitHub Actions

@rok

rok commented Jul 24, 2026

Copy link
Copy Markdown
Member

@github-actions crossbow submit wheel-windows-cp314-cp314-amd64

@github-actions

Copy link
Copy Markdown

Revision: e470cf0

Submitted crossbow builds: ursacomputing/crossbow @ actions-03d0412c61

Task Status
wheel-windows-cp314-cp314-amd64 GitHub Actions

@rok rok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI and windows wheel jobs pass. If there's no objections I'll merge this.

@Reranko05

Copy link
Copy Markdown
Contributor Author

@rok Thanks for the review and for rerunning the Crossbow jobs :)

Comment thread cpp/cmake_modules/ThirdpartyToolchain.cmake
@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting merge Awaiting merge labels Jul 24, 2026
Copilot AI review requested due to automatic review settings July 24, 2026 16:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Jul 24, 2026
@Reranko05
Reranko05 requested a review from rok July 24, 2026 16:32

@rok rok left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick effort @Reranko05 !

@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Jul 24, 2026
@rok
rok merged commit 62d2dd8 into apache:main Jul 24, 2026
66 of 67 checks passed
@rok rok removed the awaiting merge Awaiting merge label Jul 24, 2026
Comment on lines +413 to +420
# The macOS 11.3 SDK has incomplete C++20 concepts support, which prevents
# simdjson headers from compiling. Disable simdjson concepts for this SDK.
if(ARROW_JSON
AND CMAKE_OSX_SYSROOT
AND CMAKE_OSX_SYSROOT MATCHES "MacOSX11\\.3\\.sdk$")
message(STATUS "Disabling simdjson concepts for macOS SDK 11.3")
add_compile_definitions(SIMDJSON_CONCEPT_DISABLED=1)
endif()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Reranko05 Could you move this to build_simdjson() and use target_compile_options() instead of add_compile_definitions() as a follow-up task?

Could you report this to upstream? Upstream also checks clang version but we need to SDK version not clang version.
https://github.com/simdjson/simdjson/blob/8e6bac94877f2d3d026000d36ce81e0aaf38d26f/include/simdjson/compiler_check.h#L83-L87

@github-actions github-actions Bot added the awaiting changes Awaiting changes label Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants