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

Doc-tests do not respect linker settings #14189

Closed
madonuko opened this issue Jul 4, 2024 · 1 comment
Closed

Doc-tests do not respect linker settings #14189

madonuko opened this issue Jul 4, 2024 · 1 comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.

Comments

@madonuko
Copy link

madonuko commented Jul 4, 2024

Problem

Doc-test in cargo test --doc and cargo test does not respect linker settings in ~/.cargo/config.toml.

Steps

  1. Paste the following file into ~/.cargo/config.toml:
[target.x86_64-unknown-linux-gnu]
#linker = "gcc"
rustflags = ["-C", "link-arg=-fuse-ld=mold"]
  1. Make any doc-test, whatever you like, then run cargo test --doc
  2. Notice during normal test compilation and cargo build, mold is used, but not for doc-tests
  3. uncomment linker = "gcc", try again (same behaviour)
  4. use linker = "clang", try again (same behaviour)

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.79.0 (ffa9cf99a 2024-06-03)
release: 1.79.0
commit-hash: ffa9cf99a594e59032757403d4c780b46dc2c43a
commit-date: 2024-06-03
host: x86_64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Ultramarine Linux 40.0.0 (lostumbrella) [64-bit]
@madonuko madonuko added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jul 4, 2024
@ehuss
Copy link
Contributor

ehuss commented Jul 4, 2024

Thanks for the report! I believe this is a duplicate of #12532 and #7040, so closing in favor of those.

You can use -Zdoctest-xcompile on nightly to honor the linker flag.
For rustflags, you need to also specify rustdocflags. Conceptually, doctests are going through rustdoc which has a different field for specifying its flags.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants