<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/152976>152976</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
llvm-config --ldflags incorrect when llvm is installed inside build directory
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DavidSpickett
</td>
</tr>
</table>
<pre>
Originally reported in https://discourse.llvm.org/t/compiled-llm-config-executable-programs-do-not-correctly-point-to-the-installation-directory/87766.
Build llvm as follows:
```
$ mkdir build-llvm-config && cd llvm-config
$ make ../llvm-project/llvm -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/david.spickett/build-llvm-config/llvm.install -G Ninja -DLLVM_CCACHE_BUILD=ON && ninja && ninja install
```
Note that the install directory is inside the build directory.
This causes the `llvm-config` in the installed directory to report an incorrect library path:
```
~/build-llvm-config$ ./llvm.install/bin/llvm-config --ldflags
-L/home/david.spickett/build-llvm-config/Release/lib
```
The one in the build directory's `bin` points to the build's library dir as expected:
```
~/build-llvm-config$ ./bin/llvm-config --ldflags
-L/home/david.spickett/build-llvm-config/lib
```
I think llvm-config has autodetected as `InDevelopmentTree` true (which it is, sort of) and `DevelopmentTreeLayout` of `CMakeBuildModeStyle`. This causes it to put `build_mode` in the path which is read from `LLVM_BUILDMODE` which would be `Release`.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVcFu4zYQ_Rr6MpBA0ZIcH3TwWlEb1EkWG7doTwYlji2uKVIgqXh96bcXVOSs19nLAgV8kebN6M2bN2PunDxoxIJkn0hWzvjgW2OLkr9K8dLL5ojez2ojzsWzlQepuVJnsNgb61GA1NB63zsyXxFWEVYJ6RozWIexUq9dbOyBsMoTVjWm66VCESnVRY3Re3mI8Bs2g-e1wqi35mB55yJhIm181BhrsfHqHPVGah95E_kWI6md50pxL42OhAwQY8-EVXeLR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