GithubHelp home page GithubHelp logo

japaric / xargo Goto Github PK

View Code? Open in Web Editor NEW
1.1K 22.0 94.0 695 KB

The sysroot manager that lets you build and customize `std`

License: Apache License 2.0

Rust 100.00%
rust cargo sysroot bare-metal cross-compilation no-std

xargo's Introduction

crates.io crates.io

xargo

The sysroot manager that lets you build and customize std

Cross compiling `std` for i686-unknown-linux-gnu
Cross compiling `std` for i686-unknown-linux-gnu

Xargo builds and manages "sysroots" (cf. rustc --print sysroot). Making it easy to cross compile Rust crates for targets that don't have binary releases of the standard crates, like the thumbv*m-none-eabi* targets. And it also lets you build a customized std crate, e.g. compiled with -C panic=abort, for your target.

Dependencies

  • The rust-src component, which you can install with rustup component add rust-src.

  • Rust and Cargo.

Installation

$ cargo install xargo

Usage

no_std

xargo has the exact same CLI as cargo.

# This Just Works
$ xargo build --target thumbv6m-none-eabi
   Compiling core v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libcore)
    Finished release [optimized] target(s) in 11.61 secs
   Compiling lib v0.1.0 (file://$PWD)
    Finished debug [unoptimized + debuginfo] target(s) in 0.5 secs

xargo will cache the sysroot, in this case the core crate, so the next build command will be (very) fast.

$ xargo build --target thumbv6m-none-eabi
    Finished debug [unoptimized + debuginfo] target(s) in 0.0 secs

By default, xargo will only compile the core crate for the target. If you need a bigger subset of the standard crates, specify the dependencies in a Xargo.toml at the root of your Cargo project (right next to Cargo.toml).

$ cat Xargo.toml
# Alternatively you can use [build.dependencies]
# the syntax is the same as Cargo.toml's; you don't need to specify path or git
[target.thumbv6m-none-eabi.dependencies]
collections = {}

$ xargo build --target thumbv6m-none-eabi
   Compiling core v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libcore)
   Compiling alloc v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/liballoc)
   Compiling std_unicode v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libstd_unicode)
   Compiling collections v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libcollections)
    Finished release [optimized] target(s) in 15.26 secs
   Compiling lib v0.1.0 (file://$PWD)
    Finished debug [unoptimized + debuginfo] target(s) in 0.5 secs

std

You can compile a customized std crate as well, just specify which Cargo features to enable.

# Build `std` with `-C panic=abort` (default) and with jemalloc as the default
# allocator
$ cat Xargo.toml
[target.i686-unknown-linux-gnu.dependencies.std]
features = ["jemalloc"]

# Needed to compile `std` with `-C panic=abort`
$ tail -n2 Cargo.toml
[profile.release]
panic = "abort"

$ xargo run --target i686-unknown-linux-gnu --release
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling libc v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/rustc/libc_shim)
   Compiling core v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libcore)
   Compiling build_helper v0.1.0 (file://$SYSROOT/lib/rustlib/src/rust/src/build_helper)
   Compiling gcc v0.3.41
   Compiling unwind v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libunwind)
   Compiling std v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libstd)
   Compiling compiler_builtins v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libcompiler_builtins)
   Compiling alloc_jemalloc v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/liballoc_jemalloc)
   Compiling alloc v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/liballoc)
   Compiling rand v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/librand)
   Compiling std_unicode v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libstd_unicode)
   Compiling alloc_system v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/liballoc_system)
   Compiling panic_abort v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libpanic_abort)
   Compiling collections v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libcollections)
    Finished release [optimized] target(s) in 33.49 secs
   Compiling hello v0.1.0 (file://$PWD)
    Finished release [optimized] target(s) in 0.28 secs
     Running `target/i686-unknown-linux-gnu/release/hello`
Hello, world!

If you'd like to know what xargo is doing under the hood, pass the verbose, -v, flag to it.

$ xargo build --target thumbv6m-none-eabi -v
+ "rustc" "--print" "target-list"
+ "rustc" "--print" "sysroot"
+ "cargo" "build" "--release" "--manifest-path" "/tmp/xargo.lTBXKnaUGicV/Cargo.toml" "--target" "thumbv6m-none-eabi" "-v" "-p" "core"
   Compiling core v0.0.0 (file://$SYSROOT/lib/rustlib/src/rust/src/libcore)
     Running `rustc --crate-name core $SYSROOT/lib/rustlib/src/rust/src/libcore/lib.rs --crate-type lib -C opt-level=3 -C metadata=a5c596f87f7d486b -C extra-filename=-a5c596f87f7d486b --out-dir /tmp/xargo.lTBXKnaUGicV/target/thumbv6m-none-eabi/release/deps --emit=dep-info,link --target thumbv6m-none-eabi -L dependency=/tmp/xargo.lTBXKnaUGicV/target/thumbv6m-none-eabi/release/deps -L dependency=/tmp/xargo.lTBXKnaUGicV/target/release/deps`
    Finished release [optimized] target(s) in 11.50 secs
+ "cargo" "build" "--target" "thumbv6m-none-eabi" "-v"
   Compiling lib v0.1.0 (file://$PWD)
     Running `rustc --crate-name lib src/lib.rs --crate-type lib -g -C metadata=461fd0b398821543 -C extra-filename=-461fd0b398821543 --out-dir $PWD/target/thumbv6m-none-eabi/debug/deps --emit=dep-info,link --target thumbv6m-none-eabi -L dependency=$PWD/target/thumbv6m-none-eabi/debug/deps -L dependency=$PWD/lib/target/debug/deps --sysroot $HOME/.xargo`
    Finished debug [unoptimized + debuginfo] target(s) in 0.5 secs

Dev channel

Oh, and if you want to use xargo to compile std using a "dev" rustc, a rust compiled from source, you can use the XARGO_RUST_SRC environment variable to tell xargo where the Rust source is.

# `$XARGO_RUST_SRC` must point to the `library` subfolder of a Rust checkout.
$ export XARGO_RUST_SRC=/path/to/rust/library

$ xargo build --target msp430-none-elf

NOTE This also works with the nightly channel but it's not recommended as the Rust source may diverge from what your compiler is able to compile as it may make use of newer features that your compiler doesn't understand.

Compiling the sysroot with custom rustc flags

Xargo uses the same custom rustc flags that apply to the target Cargo project. So you can use either the RUSTFLAGS env variable or a .cargo/config configuration file to specify custom rustc flags.

# build the sysroot with debug information
$ RUSTFLAGS='-g' xargo build --target x86_64-unknown-linux-gnu

# Alternatively
$ edit .cargo/config && cat $_
[build]
rustflags = ["-g"]

# Then you can omit RUSTFLAGS
$ xargo build --target x86_64-unknown-linux-gnu

Compiling the sysroot for a custom target

At some point you may want to develop a program for a target that's not officially supported by rustc. Xargo's got your back! It supports custom targets via target specifications files, which are not really documented anywhere other than in the compiler source code. Luckily you don't need to write a specification file from scratch; you can start from an existing one.

For example, let's say that you want to cross compile a program for a PowerPC Linux systems that uses uclibc instead of glibc. There's a similarly looking target in the list of targets supported by the compiler -- see rustc --print target-list -- and that is powerpc-unknown-linux-gnu. So you can start by dumping the specification of that target into a file:

$ rustc -Z unstable-options --print target-spec-json --target powerpc-unknown-linux-gnu | tee powerpc-unknown-linux-uclibc.json
{
  "arch": "powerpc",
  "data-layout": "E-m:e-p:32:32-i64:64-n32",
  "dynamic-linking": true,
  "env": "gnu",
  "executables": true,
  "has-elf-tls": true,
  "has-rpath": true,
  "is-builtin": true,
  "linker-flavor": "gcc",
  "linker-is-gnu": true,
  "llvm-target": "powerpc-unknown-linux-gnu",
  "max-atomic-width": 32,
  "os": "linux",
  "position-independent-executables": true,
  "pre-link-args": {
    "gcc": [
      "-Wl,--as-needed",
      "-Wl,-z,noexecstack",
      "-m32"
    ]
  },
  "target-endian": "big",
  "target-family": "unix",
  "target-pointer-width": "32",
  "vendor": "unknown"
}

One of the things you'll definitively want to do is drop the is-builtin field as that's reserved for targets that are defined in the compiler itself. Apart from that the only modification you would have to in this case is change the env field from gnu (glibc) to uclibc.

   "arch": "powerpc",
   "data-layout": "E-m:e-p:32:32-i64:64-n32",
   "dynamic-linking": true,
-  "env": "gnu",
+  "env": "uclibc",
   "executables": true,
   "has-elf-tls": true,
   "has-rpath": true,
-  "is-builtin": true,
   "linker-flavor": "gcc",
   "linker-is-gnu": true,
   "llvm-target": "powerpc-unknown-linux-gnu",

Once you have your target specification file you only have to call Xargo with the right target triple; make sure that the specification file is the same folder from where you invoke Xargo because that's where rustc expects it to be.

$ ls powerpc-unknown-linux-uclibc.json
powerpc-unknown-linux-uclibc.json

$ xargo build --target powerpc-unknown-linux-uclibc

Your build may fail because if rustc doesn't support your target then it's likely that the standard library doesn't support it either. In that case you will have to modify the source of the standard library. Xargo helps with that too because you can make a copy of the original source -- see rustc --print sysroot, modify it and then point Xargo to it using the XARGO_RUST_SRC env variable.

Multi-stage builds

Some standard crates have implicit dependencies between them. For example, the test crate implicitly depends on the std. Implicit here means that the test crate Cargo.toml doesn't list std as its dependency. To compile a sysroot that contains such crates you can perform the build in stages by specifying which crates belong to each stage in the Xargo.toml file:

[dependencies.std]
stage = 0

[dependencies.test]
stage = 1

This will compile an intermediate sysroot, the stage 0 sysroot, containing the std crate, and then it will compile the test crate against that intermediate sysroot. The final sysroot, the stage 1 sysroot, will contain both the std and test crates, and their dependencies.

Creating a sysroot with custom crates

Xargo lets you create a sysroot with custom crates. You can virtually put any crate in the sysroot. However, this feature is mainly used to create [alternative std facades][rust-3ds], and to replace the test crate with one that supports no_std targets. To specify the contents of the sysroot simply list the dependencies in the Xargo.toml file as you would do with Cargo.toml:

# First build some standard crates.
[dependencies.alloc]
[dependencies.panic_abort]
[dependencies.panic_unwind]

# Then build our custom facade. It (implicitly) requires the crates above to
# already be in the sysroot, so we need to set the `stage`.
[dependencies.std]
git = "https://github.com/rust3ds/ctru-rs"
stage = 1

Patching sysroot crates

Xargo also supports the patch feature from Cargo. This allows you to force the use of a custom crate throughout your sysroot's dependency tree. This can be especially useful to force the use of a custom libc or compiler_builtins without having to do intrusive changes to every transitive dependency.

[patch.crates-io.libc]
path = "path/to/custom/libc"

Notice that you should not list patched crates as [dependencies]! [dependencies] determines which crates are built in the first place; [patch] lets you replace some of their (transitive) dependencies with your own choice. Having a crate listed in both will likely lead to crate duplication.

Check-only sysroot build

Xargo supports performing a 'check build' of the syroot via the xargo-check command. This command is invoked exactly like xargo, but will invoke cargo check instead of cargo build when building the sysroot.

This is only useful for very specialized applicationsm like Miri. The resulting libstd will not be useable in a normal build, since codegen will not be performed. You should almost always run xargo check (note the space), which will perform a normal sysroot build, followed by a 'check' build of your application

Caveats / gotchas

  • Xargo won't build a sysroot when used with stable or beta Rust. This is because std and other standard crates depend on unstable features so it's not possible to build the sysroot with stable or beta.

  • std is built as rlib and dylib. The dylib needs a panic library and an allocator. If you do not specify the panic-unwind feature, you have to set panic = "abort" in Cargo.toml.

  • To build without the jemalloc feature include the following in Xargo.toml:

    [dependencies.std]
    features = ["force_alloc_system"]

    What this flag means is that every program compiled with this libstd can only use the system allocator. If your program tries to set its own allocator, compilation will fail because now two allocators are set (one by libstd, one by your program). For some further information on this issue, see rust-lang/rust#43637.

  • It's recommended that the --target option is always used for xargo. This is because it must be provided even when compiling for the host platform due to the way cargo handles compiler plugins (e.g. serde_derive) and build scripts (build.rs). This also applies to how all of the dependant crates get compiled that use compiler plugins or build scripts. You can determine your host's target triple with rustc -vV. On *nix, the following rune will extract the triple: rustc -vV | egrep '^host: ' | sed 's/^host: //'.

  • Remember that core and std will get implicitly linked to your crate but all the other sysroot crates will not. This means that if your Xargo.toml contains a crate like alloc then you will have to add a extern crate alloc somewhere in your dependency graph (either in your current crate or in some of its dependencies).

  • Remember that rustc will always implicitly link compiler_builtins into your final binary, but won't make it available for use the same way core and std are. So if you need to manually call a compiler_builtins function, you will still need to manually add an extern crate compiler_builtins within your crate.

  • Care must be taken not to end up with any "top-level" crates (core, std, compiler-builtins) twice in the sysroot. Doing so will cause cargo to error on build with a message like multiple matching crates for core. Duplicate crates in the sysroot generally occur when the same crate is built twice with different features as part of a multi-stage build.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

xargo's People

Contributors

4tm4j33tk4ur avatar a-nickol avatar aaron1011 avatar ayazhafiz avatar blutack avatar bors[bot] avatar fenrirwolf avatar homunkulus avatar ids1024 avatar japaric avatar jdub avatar jethrogb avatar johnthagen avatar k0pernicus avatar leo60228 avatar nils-tud avatar notriddle avatar oxalica avatar priyasiddharth avatar ralfjung avatar regexident avatar rkarp avatar roblabla avatar thejpster avatar thinkofname avatar victorkoenders avatar woyten avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xargo's Issues

problems with `-C link-args` that have arguments with spaces

If you use something like this:

[ build]
rustflags = [
  "-C",
  "link-args=-Tlayout.ld -nostartfiles"
]

in your .cargo/config, the executable with fail to link because three arguments will be passed to rustc: -C, -link-args=-Tlayout.ld and -nostartfiles. This a problem with Xargo because it uses RUSTFLAGS to pass these (and --sysroot) as a string to Cargo and then Cargo parses RUSTFLAGS by splitting it at whitespaces.

There is no real solution for this other than to use -C link-arg (rust-lang/rust#36574) multiple times instead of -C link-args.

Once that PR lands in rust-lang/rust, let's have Cargo print a warning about this problem and also suggest using -C link-arg instead of -C link-args.

travis: caching appears to not work

attempting to download cache archive

fetching v0.2.0-rc1/cache-linux-trusty-e98a5aab280b2cf9177d6093bcf0d8ec968d424ea3df937fa3cf9b5ed4aee1a3.tgz

fetching master/cache-linux-trusty-e98a5aab280b2cf9177d6093bcf0d8ec968d424ea3df937fa3cf9b5ed4aee1a3.tgz

could not download cache

Doesn't build alloc and collections when max_atomic_width = 0

I believe alloc now builds for thumbv6 (max_atomic_width=0), so could xargo now build alloc and collections?

I looked in the source code but I couldn't see where the builds where elided. Is it actually something cargo does?

Edit: Apologies for the edits - my finger slipped :/

Use rust-src component provided by rustup

rustup will soon provide a way to install Rust source in the sysroot. When that becomes available, let's have Xargo try to use that source directory first. If that's not available, fall back to the current logic of downloading the tarball from static.r-l.o

Xargo can not find component `rust-src`

Following along with the intermezzOs, I installed xargo. After installing Xargo, I ran the following command:

$ xargo build --release --target ./x86_64-unknown-metalomai-gnu.json
error: `rust-src` component not found. Run `rustup component add rust-src`.
$

Following the instructions in the error message, I installed the rust-src component.

$ rustup component add rust-src
info: downloading component 'rust-src'
 26.4 MiB /  26.4 MiB (100 %) 377.6 KiB/s ETA:   0 s
info: installing component 'rust-src'
warning: could not delete temp directory: /home/geemili/.multirust/tmp/zgpxf8_tm0kk8a72_dir
$ 

Then I tried running xargo again.

$ xargo build --release --target ./x86_64-unknown-metalomai-gnu.json
error: `rust-src` component not found. Run `rustup component add rust-src`.
$ # :(

Xargo finds the current sysroot using [this code][find-sysroot]. In bash, that looks like:

$ rustc --print sysroot
/home/geemili/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu
$

Then it walks the directories to [find a file named "version", in a directory named rust.][find-version]. Translating to bash again:

$ find /home/geemili/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/ -name "version"
/home/geemili/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/test/run-make/version
$ 

The "version" file is not in the "rust" folder, so the program fails.


I don't know why where version is was changed, but depending on this seems like a hack. Perhaps a better way could be found to find the location of rust-src? Maybe someone from who works on rustup could comment.

~/.xargo is purged whenever nightly version is different

If I am working on different rust projects with different rust nightly versions, then each time I recompile a project with a different toolchain xargo throws away the sysroot and rebuilds it for the different version.

Would it be worth structuring ~/.xargo similarly to how multirust does with a path component that specifies the nightly-date of the source and sysroots inside allowing for multiple nightly versions at the same time?

Explicitly building sysroot

Would it be possible to add an option for xargo to build the sysroot without an associated cargo cmd.
So that I could explicitly get xargo to build a sysroot by typing xargo --target={TARGET_NAME}.

This is beneficial for when setting up a build environment I want to know that all of my toolchain dependencies correctly installed before starting the build process.

`xargo clean` sometimes causes dependencies to be built

It seems that when I change rustc versions (with rustup), a xargo clean command will trigger the normal dependency generation process.

➜  teensy3-rs-demo git:(master) ✗ xargo clean
   Compiling sysroot for thumbv7em-none-eabi
   Compiling core v0.0.0 (file:///Users/jamesmunns/.multirust/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcore)
   Compiling rand v0.0.0 (file:///Users/jamesmunns/.multirust/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/librand)
   Compiling alloc v0.0.0 (file:///Users/jamesmunns/.multirust/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/liballoc)
   Compiling rustc_unicode v0.0.0 (file:///Users/jamesmunns/.multirust/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/librustc_unicode)
   Compiling collections v0.0.0 (file:///Users/jamesmunns/.multirust/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/src/libcollections)
    Finished release [optimized] target(s) in 17.72 secs

I would not expect a clean command to build anything

RUSTDOCFLAGS are not respected

I think #43 simply overrides RUSTDOCFLAGS / build.rustdocflags with --sysroot=... instead of appending the --sysroot argument to it.

Unlisted dependencies

To build on Fedora 24, I needed to first install cmake and openssl-devel, which was unexpected. I think they were required for libssh2-sys.

Could these be added to the README?

Xargo not recognizing rust-src on nightly (8f02c429a 2016-12-15)

It seems that on the latest nightly xargo cannot find rust-src.
I made sure that everything was up-to-date with

rustup update

and

rustup component add rust-src
info: component 'rust-src' is up to date

However, if I try to compile a project that was compiling fine before I get:

xargo build --target src/libtms570/tms570 --verbose
error: `rust-src` component not found. Run `rustup component add rust-src`.
stack backtrace:
   0:     0x55817919e8fd - backtrace::backtrace::trace::h4f27741ec31c8869
   1:     0x55817919efc2 - backtrace::capture::Backtrace::new::h3416c1b891724916
   2:     0x558179182e28 - error_chain::make_backtrace::h97415d00ea7612fa
   3:     0x55817917a8c7 - xargo::sysroot::update_target_sysroot::h4803bfb4d7fea03c
   4:     0x55817917f777 - xargo::run::h98c387672443789b
   5:     0x55817917c69d - xargo::main::h6f768eebe9cc419e
   6:     0x5581791c318a - panic_unwind::__rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
   7:     0x5581791bca36 - std::panicking::try<(),fn()>
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:434
                         - std::panic::catch_unwind<fn(),()>
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panic.rs:351
                         - std::rt::lang_start
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/rt.rs:57
   8:     0x7ffba0c8d3f0 - __libc_start_main
   9:     0x558179165729 - _start
  10:                0x0 - <unknown>

Those are the versions I am using

xargo --version
xargo 0.2.2
cargo 0.16.0-nightly (ddb5c32 2016-12-16)
rustc --version
rustc 1.15.0-nightly (8f02c429a 2016-12-15)

To confirm this bug I have reverted the rust toolchain to nightly-2016-12-06-x86_64-unknown-linux-gnu and everything compiles just fine.

Customization of std

Once #77 is implemented, people are going to ask for a way to customize the std crate (jemalloc vs alloc_system, backtrace or not, etc.).

So, I have been thinking about how to present "customizability" to users and how to solve the problem of nasty build errors, like libc, that are not actual errors.

My idea is to, by default, only build the core crate and have users specify what other dependencies they want + how to customize them via a Xargo.toml file in the root of the Cargo project.

Syntax is undecided but maybe something that looks like Cargo.toml:

# Xargo.toml
[dependencies]
collections = "0"  # NOTE version doesn't actually matter

[dependencies.compiler-builtins]
features = ["mem"]
version = "0"

No compiler_builtins for no_std builds?

Hey there! compiler_builtins doesn't appear to be built for a no_std sysroot. It turns up in ~/.xargo/lib/rustlib/x86_64-unknown-linux-gnu/lib/ along with the rest of std though.

From a quick glance at the code, I can't figure out why it's not built. It's a dependency of libstd, and I can't see where that list is being filtered. (It's clearly not tested in tests/smoke.rs though.)

When I was making sysroots with a cheesy script instead of xargo, it built fine and often came in handy.

binary releases don't work in Arch Linux

$ ./xargo -V
./xargo: /usr/lib/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by ./xargo)
./xargo: /usr/lib/libssl.so.1.0.0: no version information available (required by ./xargo)
./xargo: /usr/lib/libcrypto.so.1.0.0: no version information available (required by ./xargo)

Tested using Xargo 0.1.14

`xargo doc` doesn't seem to work

Xargo is working fabulously for my embedded project, with one exception.

[cbiffle@anansi emb1]$ xargo build --release
    Finished release [optimized + debuginfo] target(s) in 0.0 secs
[cbiffle@anansi emb1]$ xargo doc --release
 Documenting bitflags v0.7.0
error[E0463]: can't find crate for `core`

error: aborting due to previous error

error: Could not document `bitflags`.

To learn more, run the command again with --verbose.
error: `cargo` process didn't exit successfully

xargo doc doesn't seem to be hunting for crates in the sysroot. Am I doing something wrong?

Cross compile std

For starters, with a few restrictions

  • Xargo won't compile std for the host
  • No custom std source
  • The Cargo features of std can't be tweaked

These issues need to be addressed in rust-lang/rust:

But there are probably others. The easiest way to test this feature today is by compiling a binary Cargo project with the following Cargo.toml.

[dependencies]
std = "$(rustc --print sysroot)/lib/rustlib/src/rust/src/libstd"

Overriding ~/.xargo directory for sandboxing

Could xargo support a sandboxing ability where the rust sources and sysroot libraries can be put in a location other than in ~/.xargo.

The argument to be able to override where the libraries are linked to is to support situations where there are different target.json configurations that still have the same custom target name but with slightly different target configurations.

The argument to be able to override the location where the source files are put is for when you need to tweak some of the rust sources, but want to keep this isolated from other projects.

The main use case for this that I experience is when trying to get rust working on different targets on top of a non windows/unix/osx os environment. I had some patches for cargo-sysroot to support this and would be willing to port them over to xargo.

doesn't work with the built-in thumb targets

Xargo doesn't build a sysroot for built-in targets because those ship with binary releases of core et al. But these new thumb targets don't, so let's special case them in Xargo to make Xargo build a sysroot for them.

xargo seems to use stable rust when I have a multirust override nightly set

I've built xargo, using stable rust (i.e. in a directory without a multirust override set). I'm now in my Cortex-M cross-compile project, trying out xargo instead of cargo + libcore.

101 ✗ jonathan@carbon ~/Documents/programming/rust/bare-metal-arm-rust
$ xargo build --target=lm4f120 -v
   Compiling sysroot for lm4f120
   Compiling core v0.0.0 (file:///home/jonathan/.xargo/src/libcore)
     Running `rustc /home/jonathan/.xargo/src/libcore/lib.rs --crate-name core --crate-type lib -C opt-level=3 -C metadata=2502405bcd7e03db -C extra-filename=-2502405bcd7e03db --out-dir /tmp/xargo.0I1apaykfTuA/target/lm4f120/release/deps --emit=dep-info,link --target lm4f120 -L dependency=/tmp/xargo.0I1apaykfTuA/target/lm4f120/release/deps -L dependency=/tmp/xargo.0I1apaykfTuA/target/lm4f120/release/deps`
/home/jonathan/.xargo/src/libcore/lib.rs:67:1: 67:37 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:67 #![feature(allow_internal_unstable)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:68:1: 68:17 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:68 #![feature(asm)]
                                            ^~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:69:1: 69:38 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:69 #![feature(associated_type_defaults)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:70:1: 70:32 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:70 #![feature(cfg_target_feature)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:71:1: 71:27 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:71 #![feature(concat_idents)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:72:1: 72:22 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:72 #![feature(const_fn)]
                                            ^~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:73:1: 73:35 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:73 #![feature(cfg_target_has_atomic)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:74:1: 74:30 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:74 #![feature(custom_attribute)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:75:1: 75:25 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:75 #![feature(fundamental)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:76:1: 76:36 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:76 #![feature(inclusive_range_syntax)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:77:1: 77:24 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:77 #![feature(intrinsics)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:78:1: 78:24 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:78 #![feature(lang_items)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:79:1: 79:21 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:79 #![feature(no_core)]
                                            ^~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:80:1: 80:30 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:80 #![feature(on_unimplemented)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:81:1: 81:34 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:81 #![feature(optin_builtin_traits)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:82:1: 82:21 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:82 #![feature(reflect)]
                                            ^~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:83:1: 83:31 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:83 #![feature(unwind_attributes)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:84:1: 84:44 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:84 #![feature(repr_simd, platform_intrinsics)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:85:1: 85:25 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:85 #![feature(rustc_attrs)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:86:1: 86:28 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:86 #![feature(specialization)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:87:1: 87:24 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:87 #![feature(staged_api)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:88:1: 88:30 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:88 #![feature(unboxed_closures)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jonathan/.xargo/src/libcore/lib.rs:89:1: 89:27 error: #[feature] may not be used on the stable release channel
/home/jonathan/.xargo/src/libcore/lib.rs:89 #![feature(question_mark)]
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 23 previous errors
error: Could not compile `core`.

Caused by:
  Process didn't exit successfully: `rustc /home/jonathan/.xargo/src/libcore/lib.rs --crate-name core --crate-type lib -C opt-level=3 -C metadata=2502405bcd7e03db -C extra-filename=-2502405bcd7e03db --out-dir /tmp/xargo.0I1apaykfTuA/target/lm4f120/release/deps --emit=dep-info,link --target lm4f120 -L dependency=/tmp/xargo.0I1apaykfTuA/target/lm4f120/release/deps -L dependency=/tmp/xargo.0I1apaykfTuA/target/lm4f120/release/deps` (exit code: 101)
error: `cargo` process didn't exit successfully

The override is definitely set:

101 ✗ jonathan@carbon ~/Documents/programming/rust/bare-metal-arm-rust
$ rustc --version
rustc 1.12.0-nightly (28ce3e8a5 2016-08-01)

Using xargo in two directories forces rebuilds every time

When using xargo in a single directory, it won't rebuild if things haven't changed. When switching between two directories, it rebuilds everything (including core), every time.

e.g.

$ cd proj1
$ xargo build --release
  Compiling core v0.0.0 (file:///home/cbiffle/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling alloc v0.0.0 (file:///home/cbiffle/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc)
    Finished release [optimized] target(s) in 9.7 secs
   Compiling rustc_unicode v0.0.0 (file:///home/cbiffle/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/librustc_unicode)
   Compiling collections v0.0.0 (file:///home/cbiffle/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcollections)
    Finished release [optimized] target(s) in 2.69 secs
    Finished release [optimized] target(s) in 0.0 secs
   Compiling rand v0.0.0 (file:///home/cbiffle/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/librand)
    Finished release [optimized] target(s) in 0.88 secs
    Finished release [optimized] target(s) in 0.0 secs
    Finished release [optimized] target(s) in 0.0 secs
$ xargo build --release
    Finished release [optimized] target(s) in 0.0 secs
$ cd ../proj2
$ xargo build --release
    [build spew]
$ cd ../proj1
$ xargo build --release
      Compiling core v0.0.0 (file:///home/cbiffle/.multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
    [snip]

But nothing has changed in proj1 in this example; a false dependency must have been created through some piece of information xargo is caching.

weird error with cross-device hardlink

I'm using xargo within a docker container, where CARGO_HOME and ~/.xargo are on different file systems.

This leads to the following error:

 Downloading https://static.rust-lang.org/dist/2016-08-10/rustc-nightly-src.tar.gz

[snipped out successful compiles]

     Running `rustc /data/riotbuild/.xargo/src/libcollections/lib.rs --crate-name collections --crate-type lib -C opt-level=3 -C metadata=f4d6828fe1f117b1 --out-dir /tmp/xargo.K94mJ2X6F8BN/target/cortex-m0plus/release/deps --emit=dep-info,link --target cortex-m0plus -L dependency=/tmp/xargo.K94mJ2X6F8BN/target/cortex-m0plus/release/deps --extern alloc=/tmp/xargo.K94mJ2X6F8BN/target/cortex-m0plus/release/deps/liballoc.rlib --extern rustc_unicode=/tmp/xargo.K94mJ2X6F8BN/target/cortex-m0plus/release/deps/librustc_unicode.rlib --extern core=/tmp/xargo.K94mJ2X6F8BN/target/cortex-m0plus/release/deps/libcore.rlib`
    Finished release [optimized] target(s) in 44.51 secs
error: Invalid cross-device link (os error 18)

Interestingly, just repeating the build command succeds.

This are the relevant strace parts:

[snip]

570   stat("/opt/rust/cargo/bin/xargo", {st_mode=S_IFREG|0775, st_size=2039944, ...}) = 0
570   clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f9ee1c679d0) = 571
570   wait4(-1,  <unfinished ...>
571   execve("/opt/rust/cargo/bin/xargo", ["xargo", "build", "--target", "cortex-m0plus", "--verbose"], [/* 99 vars */]) = 0
[snip]
606   execve("/opt/rust/cargo/bin/rustc", ["rustc", "--print", "sysroot"], [/* 99 vars */] <unfinished ...>
[snip]
606   <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 607
606   --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=607, si_uid=1000, si_status=0, si_utime=2, si_stime=0} ---
606   sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=8192}, NULL) = 0
606   munmap(0x7fa5ff306000, 8192)      = 0
606   exit_group(0)                     = ?
606   +++ exited with 0 +++
571   <... select resumed> )            = 2 (in [6 8])
571   --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=606, si_uid=1000, si_status=0, si_utime=2, si_stime=0} ---
571   read(6, "", 64)                   = 0
571   fcntl(8, F_GETFL)                 = 0x800 (flags O_RDONLY|O_NONBLOCK)
571   fcntl(8, F_SETFL, O_RDONLY)       = 0
571   read(8, "", 16)                   = 0
571   close(8)                          = 0
571   close(6)                          = 0
571   wait4(606, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 606
571   open("/opt/rust/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 5
571   fstat(5, {st_mode=S_IFDIR|S_ISGID|0775, st_size=4096, ...}) = 0
571   getdents(5, /* 55 entries */, 32768) = 2624
571   link("/opt/rust/multirust/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-c8005792.so", "/data/riotbuild/.xargo/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-c8005792.so") = -1 EXDEV (Invalid cross-device link)
571   close(5)                          = 0
571   flock(4, LOCK_UN)                 = 0
571   close(4)                          = 0
571   flock(3, LOCK_UN)                 = 0
571   close(3)                          = 0
571   write(2, "\33(B\33[m", 6)         = 6
571   write(2, "\33[31m", 5)            = 5
571   write(2, "\33[1m", 4)             = 4
571   write(2, "error:", 6)             = 6
571   write(2, "\33(B\33[m", 6)         = 6
571   write(2, " ", 1)                  = 1
571   write(2, "Invalid cross-device link (os er"..., 39) = 39
571   write(2, "\n", 1)                 = 1
571   sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=8192}, NULL) = 0
571   munmap(0x7fdda8bca000, 8192)      = 0
571   exit_group(101)                   = ?
571   +++ exited with 101 +++

The only place where xargo hardlinks is in symlink_host_crates().

Maybe an option to actually symlink would be nice?

Error: failed to recursively copy /tmp/xargo.… to ~/.xargo/lib/…

I get this error whenever xargo tries to rebuild the sysroot (e.g. on a rust update):

error: failed to recursively copy /tmp/xargo.qkh3QP6TAK4K/target/cortex-a8/release/deps to /home/philipp/.xargo/lib/rustlib/cortex-a8/lib
caused by: No such file or directory (os error 2)
stack backtrace:
   0:     0x5627cc2b3701 - backtrace::backtrace::libunwind::trace
                        at /home/philipp/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.2.3/src/backtrace/mod.rs:82
                         - backtrace::backtrace::trace<closure>
                        at /home/philipp/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.2.3/src/backtrace/mod.rs:70
   1:     0x5627cc2b4588 - backtrace::capture::{{impl}}::new
                        at /home/philipp/.cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.2.3/src/lib.rs:96
   2:     0x5627cc245671 - error_chain::make_backtrace
                        at /home/philipp/.cargo/registry/src/github.com-1ecc6299db9ec823/error-chain-0.5.0/src/lib.rs:684
   3:     0x5627cc23d57c - xargo::errors::{{impl}}::chain_err::{{closure}}::{{closure}}<(),std::io::error::Error,closure,collections::string::String>
                        at /home/philipp/Documents/xargo/src/errors.rs:1
   4:     0x5627cc1c1eed - core::option::{{impl}}::unwrap_or_else<core::option::Option<alloc::arc::Arc<backtrace::capture::Backtrace>>,closure>
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/option.rs:358
   5:     0x5627cc241a9e - xargo::errors::{{impl}}::chain_err::{{closure}}<(),std::io::error::Error,closure,collections::string::String>
                        at /home/philipp/Documents/xargo/src/errors.rs:1
   6:     0x5627cc1d5723 - core::result::{{impl}}::map_err<(),std::io::error::Error,xargo::errors::Error,closure>
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libcore/result.rs:494
   7:     0x5627cc23d045 - xargo::errors::{{impl}}::chain_err<(),std::io::error::Error,closure,collections::string::String>
                        at /home/philipp/Documents/xargo/src/errors.rs:1
   8:     0x5627cc226594 - xargo::fs::cp_r
                        at /home/philipp/Documents/xargo/src/fs.rs:33
   9:     0x5627cc232c32 - xargo::sysroot::update_target_sysroot
                        at /home/philipp/Documents/xargo/src/sysroot.rs:230
  10:     0x5627cc230555 - xargo::sysroot::update
                        at /home/philipp/Documents/xargo/src/sysroot.rs:118
  11:     0x5627cc237733 - xargo::run
                        at /home/philipp/Documents/xargo/src/main.rs:88
  12:     0x5627cc236016 - xargo::main
                        at /home/philipp/Documents/xargo/src/main.rs:38
  13:     0x5627cc306d1a - panic_unwind::__rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  14:     0x5627cc3005c6 - std::panicking::try<(),fn()>
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panicking.rs:434
                         - std::panic::catch_unwind<fn(),()>
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/panic.rs:351
                         - std::rt::lang_start
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libstd/rt.rs:57
  15:     0x5627cc243fd2 - main
  16:     0x7f72c8a8082f - __libc_start_main
  17:     0x5627cc1a4908 - _start
  18:                0x0 - <unknown>

Doing a xargo clean doesn't help. However, it works if I copy the complete crate to a new location (e.g. to Desktop) and compile it there. Afterwards, the sysroot for the target exists and thus the crate at the old location compiles too.

I'm using the current master version (239c969), but the issue also occurs with the crates.io versions of xargo.

Rust/Cargo versions:
rustc 1.15.0-nightly (8f02c429a 2016-12-15)
cargo 0.16.0-nightly (ddb5c32 2016-12-16)

Is there a way to do `xargo test`?

Adding test to Xargo.toml makes xargo attempt to compile it, but it does not find std.

Here is an example of running xargo test without modifying Xargo.toml:

error[E0463]: can't find crate for `test`
 --> src/wget/main.rs:1:1
  |
1 | extern crate rustls;
  | ^ can't find crate

error: aborting due to previous error

Now, with a toml that looks like this:

[target.x86_64-unknown-redox.dependencies.std]
features = []

[target.x86_64-unknown-redox.dependencies.test]
features = []

I get this:

    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling core v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling gcc v0.3.41
   Compiling libc v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/rustc/libc_shim)
   Compiling unwind v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libunwind)
   Compiling build_helper v0.1.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/build_helper)
   Compiling compiler_builtins v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcompiler_builtins)
   Compiling std v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd)
   Compiling alloc v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc)
   Compiling std_unicode v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd_unicode)
   Compiling rand v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/librand)
   Compiling panic_abort v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libpanic_abort)
   Compiling alloc_system v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc_system)
   Compiling collections v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcollections)
