Skip to content

allow specifying build-std on workspace members #15365

Open
@tsatke

Description

@tsatke

Problem

Hi,

in my current project, I have a workspace that has an artifact dependency on one of its members. The workspace is built for the host arch, but the artifact dependency is always x86_64-unknown-none.

I would need to be able to specify -Zbuild-std=core,alloc for that x86_64 member, which is currently not possible. I can specify unstable.build-std in .cargo/config.toml, however that requires me specifying build.target as well, which doesn't work because then my workspace will also be built for that. If I don't specify the target, I get a panic no entry found for key.


thread 'main' panicked at src/tools/cargo/src/cargo/core/compiler/unit_dependencies.rs:178:34:
no entry found for key
stack backtrace:
   0:        0x10165d700 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h30f4b9ed62f3897b
   1:        0x1016814a4 - core::fmt::write::h68122921d8b1a619
   2:        0x101657db0 - std::io::Write::write_fmt::hac1f183862df87a2
   3:        0x10165d5b4 - std::sys::backtrace::BacktraceLock::print::h1f1b6b5bdc96b0cd
   4:        0x10165ea40 - std::panicking::default_hook::{{closure}}::heae1779b685357fb
   5:        0x10165e890 - std::panicking::default_hook::h309e27147f9cc499
   6:        0x10165f520 - std::panicking::rust_panic_with_hook::h6e33d145b73c56b6
   7:        0x10165f14c - std::panicking::begin_panic_handler::{{closure}}::h1b530e3befd00369
   8:        0x10165dbb0 - std::sys::backtrace::__rust_end_short_backtrace::h08b2dd416eec9a36
   9:        0x10165edf4 - __rustc[30d06caa1ba95d]::rust_begin_unwind
  10:        0x1016ed574 - core::panicking::panic_fmt::ha09de3336dfd93b2
  11:        0x1016ed554 - core::option::expect_failed::hb3fc12b2cdb34fa4
  12:        0x100e5eba0 - cargo[afe0554dd491e78]::core::compiler::unit_dependencies::build_unit_dependencies
  13:        0x100e89284 - cargo[afe0554dd491e78]::ops::cargo_compile::create_bcx
  14:        0x100e87cc0 - cargo[afe0554dd491e78]::ops::cargo_compile::compile_ws
  15:        0x100cda224 - cargo[afe0554dd491e78]::ops::cargo_compile::compile_with_exec
  16:        0x100cda164 - cargo[afe0554dd491e78]::ops::cargo_compile::compile
  17:        0x10082bddc - cargo[bc5817d802847781]::commands::build::exec
  18:        0x10084ca38 - <cargo[bc5817d802847781]::cli::Exec>::exec
  19:        0x100844ae0 - cargo[bc5817d802847781]::main
  20:        0x1007d7ec0 - std[54631d7a81de9e90]::sys::backtrace::__rust_begin_short_backtrace::<fn(), ()>
  21:        0x1007e7668 - std[54631d7a81de9e90]::rt::lang_start::<()>::{closure#0}
  22:        0x10164f7e4 - std::rt::lang_start_internal::h08b3d2187a7fcb0a
  23:        0x10084f61c - _main

For this problem, I wouldn't mind if build-std would be active for all workspace crates, however it of course should build the right arch.

Proposed Solution

Either allow an additional key in the artifact dependency declaration (not so great IMO).

Or allow per-member .cargo/config.toml files, in which I can easily specify all that's required (awesome but huge effort probably).

Or don't require the build.target together with unstable.build-std, because the target should become clear from the crate that is being built (I think?).

Notes

My specific problem is that I want to implement stack unwinding for x86_64-unknown-none in my project, but it seems like the stack frames under panic! don't have unwind info - probably because I'm using the precompiled libcore. That's why I'd like to be able to compile it myself. Any alternative approaches besides adding this feature are more welcome.

Also, I'd like to keep using workspaces and bindeps, although I'm aware that those are an unstable feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-needs-infoStatus: Needs more info, such as a reproduction or more background for a feature request.Z-bindepsNightly: binary artifact dependenciesZ-build-stdNightly: build-std

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions