Skip to content

Failed to build as a dependency #87

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

Closed
pftbest opened this issue Oct 2, 2016 · 5 comments · Fixed by #155
Closed

Failed to build as a dependency #87

pftbest opened this issue Oct 2, 2016 · 5 comments · Fixed by #155

Comments

@pftbest
Copy link
Contributor

pftbest commented Oct 2, 2016

Added this to my Cargo.toml

[dependencies]
rustc_builtins = { git = "https://github.com/japaric/rustc-builtins" }

tried to compile using

RUST_BACKTRACE=1 xargo build --target=stm32f429zi --verbose

got this error

error: failed to run custom build command for `rustc_builtins v0.1.0 (https://github.com/japaric/rustc-builtins#89ebc46f)`
process didn't exit successfully: `/Users/vadzim/Downloads/rplayground/target/debug/build/rustc_builtins-c925dd23196c1b21/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=build.rs

--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ()', ../src/libcore/result.rs:799
stack backtrace:
   1:        0x109c560d8 - std::sys::backtrace::tracing::imp::write::h22f199c1dbb72ba2
   2:        0x109c5b56f - std::panicking::default_hook::{{closure}}::h9a389c462b6a22dd
   3:        0x109c5a605 - std::panicking::default_hook::h852b4223c1c00c59
   4:        0x109c5ab56 - std::panicking::rust_panic_with_hook::hcd9d05f53fa0dafc
   5:        0x109c5a9f4 - std::panicking::begin_panic::hf6c488cee66e7f17
   6:        0x109c5a912 - std::panicking::begin_panic_fmt::hb0a7126ee57cdd27
   7:        0x109c5a877 - rust_begin_unwind
   8:        0x109c80c30 - core::panicking::panic_fmt::h9af671b78898cdba
   9:        0x109c05c01 - core::result::unwrap_failed::hb3293571464cc40d
  10:        0x109c01575 - <core::result::Result<T, E>>::unwrap::hebcc09568bcc73ba
  11:        0x109c0fa1a - build_script_build::main::hfbb6c5966e861548
  12:        0x109c5bb2a - __rust_maybe_catch_panic
  13:        0x109c5a146 - std::rt::lang_start::h14cbded5fe3cd915
  14:        0x109c10e69 - main

error: `cargo` process didn't exit successfully
@japaric
Copy link
Member

japaric commented Oct 2, 2016

Wow, this was very weird to debug. The actual error is that rustc --target stm32f429zi --print cfg gets called but errors with "can't find target stm32f429zi".

OK, here what seems to be happening: rustc-cfg shells out to rustc --print cfg --target $T to get the specification of target $T. rustc-builtins, in particular, uses rustc-cfg from its build script (build.rs). The thing is that Cargo calls the build script from the source directory of the crate where the build script originates from. So, the reason that rustc-builtins its working for thumb targets and not for your target is that there are thumb*.json files in the source directory of rustc-builtins and rustc-cfg is using those definitions rather than the definitions that are in $PWD, where the cargo/xargo command was called. This is obviously wrong. This also explains why it fails for the stm32f429zi target: rustc --print cfg --target stm32f429zi gets called from the source directory of rustc-builtins but there's no stm32f429zi.json in there.

This is actually a rustc-cfg bug when dealing with custom targets and build scripts but doesn't seem easy to fix. I don't think there is a way to retrieve the directory from where cargo build was called from a build script. cc @alexcrichton ^ ?

@pftbest For now, I think you can workaround this by setting the RUST_TARGET_PATH env variable to a directory and place stm32f429zi.json in there.

@FenrirWolf
Copy link

FenrirWolf commented Oct 3, 2016

Just chiming in that I got hit by this issue too.

@alexcrichton
Copy link
Member

I don't think there is a way to retrieve the directory from where cargo build was called from a build script. cc @alexcrichton ^ ?

Unfortunately no :(

@japaric
Copy link
Member

japaric commented Oct 3, 2016

@FenrirWolf Yeah, sorry. The solution right now is to export RUST_TARGET_PATH=/some/dir such that your target json is in $RUST_TARGET_PATH/3ds.json.

@japaric
Copy link
Member

japaric commented Oct 4, 2016

If you don't need the "C" cargo feature then you can use a "snapshot crate" that I've published on crates.io: compiler-builtins-snapshot. It doesn't have this problem with rustc-cfg because it doesn't depend on rustc-cfg. Ah, and if you need __aeabi_memcpy or similar you'll have to enable the "mempcy" feature of that snapshot crate.

phil-opp added a commit to embed-rs/embedded-rs that referenced this issue Jan 23, 2017
oli-obk added a commit to oli-obk/compiler-builtins that referenced this issue Apr 11, 2017
tgross35 pushed a commit to tgross35/compiler-builtins that referenced this issue Feb 23, 2025
87: implement log1p and log1pf r=japaric a=erikdesjardins

closes rust-lang#26, closes rust-lang#49

Co-authored-by: Erik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants