-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
C-bugCategory: bugCategory: bug
Description
Problem
We can specify RUSTFLAGS
for a workspace in .cargo/config
, like so:
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-L/opt/CANARY/lib",
]
Cargo dutifully passes those flags on to the compiler when you invoke cargo build
or cargo run
for that target. It also seems to mostly pass them on when you run cargo test
, with one exception: when building the doctest binary. My expectation is that Cargo should set these compiler flags when building the doctest binary.
Steps
- Clone this repository: https://github.com/tomjakubowski/doctest-rustflags. The repo is a Cargo library project with a doctest and a
.cargo/config
file specifying someRUSTFLAGS
. - Run
cargo build --verbose
and note the presence of/opt/CANARY/lib
in the compiler invocation. - Run
cargo test --verbose
and note the absence of/opt/CANARY/lib
when building the rustdoc binary:
Compiling doctest-rustflags v0.1.0 (/Users/tom/code/doctest-rustflags)
Running `rustc --edition=2018 --crate-name doctest_rustflags src/lib.rs --color always --crate-type lib --emit=dep-info,link -Cdebuginfo=2 -C metadata=533b040c3210b269 -C extra-filename=-533b040c3210b269 --out-dir /Users/tom/code/doctest-rustflags/target/debug/deps -C incremental=/Users/tom/code/doctest-rustflags/target/debug/incremental -L dependency=/Users/tom/code/doctest-rustflags/target/debug/deps -C link-arg=-L/opt/CANARY/lib`
Running `rustc --edition=2018 --crate-name doctest_rustflags src/lib.rs --color always --emit=dep-info,link -C debuginfo=2 --test -C metadata=f7f76e9875dad886 -C extra-filename=-f7f76e9875dad886 --out-dir /Users/tom/code/doctest-rustflags/target/debug/deps -C incremental=/Users/tom/code/doctest-rustflags/target/debug/incremental -L dependency=/Users/tom/code/doctest-rustflags/target/debug/deps -C link-arg=-L/opt/CANARY/lib`
[truncated]
Doc-tests doctest-rustflags
Running `rustdoc --edition=2018 --test /Users/tom/code/doctest-rustflags/src/lib.rs --crate-name doctest_rustflags -L dependency=/Users/tom/code/doctest-rustflags/target/debug/deps -L dependency=/Users/tom/code/doctest-rustflags/target/debug/deps --extern doctest_rustflags=/Users/tom/code/doctest-rustflags/target/debug/deps/libdoctest_rustflags-533b040c3210b269.rlib`
Possible Solution(s)
Beats me, though I would love to use this to get back to contributing something to rustdoc :-)
Notes
Output of cargo version
:
cargo 1.32.0 (8610973aa 2019-01-02)
Metadata
Metadata
Assignees
Labels
C-bugCategory: bugCategory: bug
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
tomjakubowski commentedon Feb 11, 2019
I noticed that setting
RUSTFLAGS
manually didn't help either, and then found #4737. So I closed the issue thinking this one was a duplicate.However, it seems that Rustdoc now does take
-C
flags, at least: rust-lang/rust#49956So maybe you'd like to reconsider passing
RUSTFLAGS
on torustdoc
. I've re-opened so that you may close :-)ehuss commentedon Feb 11, 2019
rustdoc
does not support testing with--target
(see #6460 with some upstream issues), so it doesn't recognize[target]
tables.Also, rustdoc uses a separate
rustdocflags
(orRUSTDOCFLAGS
env var), though it is not supported in[target]
.tomjakubowski commentedon Feb 11, 2019
Thanks! 🎉
Try RUSTDOCFLAGS env var as recommended in rust-lang/cargo#6650