Skip to content

cargo test with a proc_macro tries to run a host test on the target #4336

@tkilbourn

Description

@tkilbourn

When I cross-compile the attached crate's "proc-macro-test-derive" subcrate, cargo attempts to run tests compiled for the host. (This crate attempts to mirror the layout of the rand and rand-derive crates, which is how I discovered the issue.)

Setup

Running rustc 1.19.0 (0ade33941 2017-07-17), cargo 0.20.0 (a60d185 2017-07-13)

  1. Install a cross-compiler (e.g., on ubuntu trusty: apt-get install libc6-dev-arm64-cross gcc-aarch64-linux-gnu)
  2. Install qemu (ubuntu trusty: apt-get install qemu-user-static)
  3. Set a linker and runner for the target in ~/.cargo/config:
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
runner = "qemu-aarch64-static -L /usr/aarch64-linux-gnu"

Repro

cd proc-macro-test-derive
cargo test --target aarch64-unknown-linux-gnu

This will attempt to run target/debug/deps/proc_macro_test_derive-1f6a3cff88feb964, which is compiled for the host rather than the target. When cargo test is run without a --target, this (empty) test succeeds and the intended test target/debug/deps/macros-659b3b1ec96599d4 is run.

For --target aarch64-unknown-linux-gnu, I expect target/aarch64-unknown-linux-gnu/debug/macros-da045a5e3c0e63ff to be run.

proc-macro-test.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Command-testS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions