rust-script icon indicating copy to clipboard operation
rust-script copied to clipboard

Specifying build target

Open ethindp opened this issue 3 years ago • 3 comments

I'm building an OS kernel and use rust-script for some build tasks. However, cargo's config.toml file is still used for the script, and that TOML file contains actions for building parts of the rust standard library (core, alloc, ...). (This is a known issue for cargo.) Is there a way of getting around this? I'm using cargo-make, and I'd explicitly like the build script I use to not be influenced by anything in .cargo/config.toml.

ethindp avatar Jun 12 '21 18:06 ethindp

@ethindp Have you found any way around this?

Does anyone know of a workaround (either to apply manually, or that can be added to rust-script)?

fornwall avatar Jul 10 '21 09:07 fornwall

I ran into this problem recently, I have a project setup which targets an embedded device with a specific platform. But also a subdirectory inside that with a rust based script I'd like to run unfortunately it looks like cargo searches up the directory tree for .config/config.toml in any of the parent directories which then influences how the script is built (which typically in my case is for the wrong target)

Under windows I had to use the -o option to see the compile fail message

I suspect it might be related to https://github.com/rust-lang/cargo/issues/8643 https://github.com/rust-lang/cargo/blob/master/src/doc/src/reference/config.md

Hecatron avatar Oct 30 '21 16:10 Hecatron

I also stumbled on this problem. You can solve it by using unstable package.forced-target option (added in https://github.com/rust-lang/cargo/pull/9030) in Cargo.toml instead of setting target in .cargo/config.toml. It's nightly only, but it works.

chemicstry avatar Feb 11 '22 02:02 chemicstry