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

Overview

PSA: Xargo is in maintenance mode

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.

# The source of the `core` crate must be in `$XARGO_RUST_SRC/libcore`
$ export XARGO_RUST_SRC=/path/to/rust/src

$ 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 compielr_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.

Comments
  • Xargo can not find component `rust-src`

    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.

    opened by leroycep 23
  •  Search for Xargo.toml in parent directories, including test

    Search for Xargo.toml in parent directories, including test

    So far, xargo expected the Xargo.toml in the directory of the Cargo.toml. This patch searches for the Xargo.toml by walking up the directory hierarchy. This is useful if a workspace is used, leading, for example, to one Cargo.toml with the workspace and multiple Cargo.toml files for the members of the workspace. With this patch, it is no longer necessary to have one Xargo.toml for each Cargo.toml, but only one next to the workspace, for example.

    opened by Nils-TUD 22
  • Using with a crate that uses proc_macro

    Using with a crate that uses proc_macro

    e.g. serde

    I've tried a few different ways to get this to work but it always ends up with

    error: libproc_macro.so: cannot open shared object file: No such file or directory
      --> src/lib.rs:23:1
       |
    23 | extern crate serde_derive;
       | ^^^^^^^^^^^^^^^^^^^^^^^^^^
    

    Not sure if i'm missing something

    opened by Thinkofname 16
  • try to build all std dependencies including std

    try to build all std dependencies including std

    this makes Xargo robust against changes in the std facade as all the crate names that were hardcoded in Xargo, e.g. rustc_unicode, have been removed.

    The downside is that this also worsens the user experience because when Xargo fails to build one of std dependencies it will simply regurgitate the error to stderr.

    cc @brson with this change, I won't get mad if you change the std facade :smile:.

    opened by japaric 14
  • clarify operating systems with available binaries

    clarify operating systems with available binaries

    This is very much a nit. Feel free to close and discard this PR if you wish.

    It may also be worth getting rid of this line entirely. It appears that since 0.3.12 there have only been Windows binary releases (excluding one linux one in 0.3.13).

    opened by ayazhafiz 13
  • allow

    allow "multi-stage" sysroot builds

    with this is now possible to build the test crate which doesn't explicitly depend on std.

    This Xargo.toml

    [dependencies.std]
    features = ["panic_unwind"]
    # stage = 0 # implicit
    
    [dependencies.test]
    stage = 1
    

    Builds the sysroot in two stages. First, Xargo builds the std facade, the stage 0, turns that into a partial sysroot and then builds the test crate, the stage 1, against that partial sysroot. Finally, the stage 0 artifacts and the stage 1 artifacts are then merged into the sysroot that will be used to build the application.

    The result is that you can use xargo test with this Xargo.toml.


    cc @jackpot51

    opened by japaric 13
  • improve error message when the `rust-src` component is missing

    improve error message when the `rust-src` component is missing

    now you get:

    $ xargo build
    error: `rust-src` component not found. Run `rustup component add rust-src`.
    note: run with `RUST_BACKTRACE=1` for a backtrace
    

    closes #124

    opened by japaric 12
  • Xargo fails to copy nested directories

    Xargo fails to copy nested directories

    After not using xargo for a couple of months I tried updating it today and I get the following error:

    D:\Development\Personal\rust_stm32f103>xargo --verbose
    + "rustc" "--print" "sysroot"
    + "rustc" "--print" "target-list"
    + "cargo" "build" "--release" "--manifest-path" "C:\\Users\\VKOEND~1.INT\\AppData\\Local\\Temp\\xargo.L9kWwUhdnTlo\\Cargo.toml" "--target" "thumbv7em-none-eabihf" "-v" "-p" "core"
    Compiling core v0.0.0 (file:///C:/Users/vkoenders.INTRANET/.rustup/toolchains/nightly-x86_64-pc-windows-msvc/lib/rustlib/src/rust/src/libcore)
     Running `rustc --crate-name core C:\Users\vkoenders.INTRANET\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\src\libcore\lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C metadata=ed3afdb7c1933857 -C extra-filename=-ed3afdb7c1933857 --out-dir C:\Users\VKOEND~1.INT\AppData\Local\Temp\xargo.L9kWwUhdnTlo\target\thumbv7em-none-eabihf\release\deps --target thumbv7em-none-eabihf -L dependency=C:\Users\VKOEND~1.INT\AppData\Local\Temp\xargo.L9kWwUhdnTlo\target\thumbv7em-none-eabihf\release\deps -L dependency=C:\Users\VKOEND~1.INT\AppData\Local\Temp\xargo.L9kWwUhdnTlo\target\release\deps -C link-arg=-Tstm32f103.ld -C link-arg=-nostartfiles --sysroot C:\Users\vkoenders.INTRANET\.xargo`
    Finished release [optimized] target(s) in 24.38 secs
    error: copying files from `C:\Users\vkoenders.INTRANET\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib/rustlib\x86_64-pc-windows-msvc\lib` to `C:\Users\vkoenders.INTRANET\.xargo\lib/rustlib\x86_64-pc-windows-msvc\lib` failed
    caused by: Access is denied. (os error 5)
    stack backtrace:
     0:     0x7ff6ca37090f - <no info>
     1:     0x7ff6ca371222 - <no info>
     2:     0x7ff6ca34a328 - <no info>
     3:     0x7ff6ca340a1d - <no info>
     4:     0x7ff6ca337fe6 - <no info>
     5:     0x7ff6ca34726c - <no info>
     6:     0x7ff6ca3441df - <no info>
     7:     0x7ff6ca3936a2 - <no info>
     8:     0x7ff6ca3929ca - <no info>
     9:     0x7ff6ca3a2429 - <no info>
    10:     0x7ff8e0578364 - BaseThreadInitThunk
    

    The C:\Users\vkoenders.INTRANET.xargo\lib/rustlib\x86_64-pc-windows-msvc\lib directory does get created and filled, so I'm not sure what's going wrong.

    xargo 0.3.5 cargo 0.19.0-nightly (4e95c6b41 2017-03-23) Windows 10 64 bit

    I'm not sure where to start debugging or getting more info

    opened by VictorKoenders 12
  • v0.3.26 has a subtle breaking change

    v0.3.26 has a subtle breaking change

    Hi guys, please see this commit message on our project's repo: https://github.com/scrtlabs/SecretNetwork/commit/a8f623f5b375575f89b7a0da3ee52ac4a5ec7ef0

    Pin xargo to v0.3.25

    As xargo v0.3.26 contains breaking changes, specifically this: https://github.com/japaric/xargo/compare/v0.3.25...v0.3.26diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5L147-R148 which caused an error[E0463]: can't find crate for "core" error when building

    This is because of the change to the search path of sysroot. You might want to also tag v0.3.26 as v0.4.0.

    Cc @reuvenpo

    opened by assafmo 1
  • target powerpc-unknown-linux-gnu - can't even build simple hello world

    target powerpc-unknown-linux-gnu - can't even build simple hello world

    Running on Ubuntu 20.04, installed cross compilation tools using sudo apt-get install crossbuild-essential-powerpc

    Created new crate using cargo new --bin hello

    Installed Xargo, rust src etc. and tried to build as described on main readme.md

    I get 'failed to select a version for 'std'.

    Jorge - can you please provide simple and tested instructions for this simple task? This should be trivial but it is not!

    opened by mfanara 0
  • "cant find crate std" error when trying to build DLL

    I'm trying to remove any panic!() macros from my build to see how much the resulting size of the binary is affected.

    cargo install xargo
    rustup component add rust-src
    git clone https://github.com/fschutt/azul
    cd azul/azul-dll
    xargo clean
    xargo build --release xargo build --release --target x86_64-unknown-linux-gnu
    

    gives:

    warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
    package:   /home/felix/Development/azul/azul-dll/Cargo.toml
    workspace: /home/felix/Development/azul/Cargo.toml
    warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
    package:   /home/felix/Development/azul/azulc/Cargo.toml
    workspace: /home/felix/Development/azul/Cargo.toml
    warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
    package:   /home/felix/Development/azul/azul-dll/Cargo.toml
    workspace: /home/felix/Development/azul/Cargo.toml
    warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
    package:   /home/felix/Development/azul/azulc/Cargo.toml
    workspace: /home/felix/Development/azul/Cargo.toml
    warning: output filename collision.
    The lib target `azul` in package `azul-dll v0.0.1 (/home/felix/Development/azul/azul-dll)` has the same output filename as the lib target `azul` in package `azul v1.0.0-beta1 (/home/felix/Development/azul/api/rust)`.
    Colliding filename is: /home/felix/Development/azul/target/x86_64-unknown-linux-gnu/release/libazul.rlib
    The targets should have unique names.
    Consider changing their names to be unique or compiling them separately.
    This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
       Compiling autocfg v1.1.0
       Compiling libc v0.2.117
       Compiling proc-macro2 v1.0.36
       Compiling unicode-xid v0.2.2
       Compiling syn v1.0.86
       Compiling cfg-if v1.0.0
       Compiling lazy_static v1.4.0
       Compiling serde_derive v1.0.136
       Compiling crossbeam-utils v0.8.7
       Compiling log v0.4.14
    error[E0463]: can't find crate for `std`
     --> /home/felix/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:9:1
      |
    9 | extern crate std;
      | ^^^^^^^^^^^^^^^^^ can't find crate
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error: could not compile `lazy_static`
    
    To learn more, run the command again with --verbose.
    warning: build failed, waiting for other jobs to finish...
    error: build failed
    

    verbose build:

    + "rustc" "--print" "sysroot"
    + RUSTFLAGS="--sysroot /home/felix/.xargo/HOST"
    + "cargo" "build" "--release" "--verbose" "--target" "x86_64-unknown-linux-gnu"
    warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
    package:   /home/felix/Development/azul/azul-dll/Cargo.toml
    workspace: /home/felix/Development/azul/Cargo.toml
    warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
    package:   /home/felix/Development/azul/azulc/Cargo.toml
    workspace: /home/felix/Development/azul/Cargo.toml
    warning: output filename collision.
    The lib target `azul` in package `azul-dll v0.0.1 (/home/felix/Development/azul/azul-dll)` has the same output filename as the lib target `azul` in package `azul v1.0.0-beta1 (/home/felix/Development/azul/api/rust)`.
    Colliding filename is: /home/felix/Development/azul/target/x86_64-unknown-linux-gnu/release/libazul.rlib
    The targets should have unique names.
    Consider changing their names to be unique or compiling them separately.
    This may become a hard error in the future; see <https://github.com/rust-lang/cargo/issues/6313>.
           Fresh autocfg v1.1.0
           Fresh unicode-xid v0.2.2
       Compiling lazy_static v1.4.0
       Compiling serde v1.0.136
       Compiling crc32fast v1.3.2
         Running `rustc --crate-name lazy_static /home/felix/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=z -C panic=abort -C embed-bitcode=no -C codegen-units=16 -C metadata=cbcf0a382251c772 -C extra-filename=-cbcf0a382251c772 --out-dir /home/felix/Development/azul/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/home/felix/Development/azul/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/felix/Development/azul/target/release/deps --cap-lints allow --sysroot /home/felix/.xargo/HOST`
         Running `rustc --crate-name build_script_build /home/felix/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.136/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="rc"' --cfg 'feature="serde_derive"' --cfg 'feature="std"' -C metadata=c352340d54173480 -C extra-filename=-c352340d54173480 --out-dir /home/felix/Development/azul/target/release/build/serde-c352340d54173480 -L dependency=/home/felix/Development/azul/target/release/deps --cap-lints allow`
       Compiling byteorder v1.4.3
         Running `rustc --crate-name build_script_build /home/felix/.cargo/registry/src/github.com-1ecc6299db9ec823/crc32fast-1.3.2/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=39a6adb869985925 -C extra-filename=-39a6adb869985925 --out-dir /home/felix/Development/azul/target/release/build/crc32fast-39a6adb869985925 -L dependency=/home/felix/Development/azul/target/release/deps --cap-lints allow`
         Running `rustc --crate-name byteorder --edition=2018 /home/felix/.cargo/registry/src/github.com-1ecc6299db9ec823/byteorder-1.4.3/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=z -C panic=abort -C embed-bitcode=no -C codegen-units=16 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=e5620588a900a310 -C extra-filename=-e5620588a900a310 --out-dir /home/felix/Development/azul/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/home/felix/Development/azul/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/felix/Development/azul/target/release/deps --cap-lints allow --sysroot /home/felix/.xargo/HOST`
    error[E0463]: can't find crate for `std`
     --> /home/felix/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:9:1
      |
    9 | extern crate std;
      | ^^^^^^^^^^^^^^^^^ can't find crate
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error: could not compile `lazy_static`
    
    Caused by:
      process didn't exit successfully: `rustc --crate-name lazy_static /home/felix/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=z -C panic=abort -C embed-bitcode=no -C codegen-units=16 -C metadata=cbcf0a382251c772 -C extra-filename=-cbcf0a382251c772 --out-dir /home/felix/Development/azul/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/home/felix/Development/azul/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/home/felix/Development/azul/target/release/deps --cap-lints allow --sysroot /home/felix/.xargo/HOST` (exit status: 1)
    warning: build failed, waiting for other jobs to finish...
    error[E0463]: can't find crate for `std`
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error: build failed
    

    I want to use a custom std with panic!() macros replaced by abort():

    [dependencies]
    std = { default-features=false, features=["panic_immediate_abort"] }
    core = { default-features=false, features=["panic_immediate_abort"] }
    
    opened by fschutt 0
  • xargo doesn't work with cranelift

    xargo doesn't work with cranelift

    $  cat config.toml
    [rust]
    codegen-backends = ["cranelift"]
    $ x.py test --stage 0 src/tools/miri
    error: failed to run `rustc` to learn about target-specific information
    
    Caused by:
      process didn't exit successfully: `/home/joshua/rustc/build/bootstrap/debug/rustc - --crate-name ___ --print=file-names -Cdebug-assertions=off --sysroot /home/joshua/.cache/miri/HOST -Z force-unstable-if-unmarked --target x86_64-unknown-linux-gnu --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit code: 1)
      --- stderr
      error: failed to find a `codegen-backends` folder in the sysroot candidates:
      * /home/joshua/rustc/build/x86_64-unknown-linux-gnu
      * /home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage0-sysroot/lib/rustlib/x86_64-unknown-linux-gnu
      * /home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage0-sysroot
    
    error: `"/home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--release" "--manifest-path" "/tmp/xargo.z0UAkyvzwjGN/Cargo.toml" "--target" "x86_64-unknown-linux-gnu" "-p" "std"` failed with exit code: Some(101)
       0: error_chain::backtrace::imp::InternalBacktrace::new
       1: <error_chain::State as core::default::Default>::default
       2: <std::process::Command as xargo::extensions::CommandExt>::run
       3: xargo::sysroot::build
       4: xargo::sysroot::update
       5: xargo::main_inner
       6: std::sys_common::backtrace::__rust_begin_short_backtrace
       7: std::rt::lang_start::{{closure}}
       8: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
                 at /rustc/4708ac76ee6ec7e278a00f49a40b5bfbcdfd6168/library/core/src/ops/function.rs:259:13
          std::panicking::try::do_call
                 at /rustc/4708ac76ee6ec7e278a00f49a40b5bfbcdfd6168/library/std/src/panicking.rs:381:40
          std::panicking::try
                 at /rustc/4708ac76ee6ec7e278a00f49a40b5bfbcdfd6168/library/std/src/panicking.rs:345:19
          std::panic::catch_unwind
                 at /rustc/4708ac76ee6ec7e278a00f49a40b5bfbcdfd6168/library/std/src/panic.rs:382:14
          std::rt::lang_start_internal
                 at /rustc/4708ac76ee6ec7e278a00f49a40b5bfbcdfd6168/library/std/src/rt.rs:51:25
       9: main
      10: __libc_start_main
      11: _start
    
    fatal error: failed to run xargo
    $ fd codegen-backends /home/joshua/rustc/build/x86_64-unknown-linux-gnu
    /home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends
    $ ls /home/joshua/rustc/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends
    librustc_codegen_cranelift-1.49.0-dev.so
    
    opened by jyn514 7
  • xargo build error

    xargo build error

    I am trying out nightly xargo for further customizing target riscv64gc-unknown-linux-musl for cross building inspired by this issue but I failed at the very beginning :)

    I want a statically linked executable so targetting x86_64-unknown-linux-musl with

    xargo build --release --target x86_64-unknown-linux-musl
    

    then got

    xargo build --release --target x86_64-unknown-linux-musl
       Compiling hello v0.1.0 (/home/chao/rust_playground/hello)
    error[E0463]: can't find crate for `std`
      |
      = note: the `x86_64-unknown-linux-musl` target may not be installed
    
    error: aborting due to previous error
    
    For more information about this error, try `rustc --explain E0463`.
    error: could not compile `hello`.
    
    To learn more, run the command again with --verbose.
    Makefile:3: recipe for target 'x86-musl' failed
    make: *** [x86-musl] Error 101
    

    my rustup show

    chao@DESKTOP-B79IRTG:~/rust_playground/hello$ rustup show
    Default host: x86_64-unknown-linux-gnu
    rustup home:  /home/chao/.rustup
    
    installed toolchains
    --------------------
    
    stable-x86_64-unknown-linux-gnu
    nightly-x86_64-unknown-linux-gnu (default)
    1.40.0-x86_64-unknown-linux-gnu
    
    installed targets for active toolchain
    --------------------------------------
    
    wasm32-unknown-unknown
    x86_64-unknown-linux-gnu
    x86_64-unknown-linux-musl
    
    active toolchain
    ----------------
    
    nightly-x86_64-unknown-linux-gnu (default)
    rustc 1.44.0-nightly (f509b26a7 2020-03-18)
    

    Things work fine without nightly but with getting WARNING: the sysroot can't be built for the Stable channel. Switch to nightly. in customizing sysroot and target

    opened by chaozju 3
  • cargo-features = [

    cargo-features = ["strip"] cause compile error

    I'm trying to use xargo to reduce space of binary file. min-sized-rust mentions it here. But cargo-features = ["strip"] cause error. This thing was recently added (see https://github.com/rust-lang/cargo/issues/3483).

    $ RUST_BACKTRACE=1 xargo build --target x86_64-unknown-linux-gnu --release --verbose
    
    # output:
    + "rustc" "--print" "sysroot"
    + RUSTFLAGS="--sysroot /home/alex/.xargo/HOST -Z force-unstable-if-unmarked"
    + "cargo" "build" "--release" "--manifest-path" "/tmp/xargo.Dax5TY8K3VlJ/Cargo.toml" "--target" "x86_64-unknown-linux-gnu" "-v" "-p" "std"
    error: failed to parse manifest at `/tmp/xargo.Dax5TY8K3VlJ/Cargo.toml`
    
    Caused by:
      feature `strip` is required
    
    consider adding `cargo-features = ["strip"]` to the manifest
    error: `"cargo" "build" "--release" "--manifest-path" "/tmp/xargo.Dax5TY8K3VlJ/Cargo.toml" "--target" "x86_64-unknown-linux-gnu" "-v" "-p" "std"` failed with exit code: Some(101)
       0: error_chain::make_backtrace
       1: <error_chain::State as core::default::Default>::default
       2: <std::process::Command as xargo::extensions::CommandExt>::run
       3: xargo::sysroot::build
       4: xargo::sysroot::update
       5: xargo::main_inner
       6: std::rt::lang_start::{{closure}}
       7: std::rt::lang_start_internal::{{closure}}
                 at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/rt.rs:52
          std::panicking::try::do_call
                 at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/panicking.rs:297
          std::panicking::try
                 at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/panicking.rs:274
          std::panic::catch_unwind
                 at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/panic.rs:394
          std::rt::lang_start_internal
                 at /rustc/a74d1862d4d87a56244958416fd05976c58ca1a8/src/libstd/rt.rs:51
       8: main
       9: __libc_start_main
      10: _start
    
    

    Example Cargo.toml

    cargo-features = ["strip"]
    
    [package]
    name = "failed_case"
    version = "0.1.0"
    edition = "2018"
    
    # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    
    [dependencies]
    
    [profile.release]
    strip = "symbols"
    

    and Xargo.toml

    [dependencies.std]
    default-features = false
    features = ["panic_unwind"]
    
    $ xargo -V
    xargo 0.3.20
    cargo 1.45.0-nightly (9fcb8c1d2 2020-05-25)
    
    $ rustc -Vv
    rustc 1.45.0-nightly (5fd2f06e9 2020-05-31)
    binary: rustc
    commit-hash: 5fd2f06e99a985dd896684cb2c9f8c7090eca1ab
    commit-date: 2020-05-31
    host: x86_64-unknown-linux-gnu
    release: 1.45.0-nightly
    LLVM version: 10.0
    
    opened by Frago9876543210 1
Releases(v0.3.20)
Owner
Jorge Aparicio
@ferrous-systems engineer. @rust-embedded WG core member. He/they
Jorge Aparicio
Example of a Baremetal program written for the Rasperry Pi 1 (BCM2845). Both the UART and the Framebuffer graphics working

This repository is aimed to provide a starting point to whoever is trying to build a BCM2835 program from scratch. This repository contains linker scr

Pietro 4 Nov 10, 2022
GPIO reader, writer and listener

Unbothered gpio Everything is unwrapped under the hood for the precious prettiness of your code. It's more than a simple Rust crate, it's a philosophy

null 0 Nov 7, 2021
Libraries and tools for the SMT-LIB-2 standard.

smt2utils: Libraries and tools for the SMT-LIB-2 standard This project aims to develop Rust libraries and tools around the SMT-LIB-2 standard. The SMT

Meta Incubator 18 Dec 16, 2022
Raspberry PI library for Rust. GPIO controller, L298N motors, sockets and "i2clib" integrated

raslib Raspberry PI library for Rust. GPIO controller, L298N motors, sockets and "i2clib" integrated All tests are made on Raspberry PI 4B+ on Raspbia

Anтo 5 Apr 12, 2022
Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion is a cross-platform App Dev ToolKit build on Rust . Fusion lets you create Beautiful and Fast apps for mobile and desktop platform.

Fusion 1 Oct 19, 2021
Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc.

cargo-xbuild Cargo-xbuild is a wrapper for cargo build, which cross compiles the sysroot crates core, compiler_builtins, and alloc for custom targets.

Rust OSDev 241 Dec 30, 2022
Expanding opportunities standard library std::fs and std::io

fs_extra A Rust library that provides additional functionality not present in std::fs. Documentation Migrations to 1.x.x version Key features: Copy fi

Denis Kurilenko 163 Dec 30, 2022
Rust on ESP32 STD "Hello, World" app. A "Hello, world!" STD binary crate for the ESP32[XX] and ESP-IDF.

Rust on ESP32 STD "Hello, World" app A "Hello, world!" STD binary crate for the ESP32[XX] and ESP-IDF. This is the crate you get when running cargo ne

Ivan Markov 138 Jan 1, 2023
Searchbuddy is a browser extension that lets you chat with people that are searching for what you're searching for.

searchbuddy Make friends while searching! Searchbuddy is a browser extension that lets you chat with people that are searching for what you're searchi

Joseph Gerber 14 May 23, 2022
A bit like tee, a bit like script, but all with a fake tty. Lets you remote control and watch a process

teetty teetty is a wrapper binary to execute a command in a pty while providing remote control facilities. This allows logging the stdout of a process

Armin Ronacher 259 Jan 3, 2023
Managed game servers, matchmaking, and DDoS mitigation that lets you focus on building your game

Managed game servers, matchmaking, and DDoS mitigation that lets you focus on building your game. Home - Docs - Twitter - Discord ?? Features Everythi

Rivet 58 Jun 25, 2023
Terminal UI for leetcode. Lets you browse questions through different topics. View, solve, run and submit questions from TUI.

Leetcode TUI Use Leetcode in your terminal. Why this TUI: My motivation for creating leetcode-tui stemmed from my preference for tools that are lightw

Akarsh 8 Aug 10, 2023
The Heros NFT Marketplace Boilerplate project is designed to let users fork, customize, and deploy their own nft marketplace app to a custom domain, ultra fast.

Heros NFT on Solana The Heros NFT Marketplace Boilerplate project is designed to let users fork, customize, and deploy their own nft marketplace app t

nightfury 6 Jun 6, 2022
VSCode extension to quickly write and customize well tested Solana snippets.

Solana Snippets The Solana Snippets VSCode Extension allows you to quickly insert Solana snippets into your code. This snippets are well tested in a r

patriciobcs 7 Dec 15, 2022
Docker containers on a synthetic network. Run applications in a context that lets you manipulate their network conditions.

Synthetic Network Docker containers on a synthetic network. Run applications in a context that lets you manipulate their network conditions. Dependenc

Daily 58 Dec 15, 2022
koyo is a cli tool that lets you run commands as another user. It is similar to doas or sudo.

koyo is a cli tool that lets you run commands as another user. It is similar to doas or sudo.

null 3 Nov 27, 2021
A Garry's Mod module that lets you check which fonts are available on the system

gm_fontsx Since apparently we're never getting a proper way to check for installed fonts on Garry's Mod, this has to exist ?? Usage require("fontsx")

Earu 4 Mar 14, 2022
ISG lets you use YouTube as cloud storage for ANY files, not just video

I was working on this instead of my finals, hope you appreciate it. I'll add all relevant executables when I can Infinite-Storage-Glitch AKA ISG (writ

HistidineDwarf 3.6k Feb 23, 2023
⚡️(cd with env) Is a configurable cd wrapper that lets you define your environment per directory.

⚡️cdwe (cd with env) A simple configurable cd wrapper that provides powerful utilities for customizing your envionment per directory. (For ZSH / BASH

teo 20 Aug 6, 2023
An anyrun plugin that lets you search NixOS options.

anyrun-nixos-options An anyrun plugin that lets you search NixOS options. how 2 build? nix build ... or cargo build optionally :) Configuration This p

Michał 4 Aug 24, 2023