Skip to content

rustdoc fails to account for -Clinker and -Clink-arg when building tests #65171

Closed
@nagisa

Description

@nagisa

I’m working on a fairly peculiar system at the moment where the default linker (cc) is not able of linking properly, and thus I set the following environment variables

export RUSTFLAGS="-Clinker=clang -Clink-arg=--target=$HOST_TARGET"
export RUSTDOCFLAGS="-Clinker=clang -Clink-arg=--target=$HOST_TARGET"
export CC="clang"
export CFLAGS="--target=$HOST_TARGET"

which made cargo build pass. However cargo test still fails because doctests are still being compiled with the default linker. Running cargo test --verbose reveals that the flags are being passed through to rustdoc:

rustdoc ... -Clinker=clang -Clink-arg=--target=$HOST_TARGET

However, rustdoc still uses a default linker:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" ...

(Tested with rustdoc 1.38.0 (625451e37 2019-09-23))

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-doctestsArea: Documentation tests, run by rustdocA-linkageArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions