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

    <tr>
        <th>Summary</th>
        <td>
            BUG: Build with LLVM_BUILD_LLVM_C_DYLIB=ON fails on osx
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          h-vetinari
      </td>
    </tr>
</table>

<pre>
    Based on 
https://github.com/llvm/llvm-project/blob/1c822e1e8278ebefdb7701249bdfe51f1ed03d7d/llvm/tools/llvm-shlib/CMakeLists.txt#L82-L85
it looks like `LLVM_BUILD_LLVM_C_DYLIB=ON` should definitely be supported on osx, however, actually setting it results in a build failure Iwhich might be a build ordering issue, because it cannot find `libLLVM.dylib`, which definitely gets built).


The stack trace below is from 17.0.0.rc2, but it has been the same for the 16.x series, and I presume it's the same for `main`. Xref also #43487.


```
[...]
[3369/3461] Linking CXX executable bin/llvm-rust-demangle-fuzzer
[3370/3461] Generating Export list for LLVM...
error: nm: can't open file: $SRC_DIR/build/./lib/libLLVM.dylib (No such file or directory)
[3371/3461] Creating export file for LLVM-C
[3372/3461] Building CXX object tools/llvm-shlib/CMakeFiles/LLVM-C.dir/libllvm.cpp.o
[3373/3461] Linking CXX shared library lib/libLLVM-C.17.dylib
FAILED: lib/libLLVM-C.17.dylib 
: && $BUILD_PREFIX/bin/x86_64-apple-darwin13.4.0-clang++ -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/llvm-package-17.0.0.rc2 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -isysroot /Applications/Xcode_13.2.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.9 -dynamiclib -Wl,-headerpad_max_install_names -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib   -Wl,-dead_strip -Wl,-exported_symbols_list,"$SRC_DIR/build/tools/llvm-shlib/LLVM-C.exports" -compatibility_version 1 -current_version 17.0.0 -Wl,-reexport_library $SRC_DIR/build/./lib/libLLVM.dylib  -compatibility_version 17.0.0 -current_version 17.0.0 -o lib/libLLVM-C.17.dylib -install_name @rpath/libLLVM-C.17.dylib tools/llvm-shlib/CMakeFiles/LLVM-C.dir/libllvm.cpp.o -Wl,-rpath,@loader_path/../lib  lib/libLLVM-17.dylib && :
clang-15: error: no such file or directory: '$SRC_DIR/build/./lib/libLLVM.dylib'
[3374/3461] Building CXX object tools/llvm-sim/CMakeFiles/llvm-sim.dir/llvm-sim.cpp.o
ninja: build stopped: subcommand failed.
```

<details>
<summary>CMake invocation</summary>

```
cmake -GNinja \
 -DCMAKE_INSTALL_PREFIX="${PREFIX}" \
      -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_LIBRARY_PATH="${PREFIX}" \
 -DLLVM_ENABLE_BACKTRACES=ON \
      -DLLVM_ENABLE_DUMP=ON \
 -DLLVM_ENABLE_LIBEDIT=OFF \
      -DLLVM_ENABLE_LIBXML2=FORCE_ON \
 -DLLVM_ENABLE_RTTI=ON \
      -DLLVM_ENABLE_TERMINFO=OFF \
 -DLLVM_ENABLE_ZLIB=FORCE_ON \
      -DLLVM_ENABLE_ZSTD=FORCE_ON \
 -DLLVM_DEFAULT_TARGET_TRIPLE=${HOST_TRIPLE} \
 -DLLVM_HOST_TRIPLE=${HOST_TRIPLE} \
      -DLLVM_INCLUDE_BENCHMARKS=OFF \
      -DLLVM_INCLUDE_DOCS=OFF \
      -DLLVM_INCLUDE_EXAMPLES=OFF \
      -DLLVM_INCLUDE_GO_TESTS=OFF \
      -DLLVM_INCLUDE_TESTS=ON \
      -DLLVM_INCLUDE_UTILS=ON \
      -DLLVM_INSTALL_UTILS=ON \
      -DLLVM_UTILS_INSTALL_DIR=libexec/llvm \
 -DLLVM_BUILD_LLVM_DYLIB=yes \
      -DLLVM_LINK_LLVM_DYLIB=yes \
 -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly \
 -DLLVM_BUILD_LLVM_C_DYLIB=ON \
      ../llvm
```

</details>
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykWF9z26oS_zTkhUEjI_99yINtyT2eKn_GcW5yzosGibXFCQJdQEncT38HSXbcNknbuZ2OYsHuj9_uwu4KZq3YK4BLNFqgUXzBGldqc1mSZ3BCMSMucs0PlwtmgWOtMApjFM5L52qLojmiK0RXe-HKJg8KXSG6kvL5-IfURv8LhUN0lUudI7oaFFNKYQBTOplCDjueTybhgA5nOd_BaLAbAA8jPuFvOE5raY94tpTCwyyv2BOkwjobuFeHaJROKUmno46ccFhq_WSxFE-A0ThM0_9cZYv7dRpn7c9lFv-drhcoim-u0TjEttSN5JjDTijhQB5wDtg2da2N66zW9hXRJS71CzyD8T9Z4Rom5QFbcE6oPRYOG7CNdBYLhRnOGyE53jEhGwN4_VKKosSV2JfOox_nteFgWnVrG_DAORSsseDxCqaUdngnFPdmSJF7-gE_eC-MQy_dwZ4x34OzLbZDdBZ0Djl_bkvA1rHiCTvDCsA5SP2ChcU7oys8mARhEAamoC2VxnkaJbM4B1DYeV1WAd5p074MxsErtmAE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