Skip to content

Eliminate xargo dependency#1709

Merged
Emilgardis merged 4 commits intocross-rs:mainfrom
neuschaefer:xargo
Jan 3, 2026
Merged

Eliminate xargo dependency#1709
Emilgardis merged 4 commits intocross-rs:mainfrom
neuschaefer:xargo

Conversation

@neuschaefer
Copy link
Copy Markdown
Contributor

@neuschaefer neuschaefer commented Sep 26, 2025

xargo is no longer actively developed and has fortunately become unnecessary due to the build-std option in cargo.

Fixes: #692


The plan is to try all targets and see which ones actually need build-std. I will then add build-std in targets.toml as needed. It is also possible that I'm missing something else.


  • clean up rust code
  • clean up documentation

@a5ehren
Copy link
Copy Markdown

a5ehren commented Nov 5, 2025

Not sure when it quit working, but note that at least as of Rust 1.91 you can no longer build an image from the Dockerfiles due to Xargo:


25.83    Compiling dirs-sys v0.3.7
25.83    Compiling fs2 v0.4.3
25.91    Compiling dirs v4.0.0
26.23    Compiling tempdir v0.3.7
27.15    Compiling toml v0.5.11
28.00 error[E0308]: mismatched types
28.00    --> /tmp/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/xargo-0.3.26/src/flock.rs:118:41
28.00     |
28.00 118 |                 acquire(msg, &path, &|| f.try_lock_shared(), &|| f.lock_shared())?;
28.00     |                                         ^^^^^^^^^^^^^^^^^^^ expected `Result<(), Error>`, found `Result<(), TryLockError>`
28.00     |
28.00     = note: expected enum `std::result::Result<_, std::io::Error>`
28.00                found enum `std::result::Result<_, std::fs::TryLockError>`
28.00 help: use `?` to coerce and return an appropriate `Err`, and wrap the resulting value in `Ok` so the expression remains of type `Result`
28.00     |
28.00 118 |                 acquire(msg, &path, &|| Ok(f.try_lock_shared()?), &|| f.lock_shared())?;
28.00     |                                         +++                   ++
28.00
28.12 For more information about this error, try `rustc --explain E0308`.
28.12 error: could not compile `xargo` (lib) due to 1 previous error
28.12 warning: build failed, waiting for other jobs to finish...
28.80 error: failed to compile `xargo v0.3.26`, intermediate artifacts can be found at `/tmp/cargo-installH3IbjE`.
28.80 To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
------
Dockerfile.x86_64-pc-windows-gnu:11
--------------------
   9 |
  10 |     COPY xargo.sh /
  11 | >>> RUN /xargo.sh
  12 |
  13 |     FROM cross-base AS build
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c /xargo.sh" did not complete successfully: exit code: 101

Copy link
Copy Markdown

@m-reichard m-reichard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated cross-rs and was stuck in the weeds of the xargo issues for hours, this totally fixed the problem, which was not at all clear from the cross-rs error.

@neuschaefer neuschaefer marked this pull request as ready for review December 28, 2025 15:56
@neuschaefer neuschaefer requested a review from a team as a code owner December 28, 2025 15:56
@therealprof
Copy link
Copy Markdown
Contributor

Hm, where was xargo actually used? In https://github.com/cross-rs/cross/pull/1709/files#diff-daa4fe2a01c2753b53e896c72d636979f146bb50cdef0c4404300e8fb181093e it was merely installed, no?

@neuschaefer
Copy link
Copy Markdown
Contributor Author

Hm, where was xargo actually used? In https://github.com/cross-rs/cross/pull/1709/files#diff-daa4fe2a01c2753b53e896c72d636979f146bb50cdef0c4404300e8fb181093e it was merely installed, no?

Good question, I don't know. @Emilgardis might know

@Emilgardis
Copy link
Copy Markdown
Member

it's available if needed, but we removed the implicit usage of it and opted for nightly build-std instead.

Copy link
Copy Markdown
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bunch of mentions of xargo in the rust source code, these should be removed. Care should be taken to not mess with the build-std paths however

@Emilgardis
Copy link
Copy Markdown
Member

Emilgardis commented Dec 29, 2025

to flesh that comment out a bit more: here's how we determine if xargo is to be used or not

let uses_xargo = !build_std.enabled() && config.xargo(&target).unwrap_or(!target.is_builtin());

and ultimately that ends up being used here

let mut cmd = options.command_variant.safe_command();

xargo is no longer actively developed and has fortunately become
unnecessary due to the build-std option in cargo.

Fixes: cross-rs#692
@neuschaefer
Copy link
Copy Markdown
Contributor Author

I gave it a first try, not entirely sure about the direction

Copy link
Copy Markdown
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one minor nit

sorry, I thought I had sent this review already but I hadn't!

Comment thread docs/environment_variables.md Outdated
Comment on lines +58 to +60
example, setting `CROSS_BUILD_XARGO=1` is identical to setting `build.xargo =
true`, and `CROSS_TARGET_AARCH64_UNKNOWN_LINUX_GNU_XARGO=1` is identical to
`target.aarch64-unknown-linux-gnu.xargo = true`.
example, setting `CROSS_BUILD_DOCKERFILE=foo` is identical to setting `build.dockerfile =
foo`.
Copy link
Copy Markdown
Member

@Emilgardis Emilgardis Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add an example of a target.<target>. setting here

CROSS_TARGET_AARCH64_UNKNOWN_LINUX_GNU_DOCKERFILE=foo maybe?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review, I'll do that.

Copy link
Copy Markdown
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! LGTM!

@Emilgardis Emilgardis added the no-ci-targets PRs that do not affect or should skip any cross-compilation targets. label Jan 3, 2026
@Emilgardis Emilgardis enabled auto-merge January 3, 2026 16:57
@Emilgardis Emilgardis added this pull request to the merge queue Jan 3, 2026
Merged via the queue into cross-rs:main with commit 426e811 Jan 3, 2026
20 checks passed
github-merge-queue Bot pushed a commit that referenced this pull request Jan 19, 2026
Updates the cross-toolchains submodule to include
cross-rs/cross-toolchains#72, which removes xargo.sh references from
Dockerfiles.

This fixes builds for targets defined in cross-toolchains (e.g.
`x86_64-pc-windows-msvc`) after xargo.sh was removed in #1709.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-ci-targets PRs that do not affect or should skip any cross-compilation targets.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drop xargo in favor of build-std

5 participants