Skip to content

build_from_source makes assumptions on internal Cargo details, breaking cargo-miri with new build-dir features #25

Closed
@epage

Description

@epage

Original report at rust-lang/cargo#14125 (comment)

miri (13e8790949 2025-05-04) fails to run with

$ cargo miri clean
$ cargo miri test
Preparing a sysroot for Miri (target: x86_64-unknown-linux-gnu)... fatal error: failed to build sysroot: failed to read cargo out dir

Caused by:
    No such file or directory (os error 2)

when

[build]
build-dir = "{cargo-cache-home}/build/{workspace-path-hash}"

[unstable]
build-dir=true

is set in ~/.cargo/config.toml.

After disabling these lines, miri can create the sysroot and works when these lines are reenabled.

The problem is

let out_dir = build_target_dir
.join(&target_name)
.join(DEFAULT_SYSROOT_PROFILE)
.join("deps");

According to the Cargo docs

Cargo also creates several other directories and files needed for the build process. Their layout is considered internal to Cargo, and is subject to change. Some of these directories are:

target/debug/deps/

With rust-lang/cargo#14125 (docs), users will be allowed to move deps and many other directories out of target-dir into their `build-dir of choice.

Our expectation is that we will eventually change the default location of build-dir from target-dir to {cargo-cache-home}/build/{workspace-path-hash}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions