<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60849>60849</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
libclang needs stable API to fetch the installed `ResourceDir` of clang
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
karolherbst
</td>
</tr>
</table>
<pre>
In Mesa we have the problem that we have to build the path to clang's resource directory at runtime. We need this so that libclang picks up `opencl-c-base.h` when compiling `OpenCL C` kernels.
There are currently a few solutions to do this correctly, but each has severe drawbacks:
1. use `clang -print-resource-dir`: That means calling a binary within a system library. We have _no_ control over the applications or user having a sane `PATH` so the `clang` invoked might not match the `libclang` loaded by mesa. This also makes development hard as if you use a custom LLVM, you also have to make sure to adjust your PATH variable, which is very counter intuitive and therefore bad.
2. use `clang::driver::Driver::GetResourcesPath("/usr/lib64/libclang.so", CLANG_RESOURCE_DIR) + "/include"`: This is just a super mess. Yes the first argument doesn't have to point to a valid file, but `CLANG_RESOURCE_DIR` can end up hard-coding clangs x.y.z version requiring distributions to rebuild mesa on every clang update. This is not something we want distributions to require to do.
What we really need is to have a rock-solid way of making sure libclang knows where to find it's resources on its own without users having to deal with this any of this nonsense.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsVU1z2zYQ_TXUZUccClIk66CDYsdpZpwm47rN9ORZAisREQiwWEAq--s7C0Z2PO1FBLkf2H379gmZ7dET7ap376t3dzPMqQtxd8IYXEex5TRrgxl3nzx8Jka4EHR4JkgdwRBD66iH1GF6NQRos3Vm8sDUyRft0B8rtWGIxCFHTWBsJJ1CHAETxOyT7amGbwSeSIItA4cptbNtSQCD1SeGPEC1bsJAXru5nrfIVHfVuoFLRx506AfrrD-K05eB_O0D3Ir1RNGT47pq7qpmP_0-dRQJMBLoHCP55EZAONAFOLicbPAs5ZswFaRDlKLdWKlbaHMCQt1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