<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/127172>127172</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            link libunwind.dylib failed on macOs M1
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          xbcnn
      </td>
    </tr>
</table>

<pre>
    I am trying build llvm locally on macOs M1.

The configuration:
```
cmake -B build -G Ninja -S llvm \
 -DLLVM_ENABLE_PROJECTS="clang" \
 -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
 -DLIBCXX_INCLUDE_TESTS=ON    \
      -DCMAKE_BUILD_TYPE=Release

ninja -C build check-cxx
```

Failed messages:
```
[152/156] Performing configure step for 'google-benchmark'
FAILED: libcxx/test/benchmarks/google-benchmark/src/google-benchmark-stamp/google-benchmark-configure /Users/test/src/llvm-project/build2/runtimes/runtimes-bins/libcxx/test/benchmarks/google-benchmark/src/google-benchmark-stamp/google-benchmark-configure
cd /Users/test/src/llvm-project/build2/runtimes/runtimes-bins/libcxx/test/benchmarks/google-benchmark/src/google-benchmark-build && /opt/homebrew/bin/cmake -GNinja -C/Users/test/src/llvm-project/build2/runtimes/runtimes-bins/libcxx/test/benchmarks/google-benchmark/tmp/google-benchmark-cache-Release.cmake -S /Users/test/src/llvm-project/runtimes/../third-party/benchmark -B /Users/test/src/llvm-project/build2/runtimes/runtimes-bins/libcxx/test/benchmarks/google-benchmark/src/google-benchmark-build && /opt/homebrew/bin/cmake -E touch /Users/test/src/llvm-project/build2/runtimes/runtimes-bins/libcxx/test/benchmarks/google-benchmark/src/google-benchmark-stamp/google-benchmark-configure
loading initial cache file /Users/test/src/llvm-project/build2/runtimes/runtimes-bins/libcxx/test/benchmarks/google-benchmark/tmp/google-benchmark-cache-Release.cmake
-- The CXX compiler identification is Clang 21.0.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /Users/test/src/llvm-project/build2/bin/clang++
-- Check for working CXX compiler: /Users/test/src/llvm-project/build2/bin/clang++ - broken
CMake Error at /opt/homebrew/share/cmake/Modules/CMakeTestCXXCompiler.cmake:73 (message):
 The C++ compiler

 "/Users/test/src/llvm-project/build2/bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

 Change Dir: '/Users/test/src/llvm-project/build2/runtimes/runtimes-bins/libcxx/test/benchmarks/google-benchmark/src/google-benchmark-build/CMakeFiles/CMakeScratch/TryCompile-tAEwDV'

 Run Build Command(s): /usr/local/bin/ninja -v cmTC_684a5
    [1/2] /Users/test/src/llvm-project/build2/bin/clang++ -Wno-unused-command-line-argument -nostdinc++ -isystem /Users/test/src/llvm-project/build2/include/c++/v1 -L/Users/test/src/llvm-project/build2/./lib -Wl,-rpath,/Users/test/src/llvm-project/build2/./lib  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -MD -MT CMakeFiles/cmTC_684a5.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_684a5.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_684a5.dir/testCXXCompiler.cxx.o -c /Users/test/src/llvm-project/build2/runtimes/runtimes-bins/libcxx/test/benchmarks/google-benchmark/src/google-benchmark-build/CMakeFiles/CMakeScratch/TryCompile-tAEwDV/testCXXCompiler.cxx
 [2/2] : && /Users/test/src/llvm-project/build2/bin/clang++ -Wno-unused-command-line-argument -nostdinc++ -isystem /Users/test/src/llvm-project/build2/include/c++/v1 -L/Users/test/src/llvm-project/build2/./lib -Wl,-rpath,/Users/test/src/llvm-project/build2/./lib  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_684a5.dir/testCXXCompiler.cxx.o -o cmTC_684a5   && :
 FAILED: cmTC_684a5
    : && /Users/test/src/llvm-project/build2/bin/clang++ -Wno-unused-command-line-argument -nostdinc++ -isystem /Users/test/src/llvm-project/build2/include/c++/v1 -L/Users/test/src/llvm-project/build2/./lib -Wl,-rpath,/Users/test/src/llvm-project/build2/./lib  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_684a5.dir/testCXXCompiler.cxx.o -o cmTC_684a5   && :
    ld: warning: ignoring file /Users/test/src/llvm-project/build2/./lib/libc++.dylib, building for macOS-x86_64 but attempting to link with file built for macOS-arm64
    ld: in '/Users/test/src/llvm-project/build2/./lib/libunwind.dylib', building for macOS-x86_64 but attempting to link with file built for macOS-arm64
 clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.





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


-- Configuring incomplete, errors occurred!
ninja: build stopped: subcommand failed.
```

So why it building for macOS-x86_64?  Did I configure something wrong and how to fix it?

Thanks.

</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWF-P4jgS_zTmpZQoMf8feIAAK26hZzQwu31PyHEK4sWxke008O1PTkI37PRK0313O73SjJAmndhV5ar6Vf3KzFqxV4gj0p2Q7rTFSpdrMzqnXKlWqrPLaAGsAGcuQu0hLYXMQMqnAqTmTMoLaAUF458srOKQRGMSjTc5AtdqJ_alYU5oRdr-NelFzS8a84IdEIJJIzD4BR6E-oNBsK6Fk25CojEE0-Xyt9V29jCeLGfbz18-_WuWbNakPSWUcsnUnlD6-tovXx82i9WsWStFys9n0p7UDywV9XOpTkJl90IWk-Txcbt4SJZfp7PtZrauFH56AIDrqupfME1W419n28nXxXK63fz784y0p19QIrNY-0HVR0qaQ_Ic-SHwdtz7gkTjORMSMyjQWrZH-62_SHcSdymh87jbI90pfEaz06bwIbl6GsE6PMJOGyC0v9d6LzFIU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