Skip to content

Conversation

@TApplencourt
Copy link
Contributor

Close #167421

This PR ad the environment variables LIBCLANG_LIBRARY_PATH and LIBCLANG_LIBRARY_FILE, which allow users to specify the directory path and the exact library file that should be used to locate libclang.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:as-a-library libclang and C++ API labels Dec 1, 2025
@llvmbot
Copy link
Member

llvmbot commented Dec 1, 2025

@llvm/pr-subscribers-clang

Author: Thomas Applencourt (TApplencourt)

Changes

Close #167421

This PR ad the environment variables LIBCLANG_LIBRARY_PATH and LIBCLANG_LIBRARY_FILE, which allow users to specify the directory path and the exact library file that should be used to locate libclang.


Full diff: https://github.com/llvm/llvm-project/pull/170201.diff

2 Files Affected:

  • (modified) clang/bindings/python/clang/cindex.py (+2-2)
  • (modified) clang/docs/ReleaseNotes.rst (+3)
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py index d352373e85c60..b728a8d8369ad 100644 --- a/clang/bindings/python/clang/cindex.py +++ b/clang/bindings/python/clang/cindex.py @@ -4383,8 +4383,8 @@ def register(item: LibFunc) -> None: class Config: - library_path = None - library_file: str | None = None + library_path: str | None = os.environ.get("LIBCLANG_LIBRARY_PATH") + library_file: str | None = os.environ.get("LIBCLANG_LIBRARY_FILE") compatibility_check = True loaded = False diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 9f8d781c93021..fb812a21f2f31 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -170,6 +170,9 @@ Clang Python Bindings Potentially Breaking Changes ElaboratedTypes. The value becomes unused, and all the existing users should expect the former underlying type to be reported instead. - Remove ``AccessSpecifier.NONE`` kind. No libclang interfaces ever returned this kind. +- Added the environment variables ``LIBCLANG_LIBRARY_PATH`` and ``LIBCLANG_LIBRARY_FILE``, + which allow users to specify the directory path and the exact library file that + should be used to locate libclang. What's New in Clang |release|? ============================== 
@TApplencourt
Copy link
Contributor Author

TApplencourt commented Dec 1, 2025

For more rational on the change see the issue #167421.

The PR is currently in the "minimal" stage. I can:

  • In the test remove the old support for CLANG_LIBRARY_PATH, and add in the release note that people should migrate to LIBCLANG_LIBRARY_PATH (will remove 3 lines per tests file so simplifying the code base)
  • Add tests. The simple one will be to do a negative testing (aka setting LIBCLANG_LIBRARY_PATH to /dev/null and verify that it crash). Other test seem harder (1/ verify that cindex if working 2/ find the libclang.so that he used, 3/ use this path to set LIBCLANG_LIBRARY_PATH, retry)

Curious what do people thinks (previous CLANG_LIBRARY_PATH didn't get any test, but it was used only the tests)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:as-a-library libclang and C++ API clang Clang issues not falling into any other category

2 participants