<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57863>57863</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Build of runtimes does not respect cmake variables specified at the top level
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
debohman
</td>
</tr>
</table>
<pre>
While building and getting ready to install llvm-15.0.1 on my system, I noticed that some of the runtime dylibs are being built to runtime link against the system libraries instead of the libraries in the install prefix location.
At top level, I have:
```
CMAKE_INSTALL_PREFIX:PATH=/usr/local
CMAKE_CXX_FLAGS:STRING=-I/usr/local/include
CMAKE_C_FLAGS:STRING=-I/usr/local/include
CMAKE_EXE_LINKER_FLAGS:STRING=-L/usr/local/lib
CMAKE_MODULE_LINKER_FLAGS:STRING=-L/usr/local/lib
CMAKE_SHARED_LINKER_FLAGS:STRING=-L/usr/local/lib
CMAKE_STATIC_LINKER_FLAGS:STRING=-L/usr/local/lib
```
This results in some of the installed libraries being runtime linked as so:
```
/tmp/dst.llvm/usr/local/lib/clang/15.0.1/lib/darwin/libclang_rt.asan_osx_dynamic.dylib:
@rpath/libclang_rt.asan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 307.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
/tmp/dst.llvm/usr/local/lib/clang/15.0.1/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib:
@rpath/libclang_rt.lsan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 307.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
/tmp/dst.llvm/usr/local/lib/clang/15.0.1/lib/darwin/libclang_rt.stats_osx_dynamic.dylib:
@rpath/libclang_rt.stats_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 307.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
/tmp/dst.llvm/usr/local/lib/clang/15.0.1/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib:
@rpath/libclang_rt.tsan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 307.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/tmp/dst.llvm/usr/local/lib/clang/15.0.1/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib:
@rpath/libclang_rt.ubsan_minimal_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 307.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
/tmp/dst.llvm/usr/local/lib/clang/15.0.1/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib:
@rpath/libclang_rt.ubsan_osx_dynamic.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 307.3.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
```
I believe that this is not a new bug in llvm-15, it started happening when the runtime libraries were split off to be built with the generated toolchain.
I worked around it by editing ```runtimes/runtimes-bins/CMakeCache.txt``` to force:
```
CMAKE_CXX_FLAGS:STRING=-I/usr/local/include
CMAKE_C_FLAGS:STRING=-I/usr/local/include
CMAKE_EXE_LINKER_FLAGS:STRING=-L/usr/local/lib
CMAKE_MODULE_LINKER_FLAGS:STRING=-L/usr/local/lib
CMAKE_SHARED_LINKER_FLAGS:STRING=-L/usr/local/lib
CMAKE_STATIC_LINKER_FLAGS:STRING=-L/usr/local/lib
```
Then, after doing this the build failed, because ```runtimes/runtimes-bins/CMakeCache.txt``` contains the following:
```
DARWIN_osx_ARCHS:STRING=i386;x86_64;x86_64h
```
This results in the runtime builtins and the runtime runtimes being built 3-way FAT, which I did not request, and the build fails because the ```i386``` architecture is not present in the library being built against.
This is building ```llvm-15.0.1``` on ```macOS 10.12.6``` with ```cmake 3.24.1```.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWFtz2joQ_jXmRROPLzGXBx4cLg3TNO0AZ5o3RrYFVitLHEkO4d-flQzGpLRJyXROJ8OMx1iX3e-T_GnNbiKybf9rThlBSUlZRvkKYZ6hFdHaPEuCsy3SAlGuNGYMMfZYXPmR67k-EhwVW6S2SpPCCQZogrjQNCUZ0jnWSImCILGEBkGy5JpCM9symiiEJeARA2BQtQHYz2CUf0d4hQ2gNa38Q38isaREWSpAa--6OWA79lTXkizpE2IixZoK7jre0PHi6h4bzDVi5JGwinqOH4kTxs1JTtvbXbY5-BR_HC0m97N5fHe3-DIdjScPYPElnt864dAJxqWScDd4rOmmshs8PCzGd_GHGZjM5tPJ_Qcwupo8MwvGlKeszMiR6e8bNs1HD6PF3eT-42h6ws_dD35gP5vWnz4P_7l7i4PZbTwdDd_iYB7PJ4OzHDx7g9V9nlMFwlYl01YzTZ3utAMSPsiqEmpTnzCMFdj9Wi9ARBdruGdKu-bcnOQZjFOG-Qp-q1NVd2dYbiivmnbKQmoXK8wXQj0tsi3HBU1de6AaPHrOtSfXWOevMkRO0E1FAfNpQhnVW_RIp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