【问题标题】:CMake fails with when attempting to compile simple test program尝试编译简单的测试程序时 CMake 失败
【发布时间】:2019-09-11 20:50:54
【问题描述】:

我正在尝试关注building pyarrow locally 的文档。具体来说,使用conda 指令:

conda create -y -n pyarrow-dev -c conda-forge \
    --file arrow/ci/conda_env_unix.yml \
    --file arrow/ci/conda_env_cpp.yml \
    --file arrow/ci/conda_env_python.yml \
    compilers \
    python=3.7
conda activate pyarrow-dev
export ARROW_HOME=$CONDA_PREFIX
git clone https://github.com/apache/arrow.git
mkdir arrow/cpp/build
pushd arrow/cpp/build
cmake -DCMAKE_INSTALL_PREFIX=$ARROW_HOME \
      -DCMAKE_INSTALL_LIBDIR=lib \
      -DARROW_FLIGHT=ON \
      -DARROW_GANDIVA=ON \
      -DARROW_ORC=ON \
      -DARROW_PARQUET=ON \
      -DARROW_PYTHON=ON \
      -DARROW_PLASMA=ON \
      -DARROW_BUILD_TESTS=ON \
      ..

cmake 指令失败并显示以下错误消息:

-- Building using CMake version: 3.12.3
-- The C compiler identification is Clang 4.0.1
-- The CXX compiler identification is Clang 4.0.1
-- Check for working C compiler: /Users/alex/miniconda3/envs/pyarrow-dev/bin/x86_64-apple-darwin13.4.0-clang
-- Check for working C compiler: /Users/alex/miniconda3/envs/pyarrow-dev/bin/x86_64-apple-darwin13.4.0-clang -- broken
CMake Error at /usr/local/Cellar/cmake/3.12.3/share/cmake/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/Users/alex/miniconda3/envs/pyarrow-dev/bin/x86_64-apple-darwin13.4.0-clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /Users/alex/Desktop/arrow/cpp/build/CMakeFiles/CMakeTmp

    Run Build Command:"/usr/bin/make" "cmTC_63f1f/fast"
    /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_63f1f.dir/build.make CMakeFiles/cmTC_63f1f.dir/build
    Building C object CMakeFiles/cmTC_63f1f.dir/testCCompiler.c.o
    /Users/alex/miniconda3/envs/pyarrow-dev/bin/x86_64-apple-darwin13.4.0-clang   -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk   -o CMakeFiles/cmTC_63f1f.dir/testCCompiler.c.o   -c /Users/alex/Desktop/arrow/cpp/build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_63f1f
    /usr/local/Cellar/cmake/3.12.3/bin/cmake -E cmake_link_script CMakeFiles/cmTC_63f1f.dir/link.txt --verbose=1
    /Users/alex/miniconda3/envs/pyarrow-dev/bin/x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs  CMakeFiles/cmTC_63f1f.dir/testCCompiler.c.o  -o cmTC_63f1f 
    ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
    ld: dynamic main executables must link with libSystem.dylib for architecture x86_64
    clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [cmTC_63f1f] Error 1
    make: *** [cmTC_63f1f/fast] Error 2




  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:25 (project)


-- Configuring incomplete, errors occurred!
See also "/Users/alex/Desktop/arrow/cpp/build/CMakeFiles/CMakeOutput.log".
See also "/Users/alex/Desktop/arrow/cpp/build/CMakeFiles/CMakeError.log".

特别是,违规行似乎是:

ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd

我使用的是 macOS Mojave 10.14.4,并且已经安装了 Xcode 10.2.1(通过Apple Developer download list)。当我运行xcode-select -p 时,我会退出/Applications/Xcode.app/Contents/Developer。

搜索此错误消息将我带到this GH comment,它指向this SO answer。我按照该答案中的说明进行操作,特别是运行 sudo xcode-select -s /Applications/Xcode.app/Contents/Developer,但它并没有解决问题。

libSystem.tbd的内容是:

