MacOS13.1 M1源码编译 arch显示x64

如题,M1 Mac在源码编译时,arch显示为x64,导致llvm使用without M1 chip才能编译成功

环境

  • MacOS Ventura 13.1
  • M1 Max 32G mem
  • Apple clang version 14.0.0
  • iterm2(没有使用Rosette打开)

报错信息如下所示:

Build type: Release
– Compiling LLVM byte code file for arch x64
– Configuring done
CMake Error at /Users/ingram14/OutSideLib/taichi-llvm-15-m1/lib/cmake/llvm/LLVMExports.cmake:64 (set_target_properties):
The link interface of target “LLVMSupport” contains:

zstd::libzstd_shared

but the target was not found. Possible reasons include:

  • There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Hi @Ingram14 ,非常欢迎来到社区论坛。

你能贴出更完整的build信息么?

[]
['taichi', 'taichi.ui', 'taichi._snode', 'taichi.tools', 'taichi.types', 'taichi.ad', 'taichi.linalg', 'taichi.graph', 'taichi.algorithms', 'taichi._lib', 'taichi.math', 'taichi.lang', 'taichi.profiler', 'taichi.aot', 'taichi.lang.ast', 'taichi.lang.simt']
running clean
removing '_skbuild/macosx-10.16-x86_64-3.8/setuptools'
removing '/Users/ingram14/Git_Project/taichi/_skbuild' (and everything under it)
removing 'python/taichi/assets' (and everything under it)
removing 'build' (and everything under it)
removing generated file taichi/common/commit_hash.h
removing generated file taichi/common/version.h
(base) ➜  taichi git:(master) ✗ python setup.py develop --user
[]
['taichi', 'taichi.ui', 'taichi._snode', 'taichi.tools', 'taichi.types', 'taichi.ad', 'taichi.linalg', 'taichi.graph', 'taichi.algorithms', 'taichi._lib', 'taichi.math', 'taichi.lang', 'taichi.profiler', 'taichi.aot', 'taichi.lang.ast', 'taichi.lang.simt']


--------------------------------------------------------------------------------
-- Trying "Ninja" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
-------
--
Not searching for unused variables given on the command line.
-- The C compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is Clang 11.1.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/homebrew/opt/llvm@11/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/ingram14/Git_Project/taichi/_cmake_test_compile/build
--
-------
------------
-----------------
----------------------
---------------------------
--------------------------------
-- Trying "Ninja" generator - success
--------------------------------------------------------------------------------

Configuring Project
  Working directory:
    /Users/ingram14/Git_Project/taichi/_skbuild/macosx-10.16-x86_64-3.8/cmake-build
  Command:
    cmake /Users/ingram14/Git_Project/taichi -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/Users/ingram14/Git_Project/taichi/_skbuild/macosx-10.16-x86_64-3.8/cmake-install -DPYTHON_VERSION_STRING:STRING=3.8.8 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/Users/ingram14/.local/lib/python3.8/site-packages/skbuild/resources/cmake -DPYTHON_EXECUTABLE:PATH=/Users/ingram14/opt/anaconda3/bin/python -DPYTHON_INCLUDE_DIR:PATH=/Users/ingram14/opt/anaconda3/include/python3.8 -DPYTHON_LIBRARY:PATH=/Users/ingram14/opt/anaconda3/lib/libpython3.8.dylib -DPython_EXECUTABLE:PATH=/Users/ingram14/opt/anaconda3/bin/python -DPython_ROOT_DIR:PATH=/Users/ingram14/opt/anaconda3 -DPython_INCLUDE_DIR:PATH=/Users/ingram14/opt/anaconda3/include/python3.8 -DPython_FIND_REGISTRY:STRING=NEVER -DPython_NumPy_INCLUDE_DIRS:PATH=/Users/ingram14/.local/lib/python3.8/site-packages/numpy/core/include -DPython3_EXECUTABLE:PATH=/Users/ingram14/opt/anaconda3/bin/python -DPython3_ROOT_DIR:PATH=/Users/ingram14/opt/anaconda3 -DPython3_INCLUDE_DIR:PATH=/Users/ingram14/opt/anaconda3/include/python3.8 -DPython3_FIND_REGISTRY:STRING=NEVER -DPython3_NumPy_INCLUDE_DIRS:PATH=/Users/ingram14/.local/lib/python3.8/site-packages/numpy/core/include -DCMAKE_MAKE_PROGRAM:FILEPATH=/Users/ingram14/.local/lib/python3.8/site-packages/ninja/data/bin/ninja -DTI_VERSION_MAJOR=1 -DTI_VERSION_MINOR=4 -DTI_VERSION_PATCH=0 -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.16 -DCMAKE_OSX_ARCHITECTURES:STRING=x86_64

