This is an automated email from the ASF dual-hosted git repository.

raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new 4ecdfe046e GH-54902: [C++] Move GCS and google-cloud-cpp to its own 
libarrow_gcs.so (#54905)
4ecdfe046e is described below

commit 4ecdfe046ec367aa4e046f28f840c21d4e18701a
Author: Raúl Cumplido <[email protected]>
AuthorDate: Tue Oct 27 10:16:21 2026 +0100

    GH-54902: [C++] Move GCS and google-cloud-cpp to its own libarrow_gcs.so 
(#54905)
    
    ### Rationale for this change
    
    Trying to reduce the size of libarrow.so and remove google-cloud-cpp SDK on 
some builds. Allow for users to plug and play based on requirements and divide 
our functionality into cleaner modules.
    
    ### What changes are included in this PR?
    
    Unconditionally build GCS and the google-cloud-cpp SDK into a different 
module libarrow_gcs.so outside of libarrow.so.
    Update bindings to link against the new libarrow_gcs.so library.
    Update the Linux Package jobs to have the new module into a different 
package.
    
    ### Are these changes tested?
    
    Yes via CI
    
    ### Are there any user-facing changes?
    
    Yes, users will need to either link against libarrow_s3.so or register 
using LoadFileSystemFactories
    
    ### Was AI used for this PR?
    
    In accordance to the [AI generation 
guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generated-code),
 please disclose below whether and how AI was used in this PR.
    
    **PR code and description written by:**
    
    - [x] Human
    - [x] AI
    
    **Reviewed before submission by:**
    
    - [x] Human
    - [ ] AI
    - [ ] Not reviewed
    
    * GitHub Issue: #54902
    
    Authored-by: Raúl Cumplido <[email protected]>
    Signed-off-by: Raúl Cumplido <[email protected]>
---
 ci/scripts/python_wheel_xlinux_build.sh            | 13 ++-
 cpp/CMakeLists.txt                                 |  9 ++
 cpp/cmake_modules/ThirdpartyToolchain.cmake        | 40 +++++----
 cpp/src/arrow/ArrowGcsConfig.cmake.in              | 44 ++++++++++
 cpp/src/arrow/CMakeLists.txt                       | 98 +++++++++++++++-------
 cpp/src/arrow/arrow-gcs.pc.in                      | 30 +++++++
 cpp/src/arrow/filesystem/CMakeLists.txt            | 20 ++++-
 cpp/src/arrow/filesystem/filesystem.cc             | 13 ---
 cpp/src/arrow/filesystem/gcs_visibility.h          | 49 +++++++++++
 cpp/src/arrow/filesystem/gcsfs.cc                  | 11 +++
 cpp/src/arrow/filesystem/gcsfs.h                   |  7 +-
 cpp/src/arrow/filesystem/gcsfs_internal.h          | 19 +++--
 cpp/src/arrow/filesystem/gcsfs_module.cc           | 18 ++++
 cpp/src/arrow/filesystem/gcsfs_module_test.cc      | 53 ++++++++++++
 cpp/src/arrow/filesystem/gcsfs_test.cc             | 15 ++++
 cpp/src/arrow/filesystem/meson.build               |  1 +
 .../linux-packages/apache-arrow/debian/control.in  | 25 ++++++
 .../apache-arrow/debian/libarrow-gcs-2700.install  |  1 +
 .../apache-arrow/debian/libarrow-gcs-dev.install   |  4 +
 .../linux-packages/apache-arrow/yum/arrow.spec.in  | 34 ++++++++
 docs/source/cpp/build_system.rst                   |  2 +
 python/CMakeLists.txt                              | 16 ++++
 r/configure                                        |  4 +
 r/configure.win                                    | 10 ++-
 24 files changed, 462 insertions(+), 74 deletions(-)

diff --git a/ci/scripts/python_wheel_xlinux_build.sh 
b/ci/scripts/python_wheel_xlinux_build.sh
index 0a5d63affc..8931bfbfa9 100755
--- a/ci/scripts/python_wheel_xlinux_build.sh
+++ b/ci/scripts/python_wheel_xlinux_build.sh
@@ -20,7 +20,16 @@
 set -ex
 
 function check_arrow_visibility {
-    nm --demangle --dynamic /tmp/arrow-dist/lib/libarrow.so > nm_arrow.log
+    local libs=(libarrow.so)
+    if [[ "${ARROW_S3}" == "ON" ]]; then
+        libs+=(libarrow_s3.so)
+    fi
+    if [[ "${ARROW_GCS}" == "ON" ]]; then
+        libs+=(libarrow_gcs.so)
+    fi
+    for lib in "${libs[@]}"; do
+        nm --demangle --dynamic "/tmp/arrow-dist/lib/${lib}"
+    done > nm_arrow.log
 
     # Filter out Arrow symbols and see if anything remains.
     # '_init' and '_fini' symbols may or not be present, we don't care.
@@ -37,7 +46,7 @@ function check_arrow_visibility {
     if [[ -f visible_symbols.log && ! -s visible_symbols.log ]]; then
         return 0
     else
-        echo "== Unexpected symbols exported by libarrow.so =="
+        echo "== Unexpected symbols exported by ${libs[*]} =="
         cat visible_symbols.log
         echo "================================================"
 
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 91d5304cc2..22bd1028b9 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -484,6 +484,15 @@ if(ARROW_BUILD_STATIC)
 endif()
 set(ARROW_FLIGHT_PC_REQUIRES_PRIVATE "")
 
+# For arrow-gcs.pc.
+set(ARROW_GCS_PC_CFLAGS "")
+set(ARROW_GCS_PC_CFLAGS_PRIVATE "")
+if(ARROW_BUILD_STATIC)
+  string(APPEND ARROW_GCS_PC_CFLAGS_PRIVATE " -DARROW_GCS_STATIC")
+endif()
+set(ARROW_GCS_PC_LIBS_PRIVATE "")
+set(ARROW_GCS_PC_REQUIRES_PRIVATE "")
+
 # For arrow-s3.pc.
 set(ARROW_S3_PC_CFLAGS "")
 set(ARROW_S3_PC_CFLAGS_PRIVATE "")
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake 
b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 200275a3be..85a1961ea6 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -1442,7 +1442,11 @@ endmacro()
 # pkg-config
 
 # SDK libraries (on macOS) may be available without .pc files
-macro(arrow_append_pc_system_library PC_PACKAGE PC_PREFIX FALLBACK)
+macro(arrow_append_pc_system_library
+      PC_PACKAGE
+      PC_PREFIX
+      FALLBACK
+      ARROW_PC_TARGET)
   find_package(PkgConfig QUIET)
   if(PkgConfig_FOUND)
     pkg_check_modules(${PC_PREFIX}
@@ -1452,10 +1456,10 @@ macro(arrow_append_pc_system_library PC_PACKAGE 
PC_PREFIX FALLBACK)
                       QUIET)
   endif()
   if(PkgConfig_FOUND AND ${PC_PREFIX}_FOUND)
-    string(APPEND ARROW_PC_REQUIRES_PRIVATE " ${PC_PACKAGE}")
+    string(APPEND ${ARROW_PC_TARGET}_PC_REQUIRES_PRIVATE " ${PC_PACKAGE}")
   else()
-    message(STATUS "No .pc for ${PC_PACKAGE}. Using ${FALLBACK} in arrow.pc")
-    string(APPEND ARROW_PC_LIBS_PRIVATE " ${FALLBACK}")
+    message(STATUS "No .pc for ${PC_PACKAGE}. Using ${FALLBACK} for 
${ARROW_PC_TARGET}")
+    string(APPEND ${ARROW_PC_TARGET}_PC_LIBS_PRIVATE " ${FALLBACK}")
   endif()
 endmacro()
 
@@ -3915,8 +3919,14 @@ if(ARROW_WITH_GOOGLE_CLOUD_CPP)
 
   # curl is required on all platforms. We always use system curl to
   # avoid conflict.
-  find_curl(ARROW)
-  resolve_dependency(google_cloud_cpp_storage PC_PACKAGE_NAMES 
google_cloud_cpp_storage)
+  find_curl(ARROW_GCS)
+  resolve_dependency(google_cloud_cpp_storage
+                     ARROW_CMAKE_PACKAGE_NAME
+                     ArrowGcs
+                     ARROW_PC_PACKAGE_NAME
+                     arrow-gcs
+                     PC_PACKAGE_NAMES
+                     google_cloud_cpp_storage)
   get_target_property(google_cloud_cpp_storage_INCLUDE_DIR 
google-cloud-cpp::storage
                       INTERFACE_INCLUDE_DIRECTORIES)
   message(STATUS "Found google-cloud-cpp::storage headers: 
${google_cloud_cpp_storage_INCLUDE_DIR}"
@@ -4480,16 +4490,18 @@ if(ARROW_WITH_AZURE_SDK)
 endif()
 
 if(ARROW_BUILD_STATIC)
-  if((ARROW_GCS AND google_cloud_cpp_storage_SOURCE STREQUAL "BUNDLED")
-     OR (ARROW_AZURE
-         AND AZURE_SDK_VENDORED
-         AND NOT WIN32))
-    arrow_append_pc_system_library("libcurl" ARROW_CURL_PC "-lcurl")
+  if(ARROW_GCS AND google_cloud_cpp_storage_SOURCE STREQUAL "BUNDLED")
+    arrow_append_pc_system_library("libcurl" ARROW_GCS_CURL_PC "-lcurl" 
ARROW_GCS)
+  endif()
+  if(ARROW_AZURE
+     AND AZURE_SDK_VENDORED
+     AND NOT WIN32)
+    arrow_append_pc_system_library("libcurl" ARROW_CURL_PC "-lcurl" ARROW)
   endif()
   if(ARROW_AZURE
      AND AZURE_SDK_VENDORED
      AND NOT WIN32)
-    arrow_append_pc_system_library("libxml-2.0" ARROW_LIBXML2_PC "-lxml2")
+    arrow_append_pc_system_library("libxml-2.0" ARROW_LIBXML2_PC "-lxml2" 
ARROW)
   endif()
   if(ARROW_GCS
      AND google_cloud_cpp_storage_SOURCE STREQUAL "BUNDLED"
@@ -4515,14 +4527,14 @@ if(ARROW_BUILD_STATIC)
                           NO_CMAKE_ENVIRONMENT_PATH
                           QUIET)
         if(ARROW_GCS_${ARROW_GCS_ABSL_PC_PACKAGE}_PC_FOUND)
-          string(APPEND ARROW_PC_REQUIRES_PRIVATE " 
${ARROW_GCS_ABSL_PC_PACKAGE}")
+          string(APPEND ARROW_GCS_PC_REQUIRES_PRIVATE " 
${ARROW_GCS_ABSL_PC_PACKAGE}")
         else()
           message(STATUS "No .pc for ${ARROW_GCS_ABSL_PC_PACKAGE}; "
                          "static pkg-config metadata may be incomplete. 
Consider CMake")
         endif()
       endforeach()
     else()
-      message(STATUS "PkgConfig not available. Skipping Abseil dependencies 
from arrow.pc"
+      message(STATUS "PkgConfig not available. Skipping Abseil dependencies 
from arrow-gcs.pc"
       )
     endif()
   endif()
diff --git a/cpp/src/arrow/ArrowGcsConfig.cmake.in 
b/cpp/src/arrow/ArrowGcsConfig.cmake.in
new file mode 100644
index 0000000000..9e82b03a1e
--- /dev/null
+++ b/cpp/src/arrow/ArrowGcsConfig.cmake.in
@@ -0,0 +1,44 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# This config sets the following variables in your project::
+#
+#   ArrowGcs_FOUND - true if Arrow GCS found on the system
+#
+# This config sets the following targets in your project::
+#
+#   ArrowGcs::arrow_gcs_shared - for linked as shared library if shared 
library is built
+#   ArrowGcs::arrow_gcs_static - for linked as static library if static 
library is built
+
+@PACKAGE_INIT@
+
+set(ARROW_GCS_SYSTEM_DEPENDENCIES "@ARROW_GCS_SYSTEM_DEPENDENCIES@")
+
+include(CMakeFindDependencyMacro)
+find_dependency(Arrow CONFIG)
+
+if(ARROW_BUILD_STATIC)
+  arrow_find_dependencies("${ARROW_GCS_SYSTEM_DEPENDENCIES}")
+endif()
+
+include("${CMAKE_CURRENT_LIST_DIR}/ArrowGcsTargets.cmake")
+
+arrow_keep_backward_compatibility(ArrowGcs arrow_gcs)
+
+check_required_components(ArrowGcs)
+
+arrow_show_details(ArrowGcs ARROW_GCS)
diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt
index 7c6313c326..e71d92fdb8 100644
--- a/cpp/src/arrow/CMakeLists.txt
+++ b/cpp/src/arrow/CMakeLists.txt
@@ -33,29 +33,6 @@ set(ARROW_SHARED_PRIVATE_LINK_LIBS)
 set(ARROW_SHARED_INSTALL_INTERFACE_LIBS)
 set(ARROW_STATIC_INSTALL_INTERFACE_LIBS)
 
-if(ARROW_GCS)
-  if(google_cloud_cpp_storage_SOURCE STREQUAL "SYSTEM")
-    list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS google-cloud-cpp::storage)
-  elseif(google_cloud_cpp_storage_SOURCE STREQUAL "BUNDLED")
-    list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS CURL::libcurl)
-    if(absl_SOURCE STREQUAL "SYSTEM")
-      # Bundled google-cloud-cpp with system Abseil needs these for static 
consumers.
-      list(APPEND
-           ARROW_STATIC_INSTALL_INTERFACE_LIBS
-           absl::base
-           absl::cord
-           absl::crc32c
-           absl::memory
-           absl::optional
-           absl::span
-           absl::str_format
-           absl::strings
-           absl::time
-           absl::variant)
-    endif()
-  endif()
-endif()
-
 if(ARROW_AZURE)
   if(Azure_SOURCE STREQUAL "SYSTEM")
     list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS 
${AZURE_SDK_LINK_LIBRARIES})
@@ -992,8 +969,31 @@ if(ARROW_FILESYSTEM)
                                 PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
   endif()
   if(ARROW_GCS)
-    list(APPEND ARROW_FILESYSTEM_SRCS filesystem/gcsfs.cc 
filesystem/gcsfs_internal.cc)
-    set_source_files_properties(filesystem/gcsfs.cc 
filesystem/gcsfs_internal.cc
+    set(ARROW_GCS_STATIC_INSTALL_INTERFACE_LIBS Arrow::arrow_static)
+    if(google_cloud_cpp_storage_SOURCE STREQUAL "SYSTEM")
+      list(APPEND ARROW_GCS_STATIC_INSTALL_INTERFACE_LIBS 
google-cloud-cpp::storage)
+    elseif(google_cloud_cpp_storage_SOURCE STREQUAL "BUNDLED")
+      list(APPEND ARROW_GCS_STATIC_INSTALL_INTERFACE_LIBS CURL::libcurl)
+      if(absl_SOURCE STREQUAL "SYSTEM")
+        # Bundled google-cloud-cpp with system Abseil needs these for static 
consumers.
+        list(APPEND
+             ARROW_GCS_STATIC_INSTALL_INTERFACE_LIBS
+             absl::base
+             absl::cord
+             absl::crc32c
+             absl::memory
+             absl::optional
+             absl::span
+             absl::str_format
+             absl::strings
+             absl::time
+             absl::variant)
+      endif()
+    endif()
+    set(ARROW_GCS_LIB_SRCS filesystem/gcsfs_module.cc filesystem/gcsfs.cc
+                           filesystem/gcsfs_internal.cc)
+    set_source_files_properties(filesystem/gcsfs_module.cc filesystem/gcsfs.cc
+                                filesystem/gcsfs_internal.cc
                                 PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
     # Suppress documentation warnings from google-cloud-cpp headers
     if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
@@ -1009,6 +1009,49 @@ if(ARROW_FILESYSTEM)
                    APPEND
                    PROPERTY COMPILE_OPTIONS 
"-Wno-error=deprecated-declarations")
     endif()
+    # If libarrow_gcs.a is only built, "pkg-config --cflags --libs
+    # arrow-gcs" outputs build flags for static linking not shared
+    # linking. ARROW_GCS_PC_* except ARROW_GCS_PC_*_PRIVATE are for the
+    # static linking case.
+    if(NOT ARROW_BUILD_SHARED AND ARROW_BUILD_STATIC)
+      string(APPEND ARROW_GCS_PC_CFLAGS "${ARROW_GCS_PC_CFLAGS_PRIVATE}")
+      set(ARROW_GCS_PC_CFLAGS_PRIVATE "")
+      set(ARROW_GCS_PC_LIBS "${ARROW_GCS_PC_LIBS_PRIVATE}")
+      set(ARROW_GCS_PC_LIBS_PRIVATE "")
+      set(ARROW_GCS_PC_REQUIRES "${ARROW_GCS_PC_REQUIRES_PRIVATE}")
+      set(ARROW_GCS_PC_REQUIRES_PRIVATE "")
+    else()
+      set(ARROW_GCS_PC_LIBS "")
+      set(ARROW_GCS_PC_REQUIRES "")
+    endif()
+    add_arrow_lib(arrow_gcs
+                  CMAKE_PACKAGE_NAME
+                  ArrowGcs
+                  PKG_CONFIG_NAME
+                  arrow-gcs
+                  SOURCES
+                  ${ARROW_GCS_LIB_SRCS}
+                  SHARED_LINK_LIBS
+                  arrow_shared
+                  SHARED_PRIVATE_LINK_LIBS
+                  google-cloud-cpp::storage
+                  SHARED_INSTALL_INTERFACE_LIBS
+                  Arrow::arrow_shared
+                  STATIC_LINK_LIBS
+                  arrow_static
+                  google-cloud-cpp::storage
+                  STATIC_INSTALL_INTERFACE_LIBS
+                  ${ARROW_GCS_STATIC_INSTALL_INTERFACE_LIBS}
+                  SHARED_LINK_FLAGS
+                  ${ARROW_VERSION_SCRIPT_FLAGS}
+                  OUTPUTS
+                  ARROW_GCS_LIBRARIES)
+    foreach(LIB_TARGET ${ARROW_GCS_LIBRARIES})
+      target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_GCS_EXPORTING)
+    endforeach()
+    if(ARROW_BUILD_STATIC AND WIN32)
+      target_compile_definitions(arrow_gcs_static PUBLIC ARROW_GCS_STATIC)
+    endif()
   endif()
   if(ARROW_HDFS)
     list(APPEND ARROW_FILESYSTEM_SRCS filesystem/hdfs.cc 
filesystem/hdfs_internal.cc)
@@ -1021,11 +1064,6 @@ if(ARROW_FILESYSTEM)
                             PRIVATE ${AZURE_SDK_LINK_LIBRARIES})
     endforeach()
   endif()
-  if(ARROW_GCS)
-    foreach(ARROW_FILESYSTEM_TARGET ${ARROW_FILESYSTEM_TARGETS})
-      target_link_libraries(${ARROW_FILESYSTEM_TARGET} PRIVATE 
google-cloud-cpp::storage)
-    endforeach()
-  endif()
   if(ARROW_HDFS)
     foreach(ARROW_FILESYSTEM_TARGET ${ARROW_FILESYSTEM_TARGETS})
       target_link_libraries(${ARROW_FILESYSTEM_TARGET} PRIVATE arrow::hadoop)
diff --git a/cpp/src/arrow/arrow-gcs.pc.in b/cpp/src/arrow/arrow-gcs.pc.in
new file mode 100644
index 0000000000..a372d298f4
--- /dev/null
+++ b/cpp/src/arrow/arrow-gcs.pc.in
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+prefix=@CMAKE_INSTALL_PREFIX@
+includedir=@ARROW_PKG_CONFIG_INCLUDEDIR@
+libdir=@ARROW_PKG_CONFIG_LIBDIR@
+
+Name: Apache Arrow GCS
+Description: Apache Arrow's GCS filesystem implementation.
+Version: @ARROW_VERSION@
+Requires: arrow@ARROW_GCS_PC_REQUIRES@
+Requires.private:@ARROW_GCS_PC_REQUIRES_PRIVATE@
+Libs: -L${libdir} -larrow_gcs@ARROW_GCS_PC_LIBS@
+Libs.private:@ARROW_GCS_PC_LIBS_PRIVATE@
+Cflags:@ARROW_GCS_PC_CFLAGS@
+Cflags.private:@ARROW_GCS_PC_CFLAGS_PRIVATE@
diff --git a/cpp/src/arrow/filesystem/CMakeLists.txt 
b/cpp/src/arrow/filesystem/CMakeLists.txt
index 00db5df1df..154c216193 100644
--- a/cpp/src/arrow/filesystem/CMakeLists.txt
+++ b/cpp/src/arrow/filesystem/CMakeLists.txt
@@ -43,17 +43,35 @@ if(ARROW_BUILD_BENCHMARKS)
 endif()
 
 if(ARROW_GCS)
+  set(ARROW_GCS_TEST_EXTRA_LINK_LIBS)
+  if(ARROW_TEST_LINKAGE STREQUAL "shared")
+    list(APPEND ARROW_GCS_TEST_EXTRA_LINK_LIBS arrow_gcs_shared)
+  else()
+    list(APPEND ARROW_GCS_TEST_EXTRA_LINK_LIBS arrow_gcs_static)
+  endif()
+  list(APPEND ARROW_GCS_TEST_EXTRA_LINK_LIBS google-cloud-cpp::storage)
   add_arrow_test(gcsfs_test
                  EXTRA_LABELS
                  filesystem
                  EXTRA_LINK_LIBS
-                 google-cloud-cpp::storage)
+                 ${ARROW_GCS_TEST_EXTRA_LINK_LIBS})
   if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
     if(TARGET arrow-gcsfs-test)
       target_compile_options(arrow-gcsfs-test PRIVATE -Wno-documentation
                                                       
-Wno-documentation-deprecated-sync)
     endif()
   endif()
+  if(ARROW_BUILD_TESTS AND ARROW_BUILD_SHARED)
+    add_arrow_test(gcsfs_module_test
+                   SOURCES
+                   gcsfs_module_test.cc
+                   EXTRA_LABELS
+                   filesystem
+                   DEFINITIONS
+                   ARROW_GCS_LIBPATH="$<TARGET_FILE:arrow_gcs_shared>"
+                   EXTRA_DEPENDENCIES
+                   arrow_gcs_shared)
+  endif()
 endif()
 
 if(ARROW_AZURE)
diff --git a/cpp/src/arrow/filesystem/filesystem.cc 
b/cpp/src/arrow/filesystem/filesystem.cc
index f92336e004..c15bc06681 100644
--- a/cpp/src/arrow/filesystem/filesystem.cc
+++ b/cpp/src/arrow/filesystem/filesystem.cc
@@ -28,9 +28,6 @@
 #ifdef ARROW_AZURE
 #  include "arrow/filesystem/azurefs.h"
 #endif
-#ifdef ARROW_GCS
-#  include "arrow/filesystem/gcsfs.h"
-#endif
 #ifdef ARROW_HDFS
 #  include "arrow/filesystem/hdfs.h"
 #endif
@@ -920,16 +917,6 @@ Result<std::shared_ptr<FileSystem>> FileSystemFromUriReal(
     return Status::NotImplemented(
         "Got Azure Blob File System URI but Arrow compiled without Azure Blob 
File "
         "System support");
-#endif
-  }
-  if (scheme == "gs" || scheme == "gcs") {
-#ifdef ARROW_GCS
-    ARROW_ASSIGN_OR_RAISE(auto options, GcsOptions::FromUri(uri, out_path));
-    return GcsFileSystem::Make(options, io_context);
-#else
-    return Status::NotImplemented(
-        "Got GCS URI but Arrow compiled "
-        "without GCS support");
 #endif
   }
   if (scheme == "hdfs" || scheme == "viewfs") {
diff --git a/cpp/src/arrow/filesystem/gcs_visibility.h 
b/cpp/src/arrow/filesystem/gcs_visibility.h
new file mode 100644
index 0000000000..33b4d614d1
--- /dev/null
+++ b/cpp/src/arrow/filesystem/gcs_visibility.h
@@ -0,0 +1,49 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#pragma once
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+#  if defined(_MSC_VER)
+#    pragma warning(push)
+#    pragma warning(disable : 4251)
+#  else
+#    pragma GCC diagnostic ignored "-Wattributes"
+#  endif
+
+#  ifdef ARROW_GCS_STATIC
+#    define ARROW_GCS_EXPORT
+#  elif defined(ARROW_GCS_EXPORTING)
+#    define ARROW_GCS_EXPORT __declspec(dllexport)
+#  else
+#    define ARROW_GCS_EXPORT __declspec(dllimport)
+#  endif
+
+#  define ARROW_GCS_NO_EXPORT
+
+#  if defined(_MSC_VER)
+#    pragma warning(pop)
+#  endif
+
+#else  // Not Windows
+#  ifndef ARROW_GCS_EXPORT
+#    define ARROW_GCS_EXPORT __attribute__((visibility("default")))
+#  endif
+#  ifndef ARROW_GCS_NO_EXPORT
+#    define ARROW_GCS_NO_EXPORT __attribute__((visibility("hidden")))
+#  endif
+#endif
diff --git a/cpp/src/arrow/filesystem/gcsfs.cc 
b/cpp/src/arrow/filesystem/gcsfs.cc
index ffeba9eadc..4273b8a324 100644
--- a/cpp/src/arrow/filesystem/gcsfs.cc
+++ b/cpp/src/arrow/filesystem/gcsfs.cc
@@ -977,5 +977,16 @@ Result<std::shared_ptr<GcsFileSystem>> GcsFileSystem::Make(
 GcsFileSystem::GcsFileSystem(const GcsOptions& options, const io::IOContext& 
context)
     : FileSystem(context), impl_(std::make_shared<Impl>(options)) {}
 
+static Result<std::shared_ptr<FileSystem>> GcsFileSystemFactory(
+    const arrow::util::Uri& uri, const io::IOContext& io_context, std::string* 
out_path) {
+  ARROW_ASSIGN_OR_RAISE(auto options, GcsOptions::FromUri(uri, out_path));
+  return GcsFileSystem::Make(options, io_context);
+}
+
+FileSystemRegistrar kGcsFileSystemModule[]{
+    ARROW_REGISTER_FILESYSTEM("gs", GcsFileSystemFactory, {}),
+    ARROW_REGISTER_FILESYSTEM("gcs", GcsFileSystemFactory, {}),
+};
+
 }  // namespace fs
 }  // namespace arrow
diff --git a/cpp/src/arrow/filesystem/gcsfs.h b/cpp/src/arrow/filesystem/gcsfs.h
index 6fe6f478b4..c215c8036d 100644
--- a/cpp/src/arrow/filesystem/gcsfs.h
+++ b/cpp/src/arrow/filesystem/gcsfs.h
@@ -23,6 +23,7 @@
 #include <vector>
 
 #include "arrow/filesystem/filesystem.h"
+#include "arrow/filesystem/gcs_visibility.h"
 #include "arrow/util/uri.h"
 
 namespace arrow {
@@ -37,7 +38,7 @@ struct GcsCredentialsHolder;
 class GcsFileSystem;
 
 /// \brief Container for GCS Credentials and information necessary to recreate 
them.
-class ARROW_EXPORT GcsCredentials {
+class ARROW_GCS_EXPORT GcsCredentials {
  public:
   bool Equals(const GcsCredentials& other) const;
   bool anonymous() const { return anonymous_; }
@@ -62,7 +63,7 @@ class ARROW_EXPORT GcsCredentials {
 };
 
 /// Options for the GcsFileSystem implementation.
-struct ARROW_EXPORT GcsOptions {
+struct ARROW_GCS_EXPORT GcsOptions {
   /// \brief Equivalent to GcsOptions::Defaults().
   GcsOptions();
   GcsCredentials credentials;
@@ -182,7 +183,7 @@ struct ARROW_EXPORT GcsOptions {
 ///   proportional to the number of objects in the prefix. Listing recursively 
takes
 ///   almost the same time as non-recursive lists.
 ///
-class ARROW_EXPORT GcsFileSystem : public FileSystem {
+class ARROW_GCS_EXPORT GcsFileSystem : public FileSystem {
  public:
   ~GcsFileSystem() override = default;
 
diff --git a/cpp/src/arrow/filesystem/gcsfs_internal.h 
b/cpp/src/arrow/filesystem/gcsfs_internal.h
index c1fd7891c3..cc7b16eeed 100644
--- a/cpp/src/arrow/filesystem/gcsfs_internal.h
+++ b/cpp/src/arrow/filesystem/gcsfs_internal.h
@@ -30,6 +30,7 @@
 #include <google/cloud/storage/well_known_parameters.h>
 
 #include "arrow/filesystem/filesystem.h"
+#include "arrow/filesystem/gcs_visibility.h"
 
 namespace arrow {
 namespace fs {
@@ -44,28 +45,28 @@ struct GcsCredentialsHolder {
   std::shared_ptr<google::cloud::Credentials> credentials;
 };
 
-ARROW_EXPORT Status ToArrowStatus(const google::cloud::Status& s);
+ARROW_GCS_EXPORT Status ToArrowStatus(const google::cloud::Status& s);
 
-ARROW_EXPORT int ErrnoFromStatus(const google::cloud::Status& s);
+ARROW_GCS_EXPORT int ErrnoFromStatus(const google::cloud::Status& s);
 
-ARROW_EXPORT Result<google::cloud::storage::EncryptionKey> ToEncryptionKey(
+ARROW_GCS_EXPORT Result<google::cloud::storage::EncryptionKey> ToEncryptionKey(
     const std::shared_ptr<const KeyValueMetadata>& metadata);
 
-ARROW_EXPORT Result<google::cloud::storage::PredefinedAcl> ToPredefinedAcl(
+ARROW_GCS_EXPORT Result<google::cloud::storage::PredefinedAcl> ToPredefinedAcl(
     const std::shared_ptr<const KeyValueMetadata>& metadata);
 
-ARROW_EXPORT Result<google::cloud::storage::KmsKeyName> ToKmsKeyName(
+ARROW_GCS_EXPORT Result<google::cloud::storage::KmsKeyName> ToKmsKeyName(
     const std::shared_ptr<const KeyValueMetadata>& metadata);
 
-ARROW_EXPORT Result<google::cloud::storage::WithObjectMetadata> 
ToObjectMetadata(
+ARROW_GCS_EXPORT Result<google::cloud::storage::WithObjectMetadata> 
ToObjectMetadata(
     const std::shared_ptr<const KeyValueMetadata>& metadata);
 
-ARROW_EXPORT Result<std::shared_ptr<const KeyValueMetadata>> 
FromObjectMetadata(
+ARROW_GCS_EXPORT Result<std::shared_ptr<const KeyValueMetadata>> 
FromObjectMetadata(
     const google::cloud::storage::ObjectMetadata& m);
 
-ARROW_EXPORT std::int64_t Depth(std::string_view path);
+ARROW_GCS_EXPORT std::int64_t Depth(std::string_view path);
 
-ARROW_EXPORT google::cloud::Options AsGoogleCloudOptions(const GcsOptions& 
options);
+ARROW_GCS_EXPORT google::cloud::Options AsGoogleCloudOptions(const GcsOptions& 
options);
 
 }  // namespace internal
 }  // namespace fs
diff --git a/cpp/src/arrow/filesystem/gcsfs_module.cc 
b/cpp/src/arrow/filesystem/gcsfs_module.cc
new file mode 100644
index 0000000000..d91413138b
--- /dev/null
+++ b/cpp/src/arrow/filesystem/gcsfs_module.cc
@@ -0,0 +1,18 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "arrow/filesystem/filesystem_library.h"
diff --git a/cpp/src/arrow/filesystem/gcsfs_module_test.cc 
b/cpp/src/arrow/filesystem/gcsfs_module_test.cc
new file mode 100644
index 0000000000..93fdcc35c2
--- /dev/null
+++ b/cpp/src/arrow/filesystem/gcsfs_module_test.cc
@@ -0,0 +1,53 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <string>
+
+#include <gmock/gmock-matchers.h>
+#include <gtest/gtest.h>
+
+#include "arrow/filesystem/filesystem.h"
+#include "arrow/testing/gtest_util.h"
+
+namespace arrow::fs {
+
+class RegistrationTestEnvironment : public ::testing::Environment {
+ public:
+  void SetUp() override { 
ASSERT_OK(LoadFileSystemFactories(ARROW_GCS_LIBPATH)); }
+};
+
+auto* lib_env = ::testing::AddGlobalTestEnvironment(new 
RegistrationTestEnvironment);
+
+TEST(GcsModuleTest, FromUri) {
+  std::string path;
+  for (const auto* scheme : {"gs", "gcs"}) {
+    ASSERT_OK_AND_ASSIGN(
+        auto fs,
+        FileSystemFromUri(std::string(scheme) + "://anonymous@mybucket/foo", 
&path));
+    EXPECT_EQ(fs->type_name(), "gcs");
+    EXPECT_EQ(path, "mybucket/foo");
+  }
+}
+
+TEST(GcsModuleTest, FromUriAndOptionsNotImplemented) {
+  EXPECT_RAISES_WITH_MESSAGE_THAT(
+      NotImplemented, ::testing::HasSubstr("Filesystem factory does not 
support"),
+      FileSystemFromUriAndOptions("gs://anonymous@mybucket/foo",
+                                  {{"foo", std::string{"bar"}}}));
+}
+
+}  // namespace arrow::fs
diff --git a/cpp/src/arrow/filesystem/gcsfs_test.cc 
b/cpp/src/arrow/filesystem/gcsfs_test.cc
index a8637377aa..7c694de9e2 100644
--- a/cpp/src/arrow/filesystem/gcsfs_test.cc
+++ b/cpp/src/arrow/filesystem/gcsfs_test.cc
@@ -372,6 +372,21 @@ TEST(GcsFileSystem, OptionsFromUri) {
                 GcsOptions::FromUri("gs://foo/bar/?retry_limit_seconds=-1", 
&path));
 }
 
+TEST(GcsFileSystem, FileSystemFromUriRegistry) {
+  std::string path;
+  for (const auto* scheme : {"gs", "gcs"}) {
+    ASSERT_OK_AND_ASSIGN(
+        auto fs,
+        FileSystemFromUri(std::string(scheme) + "://anonymous@mybucket/foo", 
&path));
+    EXPECT_EQ(fs->type_name(), "gcs");
+    EXPECT_EQ(path, "mybucket/foo");
+  }
+  EXPECT_RAISES_WITH_MESSAGE_THAT(
+      NotImplemented, ::testing::HasSubstr("Filesystem factory does not 
support"),
+      FileSystemFromUriAndOptions("gs://anonymous@mybucket",
+                                  {{"foo", std::string{"bar"}}}));
+}
+
 TEST(GcsFileSystem, OptionsAccessToken) {
   TimePoint expiration = std::chrono::system_clock::now() + 
std::chrono::minutes(5);
   auto a = GcsOptions::FromAccessToken(/*access_token=*/"accesst", expiration);
diff --git a/cpp/src/arrow/filesystem/meson.build 
b/cpp/src/arrow/filesystem/meson.build
index a0c0a4a4ba..e2eaa116a7 100644
--- a/cpp/src/arrow/filesystem/meson.build
+++ b/cpp/src/arrow/filesystem/meson.build
@@ -21,6 +21,7 @@ install_headers(
         'azurefs.h',
         'filesystem.h',
         'filesystem_library.h',
+        'gcs_visibility.h',
         'gcsfs.h',
         'hdfs.h',
         'localfs.h',
diff --git a/dev/tasks/linux-packages/apache-arrow/debian/control.in 
b/dev/tasks/linux-packages/apache-arrow/debian/control.in
index a2d889c8ac..5609724a56 100644
--- a/dev/tasks/linux-packages/apache-arrow/debian/control.in
+++ b/dev/tasks/linux-packages/apache-arrow/debian/control.in
@@ -142,6 +142,19 @@ Description: Apache Arrow is a data processing library for 
analysis
  .
  This package provides C++ library files for S3 filesystem module.
 
+Package: libarrow-gcs-2700
+Section: libs
+Architecture: any
+Multi-Arch: same
+Pre-Depends: ${misc:Pre-Depends}
+Depends:
+  ${misc:Depends},
+  ${shlibs:Depends},
+  libarrow2700 (= ${binary:Version})
+Description: Apache Arrow is a data processing library for analysis
+ .
+ This package provides C++ library files for GCS filesystem module.
+
 Package: libarrow-flight2700
 Section: libs
 Architecture: any
@@ -264,6 +277,18 @@ Description: Apache Arrow is a data processing library for 
analysis
  .
  This package provides C++ library files for S3 filesystem module.
 
+Package: libarrow-gcs-dev
+Section: libdevel
+Architecture: any
+Multi-Arch: same
+Depends:
+  ${misc:Depends},
+  libarrow-gcs-2700 (= ${binary:Version}),
+  libarrow-dev (= ${binary:Version})
+Description: Apache Arrow is a data processing library for analysis
+ .
+ This package provides C++ library files for GCS filesystem module.
+
 Package: libarrow-flight-dev
 Section: libdevel
 Architecture: any
diff --git 
a/dev/tasks/linux-packages/apache-arrow/debian/libarrow-gcs-2700.install 
b/dev/tasks/linux-packages/apache-arrow/debian/libarrow-gcs-2700.install
new file mode 100644
index 0000000000..492d1d22b5
--- /dev/null
+++ b/dev/tasks/linux-packages/apache-arrow/debian/libarrow-gcs-2700.install
@@ -0,0 +1 @@
+usr/lib/*/libarrow_gcs.so.*
diff --git 
a/dev/tasks/linux-packages/apache-arrow/debian/libarrow-gcs-dev.install 
b/dev/tasks/linux-packages/apache-arrow/debian/libarrow-gcs-dev.install
new file mode 100644
index 0000000000..ccce70981d
--- /dev/null
+++ b/dev/tasks/linux-packages/apache-arrow/debian/libarrow-gcs-dev.install
@@ -0,0 +1,4 @@
+usr/lib/*/cmake/ArrowGcs/
+usr/lib/*/libarrow_gcs.a
+usr/lib/*/libarrow_gcs.so
+usr/lib/*/pkgconfig/arrow-gcs.pc
diff --git a/dev/tasks/linux-packages/apache-arrow/yum/arrow.spec.in 
b/dev/tasks/linux-packages/apache-arrow/yum/arrow.spec.in
index ef3e9d5a4f..3932effdcb 100644
--- a/dev/tasks/linux-packages/apache-arrow/yum/arrow.spec.in
+++ b/dev/tasks/linux-packages/apache-arrow/yum/arrow.spec.in
@@ -358,6 +358,40 @@ Libraries and header files for Apache Arrow Compute
 %{_libdir}/libarrow_compute.so
 %{_libdir}/pkgconfig/arrow-compute.pc
 
+%if %{use_gcs}
+%package -n %{name}%{so_version}-gcs-libs
+Summary:       C++ library for the GCS filesystem
+License:       Apache-2.0
+Requires:      %{name}%{so_version}-libs = %{version}-%{release}
+
+%description -n %{name}%{so_version}-gcs-libs
+This package contains the libraries for Apache Arrow GCS filesystem.
+
+%files -n %{name}%{so_version}-gcs-libs
+%defattr(-,root,root,-)
+%doc README.md
+%license LICENSE.txt NOTICE.txt
+%{_libdir}/libarrow_gcs.so.*
+
+%package gcs-devel
+Summary:       Libraries and header files for Apache Arrow GCS filesystem
+License:       Apache-2.0
+Requires:      %{name}%{so_version}-gcs-libs = %{version}-%{release}
+Requires:      %{name}-devel = %{version}-%{release}
+
+%description gcs-devel
+Libraries and header files for Apache Arrow GCS filesystem.
+
+%files gcs-devel
+%defattr(-,root,root,-)
+%doc README.md
+%license LICENSE.txt NOTICE.txt
+%{_libdir}/cmake/ArrowGcs/
+%{_libdir}/libarrow_gcs.a
+%{_libdir}/libarrow_gcs.so
+%{_libdir}/pkgconfig/arrow-gcs.pc
+%endif
+
 %package -n %{name}%{so_version}-acero-libs
 Summary:       C++ library to execute a query in streaming
 License:       Apache-2.0
diff --git a/docs/source/cpp/build_system.rst b/docs/source/cpp/build_system.rst
index 8b156ae25c..800631b6e0 100644
--- a/docs/source/cpp/build_system.rst
+++ b/docs/source/cpp/build_system.rst
@@ -120,6 +120,7 @@ This is the list of available packages:
 * ArrowFlight
 * ArrowFlightSql
 * ArrowFlightTesting
+* ArrowGcs
 * ArrowS3
 * ArrowSubstrait
 * ArrowTesting
@@ -191,6 +192,7 @@ all available packages:
   * ``arrow-filesystem``
   * ``arrow-flight-testing``
   * ``arrow-flight``
+  * ``arrow-gcs``
   * ``arrow-json``
   * ``arrow-orc``
   * ``arrow-python-flight``
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 53f15ba4e7..5bff8bcc64 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -736,6 +736,18 @@ if(PYARROW_BUILD_GCS)
   if(NOT ARROW_GCS)
     message(FATAL_ERROR "You must build Arrow C++ with ARROW_GCS=ON")
   endif()
+  find_package(ArrowGcs REQUIRED)
+  if(ARROW_BUILD_SHARED)
+    if(PYARROW_BUNDLE_ARROW_CPP)
+      bundle_arrow_lib(${ARROW_GCS_SHARED_LIB} SO_VERSION ${ARROW_SO_VERSION})
+      if(MSVC)
+        bundle_arrow_import_lib(${ARROW_GCS_IMPORT_LIB})
+      endif()
+    endif()
+    set(GCS_LINK_LIBS ArrowGcs::arrow_gcs_shared)
+  else()
+    set(GCS_LINK_LIBS ArrowGcs::arrow_gcs_static)
+  endif()
   list(APPEND CYTHON_EXTENSIONS _gcsfs)
 endif()
 
@@ -1052,6 +1064,10 @@ if(PYARROW_BUILD_PARQUET)
   endif()
 endif()
 
+if(PYARROW_BUILD_GCS)
+  target_link_libraries(_gcsfs PRIVATE ${GCS_LINK_LIBS})
+endif()
+
 if(PYARROW_BUILD_S3)
   target_link_libraries(_s3fs PRIVATE ${S3_LINK_LIBS})
 endif()
diff --git a/r/configure b/r/configure
index 9919a39456..87b48d5728 100755
--- a/r/configure
+++ b/r/configure
@@ -369,6 +369,10 @@ add_feature_flags () {
     fi
     if arrow_built_with ARROW_GCS; then
       PKG_CFLAGS_FEATURES="$PKG_CFLAGS_FEATURES -DARROW_R_WITH_GCS"
+      PKG_CONFIG_NAMES_FEATURES="$PKG_CONFIG_NAMES_FEATURES arrow-gcs"
+      PKG_LIBS_FEATURES_WITHOUT_PC="-larrow_gcs $PKG_LIBS_FEATURES_WITHOUT_PC"
+      # NOTE: arrow_gcs is assumed to have the same -L flag as arrow
+      # so there is no need to add its location to PKG_DIRS
     fi
     if arrow_built_with ARROW_GCS || arrow_built_with ARROW_S3 || 
arrow_built_with ARROW_AZURE; then
       # If pkg-config is available it will handle this for us automatically
diff --git a/r/configure.win b/r/configure.win
index f33d965809..e90d585e3b 100755
--- a/r/configure.win
+++ b/r/configure.win
@@ -83,13 +83,14 @@ function configure_binaries() {
   # NOTE: If you make changes to the libraries below, you should also change
   # ci/scripts/r_windows_build.sh and ci/scripts/PKGBUILD
   PKG_CFLAGS="-I${RWINLIB}/include -DARROW_STATIC -DARROW_COMPUTE_STATIC 
-DPARQUET_STATIC \
-              -DARROW_DS_STATIC -DARROW_ACERO_STATIC -DARROW_S3_STATIC \
+              -DARROW_DS_STATIC -DARROW_ACERO_STATIC -DARROW_S3_STATIC 
-DARROW_GCS_STATIC \
               -DARROW_R_WITH_PARQUET -DARROW_R_WITH_COMPUTE 
-DARROW_R_WITH_ACERO \
               -DARROW_R_WITH_DATASET -DARROW_R_WITH_JSON \
               -DARROW_R_WITH_S3 -DARROW_R_WITH_GCS" # -DARROW_R_WITH_AZURE
   PKG_LIBS="-L${RWINLIB}/lib"'$(subst gcc,,$(COMPILED_BY))$(R_ARCH) '
   PKG_LIBS="$PKG_LIBS -L${RWINLIB}/lib"'$(R_ARCH)$(CRT) '
-  PKG_LIBS="$PKG_LIBS -larrow_dataset -larrow_acero -lparquet -larrow_compute 
-larrow_s3 -larrow -larrow_bundled_dependencies \
+  PKG_LIBS="$PKG_LIBS -larrow_dataset -larrow_acero -lparquet -larrow_compute 
-larrow_s3 \
+            -larrow_gcs -larrow -larrow_bundled_dependencies \
             -lutf8proc -lsnappy -lz -lzstd -llz4 -lbz2 ${BROTLI_LIBS} -lole32 \
             ${MIMALLOC_LIBS} ${OPENSSL_LIBS} -lre2 ${AWS_LIBS} ${GCS_LIBS}" # 
${AZURE_LIBS}
 
@@ -189,6 +190,10 @@ add_feature_flags () {
     # fi
     if arrow_built_with ARROW_GCS; then
       PKG_CFLAGS_FEATURES="$PKG_CFLAGS_FEATURES -DARROW_R_WITH_GCS"
+      PKG_CONFIG_NAMES_FEATURES="$PKG_CONFIG_NAMES_FEATURES arrow-gcs"
+      PKG_LIBS_FEATURES_WITHOUT_PC="-larrow_gcs $PKG_LIBS_FEATURES_WITHOUT_PC"
+      # NOTE: arrow_gcs is assumed to have the same -L flag as arrow
+      # so there is no need to add its location to PKG_DIRS
     fi
     if arrow_built_with ARROW_GCS || arrow_built_with ARROW_S3; then
       # If pkg-config is available it will handle this for us automatically
@@ -291,6 +296,7 @@ function configure_dev() {
 
   if [ $(cmake_option ARROW_GCS) -eq 1 ]; then
     PKG_CFLAGS="$PKG_CFLAGS -DARROW_R_WITH_GCS"
+    PKG_CONFIG_PACKAGES="$PKG_CONFIG_PACKAGES arrow-gcs"
   fi
 
   # if [ $(cmake_option ARROW_AZURE) -eq 1 ]; then

Reply via email to