--- !tapi-tbd-v3
archs:           [ x86_64 ]
uuids:           [ 'x86_64: 72841192-B0C9-36A0-8E55-ED651EADEF08' ]
platform:        zippered
install-name:    /usr/lib/libSystem.B.dylib
current-version: 1252.250.1
objc-constraint: none
exports:         
  - archs:           [ x86_64 ]
    re-exports:      [ /usr/lib/system/libcache.dylib, /usr/lib/system/libcommonCrypto.dylib, 
                       /usr/lib/system/libcompiler_rt.dylib, /usr/lib/system/libcopyfile.dylib, 
                       /usr/lib/system/libcorecrypto.dylib, /usr/lib/system/libdispatch.dylib, 
                       /usr/lib/system/libdyld.dylib, /usr/lib/system/libkeymgr.dylib, 
                       /usr/lib/system/liblaunch.dylib, /usr/lib/system/libmacho.dylib, 
                       /usr/lib/system/libquarantine.dylib, /usr/lib/system/libremovefile.dylib, 
                       /usr/lib/system/libsystem_asl.dylib, /usr/lib/system/libsystem_blocks.dylib, 
                       /usr/lib/system/libsystem_c.dylib, /usr/lib/system/libsystem_configuration.dylib, 
                       /usr/lib/system/libsystem_coreservices.dylib, /usr/lib/system/libsystem_darwin.dylib, 
                       /usr/lib/system/libsystem_dnssd.dylib, /usr/lib/system/libsystem_info.dylib, 
                       /usr/lib/system/libsystem_kernel.dylib, /usr/lib/system/libsystem_m.dylib, 
                       /usr/lib/system/libsystem_malloc.dylib, /usr/lib/system/libsystem_networkextension.dylib, 
                       /usr/lib/system/libsystem_notify.dylib, /usr/lib/system/libsystem_platform.dylib, 
                       /usr/lib/system/libsystem_pthread.dylib, /usr/lib/system/libsystem_sandbox.dylib, 
                       /usr/lib/system/libsystem_secinit.dylib, /usr/lib/system/libsystem_symptoms.dylib, 
                       /usr/lib/system/libsystem_trace.dylib, /usr/lib/system/libunwind.dylib, 
                       /usr/lib/system/libxpc.dylib ]
    symbols:         [ 'R8289209$_close', 'R8289209$_fork', 'R8289209$_fsync', 'R8289209$_getattrlist', 
                       'R8289209$_getrlimit', 'R8289209$_getxattr', 'R8289209$_open', 
                       'R8289209$_pthread_attr_destroy', 'R8289209$_pthread_attr_init', 
                       'R8289209$_pthread_attr_setdetachstate', 'R8289209$_pthread_create', 
                       'R8289209$_pthread_mutex_lock', 'R8289209$_pthread_mutex_unlock', 
                       'R8289209$_pthread_self', 'R8289209$_ptrace', 'R8289209$_read', 
                       'R8289209$_setattrlist', 'R8289209$_setrlimit', 'R8289209$_sigaction', 
                       'R8289209$_stat', 'R8289209$_sysctl', 'R8289209$_time', 'R8289209$_unlink', 
                       'R8289209$_write', ___crashreporter_info__, _libSystem_atfork_child, 
                       _libSystem_atfork_parent, _libSystem_atfork_prepare, _mach_init_routine ]
...

我做错了什么,如何修复我的环境,以便正确构建 CMake?

【问题讨论】:

  • 嗨——你想写信给 Arrow 开发者邮件列表 dev@arrow.apache.org,我们可以更好地帮助你吗?尽管您遇到的问题似乎是环境问题,而不是 Arrow 本身的问题

标签: c++ xcode cmake pyarrow apache-arrow


【解决方案1】:

这里的问题是您缺少使用 conda-forge 提供的编译器构建的正确 OSX SDK。

您需要从例如下载 10.9 OSX SDK https://github.com/phracker/MacOSX-SDKs/releases 并将其解压缩到您的硬盘驱动器上,例如/opt/MacOSX10.9.sdk。激活 conda 环境后,使用 export CONDA_BUILD_SYSROOT=/opt/MacOSX10.9.sdk 设置此 SDK 的路径。

【讨论】:

  • 这解决了这个问题(我认为 Arrow 不在 MacOSX10.14.sdk 上构建,因为它更新并引入了重大更改?)。但是,它导致了不同的问题:Could not find a configuration file for package "LLVM" that is compatible with requested version "7.0". 错误消息表明 CMake 找到但不接受,/Users/alex/miniconda3/envs/pyarrow-dev/lib/cmake/llvm/LLVMConfig.cmake, version: 4.0.1。
  • "XCode" article on Wikipedia 表示与pyarrow 捆绑的LLVM 版本仅与XCode "9.2ish" 兼容。 pyarrow 开发团队使用什么版本的 XCode?​​span>
  • Arrow 使用较新的 SDK 构建,而不是 conda-forge 编译器(即您需要完全不同的设置)。对于后一个错误,这是由于 conda-forge 中的包冲突造成的。目前,您无法在 OSX 上构建 Gandiva 功能;只需将ARROW_GANDIVA 设置为OFF。
  • 这样就解决了。将 ARROW_GANDIVA 设置为 OFF 会导致构建成功。我会考虑 (1) 记录使用 devdocs 中的 conda 代码路径在 macOS 上构建 ARROW_GANDIVA 可能存在问题(除非这是一个临时问题?)和 (2) 说明 XCode SDK 的哪些版本是已知的有利于这条构建路径。 ?
  • 你救了我的一天,伙计
猜你喜欢
  • 2013-01-13
  • 1970-01-01
  • 2015-08-13
  • 1970-01-01
  • 1970-01-01
  • 2021-03-18
  • 1970-01-01
  • 2023-04-08
  • 1970-01-01
相关资源
最近更新 更多