faf6cad78c
Differential Revision: https://phabricator.services.mozilla.com/D45719 --HG-- rename : third_party/rust/regex-0.2.2/src/freqs.rs => third_party/rust/aho-corasick/src/byte_frequencies.rs rename : third_party/rust/crc/Cargo.toml => third_party/rust/blake2b_simd/Cargo.toml rename : third_party/rust/miniz_oxide_c_api/LICENSE => third_party/rust/miniz_oxide/LICENSE rename : third_party/rust/redox_users/tests/group => third_party/rust/redox_users/tests/etc/group rename : third_party/rust/redox_users/tests/passwd => third_party/rust/redox_users/tests/etc/passwd rename : third_party/rust/redox_users/tests/shadow => third_party/rust/redox_users/tests/etc/shadow rename : third_party/rust/utf8-ranges/src/lib.rs => third_party/rust/regex-syntax/src/utf8.rs rename : third_party/rust/crossbeam-channel/LICENSE-APACHE => third_party/rust/rust-argon2/LICENSE-APACHE rename : third_party/rust/memchr-1.0.2/COPYING => third_party/rust/winapi-util/COPYING rename : third_party/rust/ucd-util/Cargo.toml => third_party/rust/winapi-util/Cargo.toml rename : third_party/rust/memchr-1.0.2/LICENSE-MIT => third_party/rust/winapi-util/LICENSE-MIT rename : third_party/rust/memchr-1.0.2/UNLICENSE => third_party/rust/winapi-util/UNLICENSE extra : moz-landing-system : lando |
||
---|---|---|
.. | ||
build | ||
ci | ||
src | ||
tests | ||
.cargo-checksum.json | ||
appveyor.yml | ||
build.rs | ||
Cargo.toml | ||
CHANGELOG.md | ||
clippy.toml | ||
LICENSE.txt | ||
README.md |
clang-sys
Rust bindings for libclang
.
If you are interested in a Rust wrapper for these bindings, see clang-rs.
Supported on the stable, beta, and nightly Rust channels.
Released under the Apache License 2.0.
Supported Versions
To target a version of libclang
, enable one of the following Cargo features:
clang_3_5
- requireslibclang
3.5 or later (Documentation)clang_3_6
- requireslibclang
3.6 or later (Documentation)clang_3_7
- requireslibclang
3.7 or later (Documentation)clang_3_8
- requireslibclang
3.8 or later (Documentation)clang_3_9
- requireslibclang
3.9 or later (Documentation)clang_4_0
- requireslibclang
4.0 or later (Documentation)clang_5_0
- requireslibclang
5.0 or later (Documentation)clang_6_0
- requireslibclang
6.0 or later (Documentation)clang_7_0
- requireslibclang
7.0 or later (Documentation)clang_8_0
- requireslibclang
8.0 or later (Documentation)
If you do not enable one of these features, the API provided by libclang
3.5 will be available by
default.
Dependencies
By default, this crate will attempt to link to libclang
dynamically. In this case, this crate
depends on the libclang
shared library (libclang.so
on Linux, libclang.dylib
on macOS,
libclang.dll
on Windows). If you want to link to libclang
statically instead, enable the
static
Cargo feature. In this case, this crate depends on the LLVM and Clang static libraries. If
you don't want to link to libclang
at compiletime but instead want to load it at runtime, enable
the runtime
Cargo feature.
These libraries can be either be installed as a part of Clang or downloaded here.
Note: The downloads for LLVM and Clang 3.8 and later do not include the libclang.a
static
library. This means you cannot link to any of these versions of libclang
statically unless you
build it from source.
Versioned Dependencies
This crate supports finding versioned instances of libclang.so
(e.g.,libclang-3.9.so
).
In the case where there are multiple instances to choose from, this crate will prefer instances with
higher versions. For example, the following instances of libclang.so
are listed in descending
order of preference:
libclang-4.0.so
libclang-4.so
libclang-3.9.so
libclang-3.so
libclang.so
Note: On BSD distributions, versioned instances of libclang.so
matching the pattern
libclang.so.*
(e.g., libclang.so.7.0
) are also included.
Note: On Linux distributions when the runtime
features is enabled, versioned instances of
libclang.so
matching the pattern libclang.so.*
(e.g., libclang.so.1
) are also included.
Environment Variables
The following environment variables, if set, are used by this crate to find the required libraries and executables:
LLVM_CONFIG_PATH
(compiletime) - provides a path to anllvm-config
executableLIBCLANG_PATH
(compiletime) - provides a path to a directory containing alibclang
shared library or a path to a specificlibclang
shared libraryLIBCLANG_STATIC_PATH
(compiletime) - provides a path to a directory containing LLVM and Clang static librariesCLANG_PATH
(runtime) - provides a path to aclang
executable
Linking
Dynamic
libclang
shared libraries will be searched for in the following directories:
- the directory provided by the
LIBCLANG_PATH
environment variable - the
bin
andlib
directories in the directory provided byllvm-config --libdir
- the directories provided by
LD_LIBRARY_PATH
environment variable - a list of likely directories for the target platform (e.g.,
/usr/local/lib
on Linux) - macOS only: the toolchain directory in the directory provided by
xcode-select --print-path
On Linux, running an executable that has been dynamically linked to libclang
may require you to
add a path to libclang.so
to the LD_LIBRARY_PATH
environment variable. The same is true on OS
X, except the DYLD_LIBRARY_PATH
environment variable is used instead.
On Windows, running an executable that has been dynamically linked to libclang
requires that
libclang.dll
can be found by the executable at runtime. See
here for more information.
Static
The availability of llvm-config
is not optional for static linking. Ensure that an instance of
this executable can be found on your system's path or set the LLVM_CONFIG_PATH
environment
variable. The required LLVM and Clang static libraries will be searched for in the same way as
shared libraries are searched for, except the LIBCLANG_STATIC_PATH
environment variable is used in
place of the LIBCLANG_PATH
environment variable.
Runtime
The clang_sys::load
function is used to load a libclang
shared library for use in the thread in
which it is called. The clang_sys::unload
function will unload the libclang
shared library.
clang_sys::load
searches for a libclang
shared library in the same way one is searched for when
linking to libclang
dynamically at compiletime.