diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.cmake index 083ac2fe9a862..7a45e9cca59de 100644 --- a/cpp/cmake_modules/BuildUtils.cmake +++ b/cpp/cmake_modules/BuildUtils.cmake @@ -97,7 +97,27 @@ function(arrow_create_merged_static_lib output_target) endforeach() if(APPLE) - set(BUNDLE_COMMAND "libtool" "-no_warning_for_no_symbols" "-static" "-o" + # The apple-distributed libtool is what we want for bundling, but there is + # a GNU libtool that has a namecollision (and happens to be bundled with R, too). + # We are not compatible with GNU libtool, so we need to avoid it. + + # check in the obvious places first to find Apple's libtool + # HINTS is used before system paths and before PATHS, so we use that + # even though hard coded paths should go in PATHS + # TODO: use a VALIDATOR when we require cmake >= 3.25 + find_program(LIBTOOL_MACOS libtool HINTS /usr/bin + /Library/Developer/CommandLineTools/usr/bin) + + # confirm that the libtool we found is not GNU libtool + execute_process(COMMAND ${LIBTOOL_MACOS} -V + OUTPUT_VARIABLE LIBTOOL_V_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT "${LIBTOOL_V_OUTPUT}" MATCHES ".*cctools-([0-9.]+).*") + message(FATAL_ERROR "libtool found appears to be the incompatible GNU libtool: ${LIBTOOL_MACOS}" + ) + endif() + + set(BUNDLE_COMMAND ${LIBTOOL_MACOS} "-no_warning_for_no_symbols" "-static" "-o" ${output_lib_path} ${all_library_paths}) elseif(CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|GNU|Intel|IntelLLVM)$") set(ar_script_path ${CMAKE_BINARY_DIR}/${ARG_NAME}.ar) diff --git a/dev/tasks/r/github.macos-linux.local.yml b/dev/tasks/r/github.macos-linux.local.yml index 045c387b73f60..b221e8c5d8d5b 100644 --- a/dev/tasks/r/github.macos-linux.local.yml +++ b/dev/tasks/r/github.macos-linux.local.yml @@ -58,6 +58,18 @@ jobs: - uses: r-lib/actions/setup-r@v2 with: use-public-rspm: true + # CRAN builders have the entire bin here added to the path. This sometimes + # includes things like GNU libtool which name-collide with what we expect + - name: Add R.framework/Resources/bin to the path + if: contains(matrix.os, 'macOS') + run: echo "/Library/Frameworks/R.framework/Resources/bin" >> $GITHUB_PATH + - name : Check whether libtool in R is used + if: contains(matrix.os, 'macOS') + run: | + if [ "$(which libtool)" != "/Library/Frameworks/R.framework/Resources/bin/libtool" ]; then + echo "libtool provided by R isn't found: $(which libtool)" + exit 1 + fi - name: Install dependencies uses: r-lib/actions/setup-r-dependencies@v2 with: