kou commented on PR #45618:
URL: https://github.com/apache/arrow/pull/45618#issuecomment-2804141414

   It seems that we need `--no-as-needed` linker flags. If we don't specify it, 
`libarrow_compute.so` isn't linked to test files such as 
`arrow-compute-aggregate-test`.
   
   This is not a good code but this works on Debian GNU/Linux with g++ 14.2.0:
   
   ```diff
   diff --git a/cpp/src/arrow/compute/kernels/CMakeLists.txt 
b/cpp/src/arrow/compute/kernels/CMakeLists.txt
   index 3e5239be96..d79482e629 100644
   --- a/cpp/src/arrow/compute/kernels/CMakeLists.txt
   +++ b/cpp/src/arrow/compute/kernels/CMakeLists.txt
   @@ -151,6 +151,9 @@ add_arrow_compute_test(aggregate_test
                           SOURCES
                           aggregate_test.cc
                           EXTRA_LINK_LIBS
   +                       "-Wl,--push-state,--no-as-needed"
   +                       arrow_compute_shared
   +                       "-Wl,--pop-state"
                           arrow_compute_kernels_testing
                           arrow_compute_testing
                           Boost::headers)
   diff --git a/cpp/src/arrow/compute/kernels/api.h 
b/cpp/src/arrow/compute/kernels/api.h
   index 3385d4cc80..deaf82626f 100644
   --- a/cpp/src/arrow/compute/kernels/api.h
   +++ b/cpp/src/arrow/compute/kernels/api.h
   @@ -23,7 +23,3 @@
    /// \defgroup compute-kernels Extra compute kernels
    /// @{
    /// @}
   -
   -#include "arrow/compute/kernels/registry.h"  // IWYU pragma: export
   -
   -static arrow::Status g_kernels_registered = 
arrow::compute::RegisterComputeKernels();
   diff --git a/cpp/src/arrow/compute/kernels/registry.cc 
b/cpp/src/arrow/compute/kernels/registry.cc
   index fe9c2df724..d62d25f74f 100644
   --- a/cpp/src/arrow/compute/kernels/registry.cc
   +++ b/cpp/src/arrow/compute/kernels/registry.cc
   @@ -33,11 +33,11 @@
    namespace arrow {
    namespace compute {
    
   -Status RegisterComputeKernels() {
   +void RegisterComputeKernels() {
      auto registry = GetFunctionRegistry();
      // TODO: Do we have a different way to avoid double registration?
      if (registry->GetFunction("abs").ok()) {
   -    return Status::OK();
   +    return;
      }
      // Register additional kernels on libarrow_compute
      // Scalar functions
   @@ -77,8 +77,10 @@ Status RegisterComputeKernels() {
      internal::RegisterScalarAggregateQuantile(registry);
      internal::RegisterScalarAggregateTDigest(registry);
      internal::RegisterScalarAggregateVariance(registry);
   -
   -  return Status::OK();
    }
   +
   +RegistryInitializer::RegistryInitializer() { RegisterComputeKernels(); }
   +
   +RegistryInitializer RegistryInitializer::instance;
    }  // namespace compute
    }  // namespace arrow
   diff --git a/cpp/src/arrow/compute/kernels/registry.h 
b/cpp/src/arrow/compute/kernels/registry.h
   index 02c002126a..2d9d95240e 100644
   --- a/cpp/src/arrow/compute/kernels/registry.h
   +++ b/cpp/src/arrow/compute/kernels/registry.h
   @@ -23,6 +23,11 @@
    
    namespace arrow::compute {
    
   -ARROW_COMPUTE_EXPORT Status RegisterComputeKernels();
   +ARROW_COMPUTE_EXPORT void RegisterComputeKernels();
   +class ARROW_COMPUTE_EXPORT RegistryInitializer {
   +  public:
   +    RegistryInitializer();
   +    static RegistryInitializer instance;
   +};
    
    }  // namespace arrow::compute
   ```


-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to