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

    <tr>
        <th>Summary</th>
        <td>
            17.0.4: `clang` python module tries to find libclang in wrong location
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    First of all `clang` python module tries to find not versioned libclang but `libclang.so` so I've added below quick patch
```patch
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -3937,7 +3937,7 @@
 elif name == "Windows":
             file = "libclang.dll"
 else:
-            file = "libclang.so"
+            file = "libclang.so.17.0"

         if Config.library_path:
 file = Config.library_path + "/" + file
```
Unversioned library name is part of the clang devel resources.

Than on use installed `clang` module it tries to find `libclang.so.17.0` in /usr/local/lib.
Below is from building libdicom documentation"
```console
+ /usr/bin/meson compile -C x86_64-redhat-linux-gnu -j 48 --verbose html
ninja: Entering directory `/home/tkloczko/rpmbuild/BUILD/libdicom-1.0.5/x86_64-redhat-linux-gnu'
[1/1] /usr/bin/sphinx-build ../doc/source html
FAILED: html
/usr/bin/sphinx-build ../doc/source html
Running Sphinx v7.1.2
making output directory... done
WARNING: html_static_path entry '_static' does not exist
building [mo]: targets for 0 po files that are out of date
writing output...
building [html]: targets for 7 source files that are out of date
updating environment: [new config] 7 added, 0 changed, 0 removed
reading sources... [ 14%] api
Exception occurred:
  File "/usr/lib/python3.8/site-packages/clang/cindex.py", line 3956, in get_cindex_library
    raise LibclangError(msg)
clang.cindex.LibclangError: /usr/local/lib/libclang.so.17.0: cannot open shared object file: No such file or directory. To provide a path to libclang use Config.set_library_path() or Config
The full traceback has been saved in /tmp/sphinx-err-s7hvhnue.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
ninja: build stopped: subcommand failed.
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /usr/bin/ninja -C /home/tkloczko/rpmbuild/BUILD/libdicom-1.0.5/x86_64-redhat-linux-gnu -j 48 -v html
```
At the same time in system is installed
```console
[tkloczko@pers-jacek SPECS]$ ls -1 /usr/lib64/libclang*
/usr/lib64/libclang-cpp.so.17.0
/usr/lib64/libclang.so.17.0
/usr/lib64/libclang.so.17.0.4
```

It would be good to find better way to update LLVM major version number in libclang library name than what is in above JFDI patch
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysV11v67gR_TX0y0CCTPnzwQ92EhUp0tvF3t3uY0BRY4kxRaokZSf99cVQ8lf29t72ooERm9RwOHPmzCElvFe1Qdyw-Y7NHyeiD411m4O28l94mJS2-tgUyvkAdg9Ca2CLTGpharbIoPsIjTXQ2qrXCMEp9BAs7JWpwNgAR3ReWYMVaFXGVVD2gVycx6m35MhbeGZ8eUQQVYUVlKjtCf7ZK3mATgTZsOyRZVu2yIbPzVySJCAYL4ageFEqUylTe8aLIbybZ1KZCt_T7mN0x3fDB8qfdDDL2CyDJF_nS8YflsD47vo7PhwMAbXagxEtAssfWf4IjPM_lKnsyTPOWb4d7W7_9kpHc7K94FVpTQvOXj1e1iY_XOvtZSkl_WPzdLpMs-ua-xDVHh6s2as61ap0wn28diI011QuPr9hRUDRXowXjPM4IvNPVR6Gv5s7GpGPAUnloRMuEjM0CAO_KjyiBofe9k6iT29D_60RBqyB3iMo44PQGqs7Qo9MVuETme8ZO8CyyEAZYLzovWO80FYKTd-qHDfdRRIrD3tnWyh7pYlXlEOlpG2hsrJv0QQRFJGMf8peWuPtBZOI17hVqYiTLXprQNq2I6CTB3hfLV4Xs8Rh1YiQaGX696Q2PSRvMFtBkhzRldYjNKHVg1ejzJtg-RaeTEBHwVXKoQzWfVDKjBeNbZHxIkQ9OFjGC9e1MRXGi93vzy-PQ8ox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