raulcd commented on code in PR #45618:
URL: https://github.com/apache/arrow/pull/45618#discussion_r2053612804
##########
cpp/src/arrow/compute/CMakeLists.txt:
##########
@@ -81,11 +86,36 @@ function(ADD_ARROW_COMPUTE_TEST REL_TEST_NAME)
set(LABELS ${ARROW_COMPUTE_TEST_LABELS})
endif()
+ if(WIN32)
+ if(MSVC)
+ set(EXTRA_LINK_LIBS arrow_compute_shared)
+ set(EXTRA_LINK_OPTIONS "/WHOLEARCHIVE:arrow_compute_shared")
+ else()
+ set(EXTRA_LINK_LIBS "-Wl,--whole-archive" arrow_compute_shared
+ "-Wl,--allow-multiple-definition"
"-Wl,--no-whole-archive")
+ endif()
+ elseif(APPLE)
+ set(EXTRA_LINK_LIBS "-Wl,-force_load" arrow_compute_shared)
+ else()
+ set(EXTRA_LINK_LIBS "-Wl,--push-state,--no-as-needed" arrow_compute_shared
+ "-Wl,--pop-state")
+ endif()
+
+ if(ARG_EXTRA_LINK_LIBS)
+ list(APPEND EXTRA_LINK_LIBS ${ARG_EXTRA_LINK_LIBS})
+ endif()
Review Comment:
I haven't been able to make this work for `WIN32` yet, I'll keep
investigating how to force the linker to not optimize out
`arrow_compute_shared` and force adding it on `WIN32`. I am unsure this is what
we want to do. From what I understand the linker is allowed to skip libraries
not used by the end result and as `libarrow_compute_shared` is never used its
optimized out, that's why we have to use the `--no-as-needed` / `-force-load` /
`while-archive` flags. From my understanding, having the static initializer
there and never calling anything explicitly on `libarrow_compute` will make
anyone that tries to use Compute and link against Arrow to require those flags
to be set making the use of `arrow_compute` quite cumbersome.
At this point I think the explicit function call to `RegisterComputeKernels`
is a better approach as it's much simpler from a user stand-point.
@kou @pitrou any thoughts on this?
I am trying to investigate as this is new for me :) and I haven't found much
info about those flags or how to use them on the different platforms. A couple
of links issues around those (not super relevant):
https://discourse.cmake.org/t/add-linker-archive-options-before-and-after-a-target/2373
https://github.com/PixarAnimationStudios/OpenUSD/pull/2284/files
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]