apache / arrow

Apache Arrow is a multi-language toolbox for accelerated data interchange and in-memory processing
https://arrow.apache.org/
Apache License 2.0
14.42k stars 3.51k forks source link

[C++] Bundled Mac C++ build fails when /usr/bin/libtool is an invalid libtool #44384

Open tomjakubowski opened 3 days ago

tomjakubowski commented 3 days ago

Describe the bug, including details regarding any error messages, version, and platform.

I am supporting a bundled build of libarrow in perspective's conda-forge feedstock. On the conda-forge arm64 cross-compiling builders, /usr/bin/libtool is broken due to some SDK issues (full logs). Here is the (stderr?) output of /usr/bin/libtool from our build logs:

  xcodebuild: error: SDK "/Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk" cannot be located.
  libtool: error: sh -c '/Applications/Xcode_15.2.app/Contents/Developer/usr/bin/xcodebuild -sdk /Applications/Xcode_15.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -find libtool 2> /dev/null' failed with exit code 16384: (null) (errno=No such file or directory)
  xcode-select: Failed to locate 'libtool', requesting installation of command line developer tools.

There is some logic in BuildUtils.cmake to locate libtool for bundling using find_program(libtool HINTS /usr/bin ...), which then fails:

  CMake Error at /Users/runner/miniforge3/conda-bld/perspective_1728519868797/work/rust/target/aarch64-apple-darwin/release/build/perspective-server-a7d183a58ee31af1/out/build/arrow-src/cpp/cmake_modules/BuildUtils.cmake:116 (message):
    libtool found appears to be the incompatible GNU libtool: /usr/bin/libtool

In this build environment, the LIBTOOL environment variable is set by conda to the name of a suitable Apple libtool on the PATH. I would propose that if LIBTOOL is set in the environment, that BuildUtils.cmake ought to use it instead of calling find_program.

To unblock us, I made this commit on top of 17.0.0 https://github.com/ProspectiveCo/arrow/commit/273a22873b3bdf2f88631441ba8fd80bc7a0dbf4. I'll use that as the basis for a PR to close this issue. I am new to both conda-build and arrow's build system and would be glad to hear better ideas of how to address this.

Component(s)

C++

tomjakubowski commented 2 days ago

Discussion in https://github.com/apache/arrow/issues/30937 suggests that Conda is probably also passing -DCMAKE_LIBTOOL=/path/to/or/name/of/some-suitable-apple-libtool (which perspective would forward on in its ExternalProject build of Arrow). Maybe it would better to check that cmake variable than an environment variable.

edit: learned from #44368 that CMAKE_LIBTOOL is used for MSVC builds. I'll do the same in my PR.

    if(CMAKE_LIBTOOL)
      set(BUNDLE_TOOL ${CMAKE_LIBTOOL})
    else()
      find_program(BUNDLE_TOOL lib