Mizunashi
Mizunashi

Reputation: 335

Is there way to use xbuild instead of build when calling cargo-binutils commands?

I try to use binutils commands for binary of custom build target with cargo xbuild command.
However, I get an error like below message.

$ cargo nm --target i586-rust_dos.json --bin rust_dos --verbose
"cargo" "build" "--target" "i586-rust_dos.json" "--bin" "rust_dos" "--message-format=json"
   Compiling rust_dos v0.1.0 (/home/soya/Documents/src/rust/prac/rust_dos)
error[E0463]: can't find crate for `core`                                ] 0/2
  |
  = note: the `i586-rust_dos-8410465322435951119` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `rust_dos`.

To learn more, run the command again with --verbose.
error: Failed to parse crate metadata

I realized that cargo nm uses cargo build command,
so I think this error should be solved if I make cargo nm to use cargo xbuild instead of cargo build.

However, I cannot find how to do that.
Please teach me if there is a way.

Upvotes: 2

Views: 386

Answers (1)

Mizunashi
Mizunashi

Reputation: 335

To detect core crate built with cargo xbuild, I need to add sysroot flag in rustflags in .cargo/config.

example is below.

rustflags = ["--sysroot", "/full/path/to/sysroot/directory"]

There is sysroot directory in project's target directory.

If adding these flags, cargo-bintuils commands are enabled to use as far as in my environment.

Upvotes: 0

Related Questions