Skip to content

rustc cannot find crate if different target is used #116562

Closed
@jpalus

Description

@jpalus

I have a self build of rust 1.73.0 on ARM/Linux configured to include two targets:

  • armv7-unknown-linux-gnueabihf (Tier 2 with host tools)
  • thumbv7neon-unknown-linux-gnueabihf (Tier 2 without host tools)

When building recent Mesa 23.2.1 for the latter target I've hit a build issue due to missing crate. The reduced reproducer is:

my_proc_macros.rs:

extern crate proc_macro;

lib.rs:

use my_proc_macros;

my_proc_macros.rs is compiled to shared object:

rustc --edition=2021  --crate-type proc-macro  --target thumbv7neon-unknown-linux-gnueabihf --crate-name my_proc_macros  -o libmy_proc_macros.so -C prefer-dynamic my_proc_macros.rs

while the lib.rs is compiled to static lib with use of above my_proc_macros:

rustc --edition=2021  --crate-type staticlib   --target thumbv7neon-unknown-linux-gnueabihf --crate-name app  -o lib.a --extern my_proc_macros=libmy_proc_macros.so lib.rs

The latter errors out with:

error[E0463]: can't find crate for `my_proc_macros`
 --> lib.rs:1:5
  |
1 | use my_proc_macros;
  |     ^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.

However if I substitute target thumbv7neon-unknown-linux-gnueabihf with armv7-unknown-linux-gnueabihf all builds fine.

Meta

rustc --version --verbose:

rustc 1.73.0 (cc66ad468 2023-10-03) (built from a source tarball)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: armv7-unknown-linux-gnueabihf
release: 1.73.0
LLVM version: 17.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    requires-custom-configThis issue requires custom config/build for rustc in some way

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions