New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`cargo package` and `cargo publish` fail with custom target triples #3119

Closed
jamesmunns opened this Issue Sep 26, 2016 · 9 comments

Comments

Projects
None yet
4 participants
@jamesmunns
Copy link
Member

jamesmunns commented Sep 26, 2016

Hey all, I was attempting to publish a crate that targets an ARM Cortex-M micro controller, and received the following errors:

➜  teensy3-sys git:(master) cargo package --verbose
   Packaging teensy3-sys v0.1.0 (file:///Users/jamesmunns/Git/teensy3-rs/teensy3-sys)
   Archiving bindings.h
   ...
   Archiving teensy3-core/yield.cpp
   Verifying teensy3-sys v0.1.0 (file:///Users/jamesmunns/Git/teensy3-rs/teensy3-sys)
error: failed to verify package tarball

Caused by:
  failed to run `rustc` to learn about target-specific information

Caused by:
  Process didn't exit successfully: `rustc - --crate-name _ --print=file-names --crate-type bin --crate-type rlib --target thumbv7em-none-eabi` (exit code: 101)
--- stderr
error: Error loading target specification: Could not find specification for target "thumbv7em-none-eabi"
  |
  = help: Use `--print target-list` for a list of built-in targets

This can be reproduced by cloning https://github.com/jamesmunns/teensy3-rs, cd teensy3-sys, then cargo package --verbose.

I was able to then publish with cargo package --verbose --no-verify, but I would expect that cargo should follow the specification in .cargo/config (up one directory). I also tried copying the .cargo folder to the teensy3-sys folder, but no change in behavior.

Cargo publish behaves the same with a similar failure.

CC @SimonSapin

@jamesmunns

This comment has been minimized.

Copy link
Member

jamesmunns commented Sep 26, 2016

Version information:

➜  teensy3-sys git:(master) ✗ cargo --version
cargo 0.13.0-nightly (9399229 2016-09-14)
➜  teensy3-sys git:(master) ✗ rustc --version
rustc 1.13.0-nightly (4f9812a59 2016-09-21)
@japaric

This comment has been minimized.

Copy link
Member

japaric commented Sep 26, 2016

Hmm, why is the packaging for the thumb target? Do you have a .cargo/config with build.target set to the thumb target? Some ideas you could try:

  • Try to package for the host i.e. remove the default target from the .cargo/config. This may fail because non-x86 asm! and what not.
  • Put the thumb target specification (the .json file) somewhere, point to that directory using RUST_TARGET_PATH (let me check that env var yes, that's the right one) i.e. export that variable and try to package using xargo package with the default target set to the thumb target.
@japaric

This comment has been minimized.

Copy link
Member

japaric commented Sep 26, 2016

All this would probably just work if the thumb targets were built-in targets! cc @alexcrichton @brson

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Sep 27, 2016

Thanks for the report! I think @japaric is right in that this is picking up .cargo/config to set the target, so you can work around this for now with cargo publish --no-verify. Also agreed that we should probably just ignore that configuration when publishing!

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Sep 27, 2016

This may not be too hard to tackle, but I'm not gonna tag E-easy yet as I'm not certain of the resolution.

@japaric

This comment has been minimized.

Copy link
Member

japaric commented Sep 27, 2016

@alexcrichton OTOH, this crate is meant to only ever by compiled for a certain embedded ARM target so it doesn't make sense to verify by compiling the crate for the host because the compilation will likely fail.

What I'm getting at is that there is an use case for "verify against this TARGET and not against the HOST" and picking up that target from .cargo/config seems reasonable but perhaps should be more explicit: Normally you would use cargo publish --target $T but if it picks up .cargo/config then show a warning/message saying "packaging/verifying for/against $T".

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Sep 28, 2016

@japaric ah yeah that's a good point! Seems reasonable to me then that we shouldn't ignore it and should just indicate that we're verifying against that.

In any case @jamesmunns I think the issue here is that the cwd is different on cargo publish and on cargo build. The custom target spec is then not picked up as part of cargo publish, unfortunately.

@jamesmunns

This comment has been minimized.

Copy link
Member

jamesmunns commented Oct 16, 2016

@japaric and @alexcrichton I can verify that this is fixed, at least as of the latest nightly (at least with my specific target triple, since it is now included).

There may be a desire long-term to support arbitrary target-triples, but I am not sure what the effort is. For now, I am happy :)

➜  teensy3 git:(master) cargo package            
   Packaging teensy3 v0.1.3 (file:///Users/jamesmunns/Git/clean_test/teensy3-rs/teensy3)
   Verifying teensy3 v0.1.3 (file:///Users/jamesmunns/Git/clean_test/teensy3-rs/teensy3)
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling teensy3-sys v0.1.0
   Compiling teensy3 v0.1.3 (file:///Users/jamesmunns/Git/clean_test/teensy3-rs/teensy3/target/package/teensy3-0.1.3)
    Finished debug [unoptimized + debuginfo] target(s) in 1.28 secs
➜  teensy3 git:(master) cargo publish
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Packaging teensy3 v0.1.3 (file:///Users/jamesmunns/Git/clean_test/teensy3-rs/teensy3)
   Verifying teensy3 v0.1.3 (file:///Users/jamesmunns/Git/clean_test/teensy3-rs/teensy3)
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling teensy3-sys v0.1.0
   Compiling teensy3 v0.1.3 (file:///Users/jamesmunns/Git/clean_test/teensy3-rs/teensy3/target/package/teensy3-0.1.3)
    Finished debug [unoptimized + debuginfo] target(s) in 1.15 secs
   Uploading teensy3 v0.1.3 (file:///Users/jamesmunns/Git/clean_test/teensy3-rs/teensy3)
➜  teensy3 git:(master) rustc --version
rustc 1.14.0-nightly (098d22845 2016-10-13)
➜  teensy3 git:(master) cargo --version
cargo 0.13.0-nightly (5f2cc15 2016-10-13)
@carols10cents

This comment has been minimized.

Copy link
Member

carols10cents commented Sep 26, 2017

I can verify that this is fixed, at least as of the latest nightly (at least with my specific target triple, since it is now included).

There may be a desire long-term to support arbitrary target-triples, but I am not sure what the effort is. For now, I am happy :)

I'm going to close this, since as far as I can tell there has been no desire expressed to support arbitrary target-triples :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment