Cargo创建的默认文件树允许并行编译发布和调试版本,因为它们位于自己的目录中;分别为target/release
和target/debug
。
允许并行编译stable
/ nightly
- 编译器有多困难。例如,使用目录
target/debug/stable
target/debug/nightly
我知道可以用jails /容器来完成,但我希望有更多的货物解决方案。
答案 0 :(得分:12)
我相信重建依赖关系的主问题不再存在:
$ cargo +nightly build
Updating crates.io index
Compiling either v1.5.0
Compiling itertools v0.8.0
Compiling example v0.1.0 (/private/tmp/example)
Finished dev [unoptimized + debuginfo] target(s) in 5.87s
$ cargo +stable build
Compiling either v1.5.0
Compiling itertools v0.8.0
Compiling example v0.1.0 (/private/tmp/example)
Finished dev [unoptimized + debuginfo] target(s) in 2.67s
$ cargo +nightly build
Finished dev [unoptimized + debuginfo] target(s) in 0.17s
$ cargo +stable build
Finished dev [unoptimized + debuginfo] target(s) in 0.16s
我相信这是渐进式编译工作的副作用:编译器版本(或等效的东西)用作构建工件的散列算法的一部分。因此,来自多个工具链的伪像可以共存。
这不涵盖了最终的工件,它具有固定的名称并将被覆盖。如果你真的需要保持两者并行,请继续阅读。
如Is it possible to deactivate file locking in cargo?中所述,您可以为您感兴趣的每个频道设置环境变量CARGO_TARGET_DIR
:
$ CARGO_TARGET_DIR=$PWD/stable rustup run stable cargo build
Compiling many v0.1.0 (file:///private/tmp/many)
Finished debug [unoptimized + debuginfo] target(s) in 0.89 secs
$ CARGO_TARGET_DIR=$PWD/nightly rustup run nightly cargo build
Compiling many v0.1.0 (file:///private/tmp/many)
Finished debug [unoptimized + debuginfo] target(s) in 0.62 secs
$ ./stable/debug/many
Hello, world!
$ ./nightly/debug/many
Hello, world!