Skip to content

Commit 30e8cbf

Browse files
committed
Correct mistake about supporting sub-makes and document CARGO_MAKEFLAGS
Sub-makes are currently not supported as the jobserver crate only sets CARGO_MAKEFLAGS which GNU Make doesn't understand. This might be reasonable as cargo overriding existing MAKEFLAGS variables would be weird, but also makes the statement in the reference false. It's helpful for build script authors who want to invoke make to know how to get make subprocesses work with parallel builds.
1 parent 898ccde commit 30e8cbf

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/doc/src/reference/environment-variables.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,15 @@ let out_dir = env::var("OUT_DIR").unwrap();
253253
current working directory of the build script when it
254254
starts.
255255
* `CARGO_MANIFEST_LINKS` — the manifest `links` value.
256+
* `CARGO_MAKEFLAGS` — Contains parameters needed for Cargo's [jobserver]
257+
implementation to parallelize subprocesses.
258+
Rustc or cargo invocations from build.rs can already
259+
read `CARGO_MAKEFLAGS`, but GNU Make requires the
260+
flags to be specified either directly as arguments,
261+
or through the `MAKEFLAGS` environment variable.
262+
Currently Cargo doesn't set the `MAKEFLAGS` variable,
263+
but it's free for build scripts invoking GNU Make
264+
to set it to the contents of `CARGO_MAKEFLAGS`.
256265
* `CARGO_FEATURE_<name>` — For each activated feature of the package being
257266
built, this environment variable will be present
258267
where `<name>` is the name of the feature uppercased
@@ -288,10 +297,9 @@ let out_dir = env::var("OUT_DIR").unwrap();
288297
that care should be taken when interpreting this environment
289298
variable. For historical purposes this is still provided but
290299
recent versions of Cargo, for example, do not need to run `make
291-
-j` as it'll automatically happen. Cargo implements its own
292-
[jobserver] and will allow build scripts to inherit this
293-
information, so programs compatible with GNU make jobservers will
294-
already have appropriately configured parallelism.
300+
-j`, and instead can set the `MAKEFLAGS` env var to the content
301+
of `CARGO_MAKEFLAGS` to activate the use of Cargo's GNU Make
302+
compatible [jobserver] for sub-make invocations.
295303
* `OPT_LEVEL`, `DEBUG` — values of the corresponding variables for the
296304
profile currently being built.
297305
* `PROFILE``release` for release builds, `debug` for other builds.

0 commit comments

Comments
 (0)