warning: dropping unsupported crate type `dylib` for target `x86_64-unknown-redox`

    Finished release [optimized] target(s) in 34.53 secs
   Compiling term v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libterm)
   Compiling getopts v0.0.0 (file:///home/jackpot/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libgetopts)
warning: dropping unsupported crate type `dylib` for target `x86_64-unknown-redox`

warning: dropping unsupported crate type `dylib` for target `x86_64-unknown-redox`

error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-redox` target may not be installed

error: aborting due to previous error

Build failed, waiting for other jobs to finish...
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-redox` target may not be installed

error: aborting due to previous error

error: Could not compile `getopts`.

To learn more, run the command again with --verbose.
error: `"cargo" "build" "--release" "--manifest-path" "/tmp/xargo.MdPp527CF7oz/Cargo.toml" "--target" "x86_64-unknown-redox" "-p" "test"` failed with exit code: Some(101)
note: run with `RUST_BACKTRACE=1` for a backtrace

So, it has already compiled std, but upon trying to compile dependencies of test, it does not have std available in the library directory.

Xargo modifies the contents of `rust-src`

because it uses the cargo metadata under the hood and that places a Cargo.lock in src/libstd. Unsure how bad this actually is. My next rustup update will probably answer that.

Unable to compile xargo on Windows

D:\MinGW>cargo install xargo
Updating registry https://github.com/rust-lang/crates.io-index
Compiling log v0.3.6
Compiling semver v0.1.20
Compiling nom v1.2.3
Compiling libc v0.2.12
Compiling filetime v0.1.10
Compiling bitflags v0.1.1
Compiling rand v0.3.14
Compiling memchr v0.1.11
Compiling rustc-serialize v0.3.19
Compiling num_cpus v0.2.12
Compiling num-traits v0.1.32
Compiling strsim v0.3.0
Compiling tar v0.4.6
Compiling aho-corasick v0.5.2
Compiling semver v0.2.3
Compiling tempdir v0.3.4
Compiling unicode-normalization v0.1.2
Compiling pkg-config v0.3.8
Compiling gcc v0.3.28
Compiling regex-syntax v0.3.3
Compiling winapi v0.2.7
Compiling miniz-sys v0.1.7
Compiling cmake v0.1.17
Compiling flate2 v0.2.14
Compiling libgit2-sys v0.4.3
Compiling libssh2-sys v0.1.37
Compiling uuid v0.1.18
Compiling matches v0.1.2
Compiling rustc_version v0.1.7
Compiling toml v0.1.30
Compiling url v0.2.38
Compiling unicode-bidi v0.2.3
Compiling idna v0.1.0
Compiling crossbeam v0.2.9
Compiling url v1.1.1
Compiling libz-sys v1.0.4
Compiling winapi-build v0.1.1
Compiling advapi32-sys v0.1.2
Compiling kernel32-sys v0.2.2
Compiling glob v0.2.11
Build failed, waiting for other jobs to finish...
error: failed to compile xargo v0.1.3, intermediate artifacts can be found at C:\Users\ANDREW~1\AppData\Local\Temp\cargo-install.U56h6Jyln4o9

Caused by:
failed to run custom build command for libssh2-sys v0.1.37
Process didn't exit successfully: C:\Users\ANDREW~1\AppData\Local\Temp\cargo-install.U56h6Jyln4o9\release\build\libssh2-sys-468c4b5ae90680be\build-script-build (exit code: 101)
--- stdout
running: "cmake" "C:\Users\Andrew Ashworth.cargo\registry\src\github.com-1ecc6299db9ec823\libssh2-sys-0.1.37\libssh2" "-G" "MSYS Makefiles" "-DCRYPTO_BACKEND=WinCNG" "-DZLIB_INCLUDE_DIR=/" "-DBUILD_SHARED_LIBS=OFF" "-DENABLE_ZLIB_COMPRESSION=ON" "-DCMAKE_INSTALL_LIBDIR=lib" "-DBUILD_EXAMPLES=OFF" "-DBUILD_TESTING=OFF" "-DCMAKE_INSTALL_PREFIX=C:\Users\ANDREW~1\AppData\Local\Temp\cargo-install.U56h6Jyln4o9\release\build\libssh2-sys-468c4b5ae90680be\out" "-DCMAKE_C_FLAGS= -O0 -ffunction-sections -fdata-sections -m32" "-DCMAKE_CXX_FLAGS= -O0 -ffunction-sections -fdata-sections -m32" "-DCMAKE_BUILD_TYPE=Release"
-- The C compiler identification is GNU 6.1.0
-- Check for working C compiler: D:/MinGW/bin/gcc.exe
-- Check for working C compiler: D:/MinGW/bin/gcc.exe -- broken
-- Configuring incomplete, errors occurred!
See also "C:/Users/Andrew Ashworth/AppData/Local/Temp/cargo-install.U56h6Jyln4o9/release/build/libssh2-sys-468c4b5ae90680be/out/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Andrew Ashworth/AppData/Local/Temp/cargo-install.U56h6Jyln4o9/release/build/libssh2-sys-468c4b5ae90680be/out/build/CMakeFiles/CMakeError.log".

--- stderr
CMake Error at D:/apps/cmake/share/cmake-3.4/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "D:/MinGW/bin/gcc.exe" is not able to compile a simple test
program.

It fails with the following output:

Change Dir: C:/Users/Andrew Ashworth/AppData/Local/Temp/cargo-install.U56h6Jyln4o9/release/build/libssh2-sys-468c4b5ae90680be/out/build/CMakeFiles/CMakeTmp

Run Build Command:"D:/MinGW/bin/make.exe" "cmTC_c5f16/fast"

D:/MinGW/bin/make.exe -f CMakeFiles/cmTC_c5f16.dir/build.make
CMakeFiles/cmTC_c5f16.dir/build

make.exe[1]: Entering directory 'C:/Users/Andrew
Ashworth/AppData/Local/Temp/cargo-install.U56h6Jyln4o9/release/build/libssh2-sys-468c4b5ae90680be/out/build/CMakeFiles/CMakeTmp'

process_begin: CreateProcess(NULL, sh.exe -c "/D/apps/cmake/bin/cmake.exe
-E cmake_echo_color --switch= --progress-dir=/C/Users/Andrew
Ashworth/AppData/Local/Temp/cargo-install.U56h6Jyln4o9/release/build/libssh2-sys-468c4b5ae90680be/out/build/CMakeFiles/CMakeTmp/CMakeFiles
--progress-num=1 Building C object
CMakeFiles/cmTC_c5f16.dir/testCCompiler.c.obj", ...) failed.

make (e=2): The system cannot find the file specified.

make.exe[1]: *** [CMakeFiles/cmTC_c5f16.dir/build.make:65:
CMakeFiles/cmTC_c5f16.dir/testCCompiler.c.obj] Error 2

make.exe[1]: Leaving directory 'C:/Users/Andrew
Ashworth/AppData/Local/Temp/cargo-install.U56h6Jyln4o9/release/build/libssh2-sys-468c4b5ae90680be/out/build/CMakeFiles/CMakeTmp'

make.exe: *** [Makefile:126: cmTC_c5f16/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:40 (project)

thread 'main' panicked at '
command did not execute successfully, got: exit code: 1

build script failed, must exit now', C:\Users\Andrew Ashworth.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.17\src\lib.rs:463
note: Run with RUST_BACKTRACE=1 for a backtrace.

Any ideas?

Build modified versoin of std

I'm working on std (in ~/dev/rust/rust), with a test crate in /tmp/test. I tried exporting XARGO_RUST_SRC and running xargo build, but it only build the test crate and not the modified std. How can I do that?

Respect default target in .cargo/config

I use a default target through a .cargo/config file:

[build]
target="stm32f7"

xargo build --target stm32f7 works fine, but xargo build fails with can't find crate for core.

Sysroot fails to update when using rustup's rust-src component

I've been trying out using the rust-src component and encounter the following error whenever I update to a new nightly version of Rust:

xargo build --release
   Compiling ctru-sys v0.2.0 (file:///home/fenrir/projects/ctru-rs/ctru-sys)
   Compiling rust3ds-template v0.1.0 (file:///home/fenrir/projects/rust3ds-template)
   Compiling alloc_system3ds v0.1.0 (https://github.com/rust3ds/alloc_system3ds?rev=da38c94#da38c941)
   Compiling ctru-rs v0.4.0 (file:///home/fenrir/projects/ctru-rs)
error[E0514]: found crate `core` compiled by an incompatible version of rustc
  |
  = help: please recompile that crate using this compiler (rustc 1.13.0-nightly (2c01bb885 2016-08-31))
  = note: crate `core` path #1: /home/fenrir/.xargo/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-411f48d3.rlib compiled by "rustc 1.13.0-nightly (eac41469d 2016-08-30)"
  = note: crate `core` path #2: /home/fenrir/.xargo/lib/rustlib/3ds/lib/libcore.rlib compiled by "rustc 1.13.0-nightly (eac41469d 2016-08-30)"

error: aborting due to previous error

Deleting the existing sysroot allows it to successfully rebuild, and deleting the rust-src component so that xargo falls back to its old behavior also results in a successful rebuild.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.