• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/workflows/H03-May-2022-4845

build/H03-May-2022-708467

src/H03-May-2022-2,7752,129

tests/H03-May-2022-6350

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197073 55

.gitattributesH A D29-Nov-197313 21

.gitignoreH A D29-Nov-197331 53

CHANGELOG.mdH A D29-Nov-197311.8 KiB462307

Cargo.tomlH A D01-Jan-19701.4 KiB5651

Cargo.toml.orig-cargoH A D29-Nov-19731 KiB5337

README.mdH A D29-Nov-19736 KiB8853

build.rsH A D29-Nov-19732.6 KiB8645

clippy.tomlH A D29-Nov-197332 21

README.md

1# clang-sys
2
3[![Crate](https://img.shields.io/crates/v/clang-sys.svg)](https://crates.io/crates/clang-sys)
4[![Documentation](https://docs.rs/clang-sys/badge.svg)](https://docs.rs/clang-sys)
5[![CI](https://img.shields.io/github/workflow/status/KyleMayes/clang-sys/CI/master)](https://github.com/KyleMayes/vulkanalia/actions?query=workflow%3ACI)
6![MSRV](https://img.shields.io/badge/MSRV-1.40.0-blue)
7
8Rust bindings for `libclang`.
9
10If you are interested in a somewhat idiomatic Rust wrapper for these bindings, see [`clang-rs`](https://github.com/KyleMayes/clang-rs).
11
12Released under the Apache License 2.0.
13
14## [Documentation](https://docs.rs/clang-sys)
15
16Note that the documentation on https://docs.rs for this crate assumes usage of the `runtime` Cargo feature as well as the Cargo feature for the latest supported version of `libclang` (e.g., `clang_13_0`), neither of which are enabled by default.
17
18Due to the usage of the `runtime` Cargo feature, this documentation will contain some additional types and functions to manage a dynamically loaded `libclang` instance at runtime.
19
20Due to the usage of the Cargo feature for the latest supported version of `libclang`, this documentation will contain constants and functions that are not available in the oldest supported version of `libclang` (3.5). All of these types and functions have a documentation comment which specifies the minimum `libclang` version required to use the item.
21
22## Supported Versions
23
24To target a version of `libclang`, enable a Cargo features such as one of the following:
25
26* `clang_3_5` - requires `libclang` 3.5 or later
27* `clang_3_6` - requires `libclang` 3.6 or later
28* etc...
29* `clang_12_0` - requires `libclang` 12.0 or later
30* `clang_13_0` - requires `libclang` 13.0 or later
31
32If you do not enable one of these features, the API provided by `libclang` 3.5 will be available by default.
33
34## Dependencies
35
36By 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.
37
38These libraries can be either be installed as a part of Clang or downloaded [here](http://llvm.org/releases/download.html).
39
40**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.
41
42### Versioned Dependencies
43
44This 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:
45
461. `libclang-4.0.so`
472. `libclang-4.so`
483. `libclang-3.9.so`
494. `libclang-3.so`
505. `libclang.so`
51
52**Note:** On BSD distributions, versioned instances of `libclang.so` matching the pattern `libclang.so.*` (e.g., `libclang.so.7.0`) are also included.
53
54**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.
55
56## Environment Variables
57
58The following environment variables, if set, are used by this crate to find the required libraries and executables:
59
60* `LLVM_CONFIG_PATH` **(compiletime)** - provides a full path to an `llvm-config` executable (including the executable itself [i.e., `/usr/local/bin/llvm-config-8.0`])
61* `LIBCLANG_PATH` **(compiletime)** - provides a path to a directory containing a `libclang` shared library or a full path to a specific `libclang` shared library
62* `LIBCLANG_STATIC_PATH` **(compiletime)** - provides a path to a directory containing LLVM and Clang static libraries
63* `CLANG_PATH` **(runtime)** - provides a path to a `clang` executable
64
65## Linking
66
67### Dynamic
68
69`libclang` shared libraries will be searched for in the following directories:
70
71* the directory provided by the `LIBCLANG_PATH` environment variable
72* the `bin` and `lib` directories in the directory provided by `llvm-config --libdir`
73* the directories provided by `LD_LIBRARY_PATH` environment variable
74* a list of likely directories for the target platform (e.g., `/usr/local/lib` on Linux)
75* **macOS only:** the toolchain directory in the directory provided by `xcode-select --print-path`
76
77On 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.
78
79On 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](https://msdn.microsoft.com/en-us/library/7d83bc18.aspx) for more information.
80
81### Static
82
83The 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.
84
85### Runtime
86
87The `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.
88