-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is Clang 11.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/homebrew/opt/llvm@11/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Taichi Version 1.4.0
       Commit dab203097278fe2b6c0b8d1e3413caed340f6e6a
Clang executable using host compiler /opt/homebrew/opt/llvm@11/bin/clang++
/opt/homebrew/opt/llvm@11/bin/clang++ --version: 11.1.0
-- Python: Using /Users/ingram14/opt/anaconda3/bin/python as the interpreter
    version: 3.8.8
    include: /Users/ingram14/opt/anaconda3/include/python3.8
    library: /Users/ingram14/opt/anaconda3/lib/libpython3.8.dylib
    numpy include: /Users/ingram14/.local/lib/python3.8/site-packages/numpy/core/include
-- Found PythonInterp: /Users/ingram14/opt/anaconda3/bin/python (found suitable version "3.8.8", minimum required is "3.6")
-- Found PythonLibs: /Users/ingram14/opt/anaconda3/lib/libpython3.8.dylib
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Failed
-- Performing Test HAS_FLTO_THIN
-- Performing Test HAS_FLTO_THIN - Failed
-- Found pybind11: /Users/ingram14/.local/lib/python3.8/site-packages/pybind11/include (found version "2.10.2")
Using C++ compiler: /opt/homebrew/opt/llvm@11/bin/clang++
Clang compiler detected. Using std=c++17.
Building for processor x86_64
Setting -march=nehalem for x86_64 processors
Using float32 (single) precision as real
CMake Warning at cmake/TaichiCore.cmake:46 (message):
  CUDA backend not supported on OS X.  Setting TI_WITH_CUDA to OFF.
Call Stack (most recent call first):
  CMakeLists.txt:156 (include)


CMake Warning at cmake/TaichiCore.cmake:50 (message):
  OpenGL backend not supported on OS X.  Setting TI_WITH_OPENGL to OFF.
Call Stack (most recent call first):
  CMakeLists.txt:156 (include)


CMake Warning at cmake/TaichiCore.cmake:54 (message):
  C backend not supported on OS X.  Setting TI_WITH_CC to OFF.
Call Stack (most recent call first):
  CMakeLists.txt:156 (include)


-- Found ZLIB: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/libz.tbd (found version "1.2.11")
-- Could NOT find zstd (missing: zstd_LIBRARY zstd_INCLUDE_DIR)
-- Found LibXml2: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/lib/libxml2.tbd (found version "2.9.4")
-- Found LLVM 16.0.0git
-- Using LLVMConfig.cmake in: /Users/ingram14/OutSideLib/taichi-llvm-15-m1/lib/cmake/llvm
LLVM include dirs /Users/ingram14/OutSideLib/taichi-llvm-15-m1/include
LLVM library dirs /Users/ingram14/OutSideLib/taichi-llvm-15-m1/lib
-- Found PythonInterp: /Users/ingram14/opt/anaconda3/bin/python (found suitable version "3.8.8", minimum required is "3")
PYTHON_LIBRARIES: /Users/ingram14/opt/anaconda3/lib/libpython3.8.dylib
C++ Flags:  -ffunction-sections -fdata-sections -DTI_ISE_NONE -std=c++17 -fsized-deallocation -Wno-deprecated-declarations -Wall  -Werror  -Wno-ignored-attributes  -Wno-nullability-completeness  -Wno-unused-private-field  -Wno-unneeded-internal-declaration  -DTI_ARCH_x64 -march=nehalem -DTI_PASS_EXCEPTION_TO_PYTHON -DTI_INCLUDED -DTI_WITH_LLVM -DTI_WITH_METAL
Build type: Release
-- Compiling LLVM byte code file for arch x64
-- Configuring done
CMake Error at /Users/ingram14/OutSideLib/taichi-llvm-15-m1/lib/cmake/llvm/LLVMExports.cmake:64 (set_target_properties):
  The link interface of target "LLVMSupport" contains:

    zstd::libzstd_shared

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  /Users/ingram14/OutSideLib/taichi-llvm-15-m1/lib/cmake/llvm/LLVMConfig.cmake:230 (include)
  cmake/TaichiCore.cmake:162 (find_package)
  CMakeLists.txt:156 (include)


CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   SPIRV-Tools-shared

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    Python3_EXECUTABLE
    Python3_FIND_REGISTRY
    Python3_INCLUDE_DIR
    Python3_NumPy_INCLUDE_DIRS
    Python3_ROOT_DIR
    Python_EXECUTABLE
    Python_FIND_REGISTRY
    Python_INCLUDE_DIR
    Python_NumPy_INCLUDE_DIRS
    Python_ROOT_DIR
    SKBUILD


CMake Generate step failed.  Build files cannot be regenerated correctly.
Traceback (most recent call last):
  File "/Users/ingram14/.local/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 632, in setup
    env = cmkr.configure(
  File "/Users/ingram14/.local/lib/python3.8/site-packages/skbuild/cmaker.py", line 335, in configure
    raise SKBuildError(

An error occurred while configuring with CMake.
  Command:
    cmake /Users/ingram14/Git_Project/taichi -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/Users/ingram14/Git_Project/taichi/_skbuild/macosx-10.16-x86_64-3.8/cmake-install -DPYTHON_VERSION_STRING:STRING=3.8.8 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/Users/ingram14/.local/lib/python3.8/site-packages/skbuild/resources/cmake -DPYTHON_EXECUTABLE:PATH=/Users/ingram14/opt/anaconda3/bin/python -DPYTHON_INCLUDE_DIR:PATH=/Users/ingram14/opt/anaconda3/include/python3.8 -DPYTHON_LIBRARY:PATH=/Users/ingram14/opt/anaconda3/lib/libpython3.8.dylib -DPython_EXECUTABLE:PATH=/Users/ingram14/opt/anaconda3/bin/python -DPython_ROOT_DIR:PATH=/Users/ingram14/opt/anaconda3 -DPython_INCLUDE_DIR:PATH=/Users/ingram14/opt/anaconda3/include/python3.8 -DPython_FIND_REGISTRY:STRING=NEVER -DPython_NumPy_INCLUDE_DIRS:PATH=/Users/ingram14/.local/lib/python3.8/site-packages/numpy/core/include -DPython3_EXECUTABLE:PATH=/Users/ingram14/opt/anaconda3/bin/python -DPython3_ROOT_DIR:PATH=/Users/ingram14/opt/anaconda3 -DPython3_INCLUDE_DIR:PATH=/Users/ingram14/opt/anaconda3/include/python3.8 -DPython3_FIND_REGISTRY:STRING=NEVER -DPython3_NumPy_INCLUDE_DIRS:PATH=/Users/ingram14/.local/lib/python3.8/site-packages/numpy/core/include -DCMAKE_MAKE_PROGRAM:FILEPATH=/Users/ingram14/.local/lib/python3.8/site-packages/ninja/data/bin/ninja -DTI_VERSION_MAJOR=1 -DTI_VERSION_MINOR=4 -DTI_VERSION_PATCH=0 -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.16 -DCMAKE_OSX_ARCHITECTURES:STRING=x86_64
  Source directory:
    /Users/ingram14/Git_Project/taichi
  Working directory:
    /Users/ingram14/Git_Project/taichi/_skbuild/macosx-10.16-x86_64-3.8/cmake-build
Please see CMake's output for more information.

shell中显示的架构

uname -a
Darwin ZYEIRYANG-MB0 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64

你的build 失败报错主要是

  The link interface of target "LLVMSupport" contains:

    zstd::libzstd_shared

  but the target was not found.

所以试一下 brew install zstd?

关于Compiling LLVM byte code file for arch x64 里显示x64的话可以试试在terminal 里面打 arch 或者 arch -arm64 python setup.py develop --user

感谢您的回答
zstd我已经安装过了

> brew install zstd
Warning: zstd 1.5.2 is already installed and up-to-date.
To reinstall 1.5.2, run:
  brew reinstall zstd

shell里查看架构是arm64,而且我的iterm2没有开Rosette

> uname -a
Darwin ZYEIRYANG-MB0 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64

直接在命令前加arch -arm64会报错,如下所示:

> arch -arm64 python setup.py develop --user
arch: posix_spawnp: python: Bad CPU type in executable