Skip to content

Commit cc11523

Browse files
committed
Rework finding of libraries
1 parent 6701bf6 commit cc11523

11 files changed

+513
-429
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## [0.24.0] - UNRELEASED
22

3+
### Changed
4+
- Reworked finding of libraries (see `README.md` for details)
5+
36
### Added
47
- Added support for `clang` 7.0.x
58

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,23 @@ the `runtime` Cargo feature.
5151
These libraries can be either be installed as a part of Clang or downloaded
5252
[here](http://llvm.org/releases/download.html).
5353

54-
**Note:** This crate supports finding versioned instances of `libclang.so` (e.g.,
55-
`libclang.so.3.9` or `libclang-3.9.so`). In the case where there are multiple instances to choose
56-
from, this crate will prefer an unversioned instance first, then the version with the shortest and
57-
highest version. For example, the following instances of `libclang.so` are listed in descending
58-
order of preference:
59-
60-
1. `libclang.so`
61-
2. `libclang.so.4`
62-
3. `libclang.so.4.0`
63-
4. `libclang.so.3`
64-
5. `libclang.so.3.9`
65-
6654
**Note:** The downloads for LLVM and Clang 3.8 and later do not include the `libclang.a` static
6755
library. This means you cannot link to any of these versions of `libclang` statically unless you
6856
build it from source.
6957

58+
### Versioned Dependencies
59+
60+
This crate supports finding versioned instances of `libclang.so` (e.g.,`libclang-3.9.so`).
61+
In the case where there are multiple instances to choose from, this crate will prefer instances with
62+
higher versions. For example, the following instances of `libclang.so` are listed in descending
63+
order of preference:
64+
65+
1. `libclang-4.0.so`
66+
2. `libclang-4.so`
67+
3. `libclang-3.9.so`
68+
4. `libclang-3.so`
69+
5. `libclang.so`
70+
7071
## Environment Variables
7172

7273
The following environment variables, if set, are used by this crate to find the required libraries
@@ -83,11 +84,12 @@ and executables:
8384

8485
### Dynamic
8586

86-
First, the `libclang` shared library will be searched for in the directory provided by the
87-
`LIBCLANG_PATH` environment variable if it was set. If this fails, the directory returned by
88-
`llvm-config --libdir` will be searched. Failing that, the directories in the `LD_LIBRARY_PATH`
89-
environment variable will be searched. If none of these approaches is successful, a list of likely
90-
directories will be searched (e.g., `/usr/local/lib` on Linux).
87+
`libclang` shared libraries will be searched for in the following directories:
88+
89+
* the directory provided by the `LIBCLANG_PATH` environment variable
90+
* the directory returned by `llvm-config --libdir`
91+
* the directories provided by `LD_LIBRARY_PATH` environment variable
92+
* a list of likely directories for the target platform (e.g., `/usr/local/lib` on Linux)
9193

9294
On Linux, running an executable that has been dynamically linked to `libclang` may require you to
9395
add a path to `libclang.so` to the `LD_LIBRARY_PATH` environment variable. The same is true on OS
@@ -101,8 +103,8 @@ On Windows, running an executable that has been dynamically linked to `libclang`
101103

102104
The availability of `llvm-config` is not optional for static linking. Ensure that an instance of
103105
this executable can be found on your system's path or set the `LLVM_CONFIG_PATH` environment
104-
variable. The required LLVM and Clang static libraries will be searched for in the same way as the
105-
shared library is searched for, except the `LIBCLANG_STATIC_PATH` environment variable is used in
106+
variable. The required LLVM and Clang static libraries will be searched for in the same way as
107+
shared libraries are searched for, except the `LIBCLANG_STATIC_PATH` environment variable is used in
106108
place of the `LIBCLANG_PATH` environment variable.
107109

108110
### Runtime

0 commit comments

Comments
 (0)