Skip to content

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

Open
Reranko05 wants to merge 4 commits into
apache:mainfrom
Reranko05:R-simdjson-bundle
Open

GH-50581: [C++][R] Use bundled simdjson for C++ wrapper builds#50587
Reranko05 wants to merge 4 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

Copy link
Copy Markdown

Revision: 9864597

Submitted crossbow builds: ursacomputing/crossbow @ actions-357652d8fe

Task Status
r-binary-packages GitHub Actions
r-recheck-most GitHub Actions
test-r-alpine-linux-cran GitHub Actions
test-r-arrow-backwards-compatibility GitHub Actions
test-r-depsource-system GitHub Actions
test-r-dev-duckdb GitHub Actions
test-r-devdocs GitHub Actions
test-r-extra-packages GitHub Actions
test-r-fedora-clang GitHub Actions
test-r-gcc-11 GitHub Actions
test-r-gcc-12 GitHub Actions
test-r-install-local GitHub Actions
test-r-install-local-minsizerel GitHub Actions
test-r-linux-as-cran GitHub Actions
test-r-linux-rchk GitHub Actions
test-r-linux-sanitizers GitHub Actions
test-r-linux-valgrind GitHub Actions
test-r-m1-san GitHub Actions
test-r-macos-as-cran GitHub Actions
test-r-offline-maximal GitHub Actions
test-r-ubuntu-22.04 GitHub Actions
test-r-versions GitHub Actions
test-r-wasm GitHub Actions

@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

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.

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.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

-Dre2_SOURCE=${re2_SOURCE:-BUNDLED} \
-Dabsl_SOURCE=${absl_SOURCE:-BUNDLED} \
-Dre2_SOURCE=${re2_SOURCE:-BUNDLED} \
-Dsimdjson_SOURCE=${simdjson_SOURCE:-} \

@rok rok Jul 23, 2026

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.

@kou should we accept this and remove the change in r/tootls/nixlibs.R?

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.

Good point! Let's try it!

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 try this?

@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.

This looks good!
As this touches the all the cpp wrappers we should also adjust issue and PR title/text.

-Dre2_SOURCE=${re2_SOURCE:-BUNDLED} \
-Dabsl_SOURCE=${absl_SOURCE:-BUNDLED} \
-Dre2_SOURCE=${re2_SOURCE:-BUNDLED} \
-Dsimdjson_SOURCE=${simdjson_SOURCE:-} \

@rok rok Jul 23, 2026

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.

@kou should we accept this and remove the change in r/tootls/nixlibs.R?

@github-actions github-actions Bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels Jul 23, 2026
@Reranko05 Reranko05 changed the title GH-50581: [R] Use bundled simdjson by default GH-50581: [R] Use bundled simdjson for C++ wrapper builds Jul 23, 2026
@Reranko05

Copy link
Copy Markdown
Contributor Author

@rok Updated PR title and description.

@rok rok changed the title GH-50581: [R] Use bundled simdjson for C++ wrapper builds GH-50581: [C++][R] Use bundled simdjson for C++ wrapper builds Jul 23, 2026
@kou

kou commented Jul 23, 2026

Copy link
Copy Markdown
Member

@github-actions crossbow submit -g r

@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting merge Awaiting merge labels Jul 23, 2026
@github-actions

Copy link
Copy Markdown

Revision: b265939

Submitted crossbow builds: ursacomputing/crossbow @ actions-aa46ed246c

Task Status
r-binary-packages GitHub Actions
r-recheck-most GitHub Actions
test-r-alpine-linux-cran GitHub Actions
test-r-arrow-backwards-compatibility GitHub Actions
test-r-depsource-system GitHub Actions
test-r-dev-duckdb GitHub Actions
test-r-devdocs GitHub Actions
test-r-extra-packages GitHub Actions
test-r-fedora-clang GitHub Actions
test-r-gcc-11 GitHub Actions
test-r-gcc-12 GitHub Actions
test-r-install-local GitHub Actions
test-r-install-local-minsizerel GitHub Actions
test-r-linux-as-cran GitHub Actions
test-r-linux-rchk GitHub Actions
test-r-linux-sanitizers GitHub Actions
test-r-linux-valgrind GitHub Actions
test-r-m1-san GitHub Actions
test-r-macos-as-cran GitHub Actions
test-r-offline-maximal GitHub Actions
test-r-ubuntu-22.04 GitHub Actions
test-r-versions GitHub Actions
test-r-wasm GitHub Actions

@kou

kou commented Jul 24, 2026

Copy link
Copy Markdown
Member

Can we disable ARROW_JSON and ARROW_WITH_SIMDJSON forcibly with AppleClang 21 or older?

Copilot AI review requested due to automatic review settings July 24, 2026 03:53

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

Copy link
Copy Markdown
Contributor Author

@kou I tried implementing the workaround by forcibly disabling ARROW_JSON for AppleClang < 22 in ThirdpartyToolchain.cmake. Since ARROW_WITH_SIMDJSON is only enabled when ARROW_JSON is enabled, this also keeps ARROW_WITH_SIMDJSON disabled.

I used AppleClang < 22 instead of <= 21 because the compiler version reported by the failing job is 21.0.0.21000101, and VERSION_LESS "22" naturally covers all 21.x releases.

Does this look like the right approach, or did you have something else in mind?

Copilot AI review requested due to automatic review settings July 24, 2026 03:59
@Reranko05
Reranko05 force-pushed the R-simdjson-bundle branch from 5841739 to 06732bd Compare July 24, 2026 03:59

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

@kou can you run this again?

@github-actions github-actions Bot added awaiting changes Awaiting changes and removed awaiting change review Awaiting change review labels Jul 24, 2026
set(ARROW_WITH_AZURE_SDK ON)
endif()

if(APPLE

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.

APPLE is redundant. AppleClang is available only on Apple.

Comment on lines +413 to +415
if(APPLE
AND CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "22")

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.

Could you check this only when ARROW_JSON=ON?

Suggested change
if(APPLE
AND CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "22")
if(ARROW_JSON
AND CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "22")

Comment on lines +417 to +419
set(ARROW_JSON
OFF
CACHE BOOL "" FORCE)

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.

We can treat ARROW_JSON as a normal variable.

Suggested change
set(ARROW_JSON
OFF
CACHE BOOL "" FORCE)
set(ARROW_JSON OFF)

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.

4 participants