Skip to content

Commit 90c4196

Browse files
committed
Update docs for cross compilation.
Document pkg-config cross compilation environment variables in library documentation. Fixes #156
1 parent dee70dd commit 90c4196

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

src/lib.rs

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
//! `Config` structure serves as a method of configuring how `pkg-config` is
77
//! invoked in a builder style.
88
//!
9+
//! After running `pkg-config` all appropriate Cargo metadata will be printed on
10+
//! stdout if the search was successful.
11+
//!
12+
//! # Environment variables
13+
//!
914
//! A number of environment variables are available to globally configure how
1015
//! this crate will invoke `pkg-config`:
1116
//!
1217
//! * `FOO_NO_PKG_CONFIG` - if set, this will disable running `pkg-config` when
1318
//! probing for the library named `foo`.
1419
//!
15-
//! * `PKG_CONFIG_ALLOW_CROSS` - The `pkg-config` command usually doesn't
16-
//! support cross-compilation, and this crate prevents it from selecting
17-
//! incompatible versions of libraries.
18-
//! Setting `PKG_CONFIG_ALLOW_CROSS=1` disables this protection, which is
19-
//! likely to cause linking errors, unless `pkg-config` has been configured
20-
//! to use appropriate sysroot and search paths for the target platform.
20+
//! ### Linking
2121
//!
2222
//! There are also a number of environment variables which can configure how a
2323
//! library is linked to (dynamically vs statically). These variables control
@@ -30,8 +30,30 @@
3030
//! * `PKG_CONFIG_ALL_STATIC` - pass `--static` for all libraries
3131
//! * `PKG_CONFIG_ALL_DYNAMIC` - do not pass `--static` for all libraries
3232
//!
33-
//! After running `pkg-config` all appropriate Cargo metadata will be printed on
34-
//! stdout if the search was successful.
33+
//! ### Cross-compilation
34+
//!
35+
//! In cross-compilation context, it is useful to manage separately
36+
//! `PKG_CONFIG_PATH` and a few other variables for the `host` and the `target`
37+
//! platform.
38+
//!
39+
//! The supported variables are: `PKG_CONFIG_PATH`, `PKG_CONFIG_LIBDIR`, and
40+
//! `PKG_CONFIG_SYSROOT_DIR`.
41+
//!
42+
//! Each of these variables can also be supplied with certain prefixes and
43+
//! suffixes, in the following prioritized order:
44+
//!
45+
//! 1. `<var>_<target>` - for example, `PKG_CONFIG_PATH_x86_64-unknown-linux-gnu`
46+
//! 2. `<var>_<target_with_underscores>` - for example,
47+
//! `PKG_CONFIG_PATH_x86_64_unknown_linux_gnu`
48+
//! 3. `<build-kind>_<var>` - for example, `HOST_PKG_CONFIG_PATH` or
49+
//! `TARGET_PKG_CONFIG_PATH`
50+
//! 4. `<var>` - a plain `PKG_CONFIG_PATH`
51+
//!
52+
//! This crate will allow `pkg-config` to be used in cross-compilation
53+
//! if `PKG_CONFIG_SYSROOT_DIR` or `PKG_CONFIG` is set. You can set
54+
//! `PKG_CONFIG_ALLOW_CROSS=1` to bypass the compatibility check, but please
55+
//! note that enabling use of `pkg-config` in cross-compilation without
56+
//! appropriate sysroot and search paths set is likely to break builds.
3557
//!
3658
//! # Example
3759
//!

0 commit comments

Comments
 (0)