Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set cc for rustdoc #7529

Closed
nmattia opened this issue Oct 21, 2019 · 3 comments · Fixed by #8359
Closed

Set cc for rustdoc #7529

nmattia opened this issue Oct 21, 2019 · 3 comments · Fixed by #8359
Labels
A-doctests Area: rustdoc --test C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Z-doctest-xcompile Nightly: doctest-xcompile

Comments

@nmattia
Copy link
Contributor

nmattia commented Oct 21, 2019

Describe the problem you are trying to solve

I can't find a way to set the cc for rustdoc.

CARGO_TARGET_XXX_LINKER is not passed, and it appears that rustdoc reacts neither to CARGO_BUILD_RUSTFLAGS=-C linker=/path/to/cc nor to CC=/path/to/cc. One solution may be to set RUSTDOCFLAGS=-Z unstable-options --linker=/path/to/cc but this is only enabled on nightly, which I don't have.

Describe the solution you'd like

It would be great for cargo to forward CARGO_TARGET_XX_LINKER to rustdoc, where XXX is the CARGO_BUILD_TARGET.

@nmattia nmattia added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Oct 21, 2019
@ehuss
Copy link
Contributor

ehuss commented Oct 21, 2019

1.39 will now allow -C linker=cc (see rust-lang/rust#63834). Cargo doesn't issue that flag, though, so you'll still need to use RUSTDOCFLAGS.

What is your use case for passing a custom linker? Doctests don't support cross-compiling without the unstable -Zdoctest-xcompile, so I'm curious why the default host linker is not working for you.

With -Zdoctest-xcompile, it seems like a reasonable idea to pass that flag, but I'm not too familiar with the use cases for using custom linkers with doc tests.

@ehuss ehuss added A-doctests Area: rustdoc --test Z-doctest-xcompile Nightly: doctest-xcompile labels Oct 21, 2019
@nmattia
Copy link
Contributor Author

nmattia commented Oct 22, 2019

Thanks for the feedback! Looking forward to 1.39.

What is your use case for passing a custom linker?

I work on systems that unfortunately do not have a cc in the path or in any standard location.

@benesch
Copy link
Contributor

benesch commented May 6, 2020

Also, sometimes linkers have bugs. For example binutils 2.30 (shipped with Ubuntu 18.04 LTS) mishandles some compressed debug info sections: https://sourceware.org/bugzilla/show_bug.cgi?id=23919.

We work around this at Materialize by setting CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER appropriately, to a toolchain that does not exhibit the bug, but the fact that this setting does not apply to rustdoc links is very surprising! Here's a build failure that took me well over an hour to track down: https://buildkite.com/materialize/tests/builds/7669#e8398bc6-91d4-4130-b417-be4233dfcfd8.

So even when you're not cross compiling, I think it's important that CARGO_TARGET_<HOST TRIPLE>_LINKER apply to rustdoc too.

benesch added a commit to frankmcsherry/materialize that referenced this issue May 6, 2020
The system linker in the builder image doesn't handle compressed debug
sections properly, and rustdoc ignores the standard Cargo linker
environment variable, so tell rustdoc to use the correct linker via the
RUSTDOCFLAGS environment variable.

See: rust-lang/cargo#7529 (comment)
@bors bors closed this as completed in 089cbb8 Jun 15, 2020
benesch added a commit to benesch/materialize that referenced this issue Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doctests Area: rustdoc --test C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Z-doctest-xcompile Nightly: doctest-xcompile
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants