Skip to content

Build script failure hidden by dependency build failure #835

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
huonw opened this issue Nov 11, 2014 · 14 comments
Closed

Build script failure hidden by dependency build failure #835

huonw opened this issue Nov 11, 2014 · 14 comments
Labels
A-build-execution Area: anything dealing with executing the compiler A-diagnostics Area: Error and warning messages generated by Cargo itself.

Comments

@huonw
Copy link
Member

huonw commented Nov 11, 2014

# a/Cargo.toml
[package]

name = "a"
version = "0.0.1"
authors = []
build = "build.rs"

[dependencies.b]
path = "../b"
// a/build.rs
fn main() { std::os::set_exit_status(1) }
# b/Cargo.toml
[package]

name = "b"
version = "0.0.1"
authors = []
// b/src/lib.rs
invalid

Then in a:

cargo clean && cargo build 
   Compiling a v0.0.1 (file:///home/huon/projects/test-rust/tmp/a)
   Compiling b v0.0.1 (file:///home/huon/projects/test-rust/tmp/a)
/home/huon/projects/test-rust/tmp/b/src/lib.rs:1:1: 1:8 error: expected item, found `invalid`
/home/huon/projects/test-rust/tmp/b/src/lib.rs:1 invalid
                                                 ^~~~~~~
Build failed, waiting for other jobs to finish...
Could not compile `b`.

The user is probably certainly more interested in the build script failing to build/run than the dependency. @alexcrichton's suggested resolution of #832 would possibly resolve this automatically too.

@alexcrichton
Copy link
Member

This is actually ordering-dependent and relies on the fact that we capture build script output rather than printing it by default.

We probably shouldn't discard all extra output though.

@alexcrichton alexcrichton added the E-easy Experience: Easy label Nov 11, 2014
@alexcrichton alexcrichton added the A-diagnostics Area: Error and warning messages generated by Cargo itself. label Jan 14, 2015
@carols10cents carols10cents added the A-build-execution Area: anything dealing with executing the compiler label May 9, 2017
@marti1125
Copy link

@alexcrichton is It still open? I would like to contribute

@alexcrichton
Copy link
Member

@marti1125 I think this may have actually been fixed in the meantime, but if you'd like to add a test for this that'd be most welcome!

@marti1125
Copy link

@alexcrichton could you tell me more about the test please =D

@alexcrichton
Copy link
Member

Sure yeah, all of Cargo's tests live in tests/*.rs in this repository, and you'd probably just extend tests/build.rs for this. You can copy/paste from previous examples but the general idea is that a Cargo project is created and then you run cargo build, placing assertions on the output of Cargo and the exit status of the process.

@dwijnand
Copy link
Member

dwijnand commented May 6, 2018

I think this may have actually been fixed in the meantime

I think it hasn't, sadly.

It's also slightly bit-rot: I changed a/build.rs to the following instead:

fn main() { panic!("boom!"); }

The new output is fundamentally the same:

$ cargo clean && cargo build
   Compiling b v0.0.1 (file:///s/t-build-script-failure/b)
   Compiling a v0.0.1 (file:///s/t-build-script-failure/a)
error: expected one of `!` or `::`, found `<eof>`
 --> /s/t-build-script-failure/b/src/lib.rs:1:1
  |
1 | invalid
  | ^^^^^^^ expected one of `!` or `::` here

error: aborting due to previous error

error: Could not compile `b`.
warning: build failed, waiting for other jobs to finish...
error: build failed

How should the other failures be reported? With handle_error?

@alexcrichton
Copy link
Member

alexcrichton commented May 6, 2018

@dwijnand in your reproduction are you sure that the build script executed? It may be that the build script was only compiled, not run, in that example

@dwijnand
Copy link
Member

dwijnand commented May 7, 2018

Given build.rs:

fn main() {
    use std::fs::File;
    use std::io::prelude::*;

    let mut file = File::create("marker.txt").unwrap();
    file.write_all(b"Hi Alex!").unwrap();

    panic!("boom!");
}

Looks like it doesn't even run the build script!

17:40:35 $ cargo clean && cargo build
   Compiling a v0.0.1 (file:///s/t-build-script-failure/a)
   Compiling b v0.0.1 (file:///s/t-build-script-failure/b)
error: expected one of `!` or `::`, found `<eof>`
 --> /s/t-build-script-failure/b/src/lib.rs:1:1
  |
1 | invalid
  | ^^^^^^^ expected one of `!` or `::` here

error: aborting due to previous error

error: Could not compile `b`.
warning: build failed, waiting for other jobs to finish...
error: build failed

17:40:54 ! cat marker.txt
cat: marker.txt: No such file or directory

in that example

Am I not accurately reproducing the reported issue? Maybe I've misunderstood some part of it.

@alexcrichton
Copy link
Member

@dwijnand oh if you execute cargo build -v you can see:

   Compiling b v0.1.0 (file:///home/alex/code/cargo-vendor/a/b)
   Compiling a v0.1.0 (file:///home/alex/code/cargo-vendor/a)
     Running `rustc --crate-name b b/src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=159cd516bfae43d6 -C extra-filename=-159cd516bfae43d6 --out-dir /home/alex/code/cargo-vendor/a/target/debug/deps -C incremental=/home/alex/code/cargo-vendor/a/target/debug/incremental -L dependency=/home/alex/code/cargo-vendor/a/target/debug/deps`
     Running `rustc --crate-name build_script_build build.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=9c9757b7d885b49f -C extra-filename=-9c9757b7d885b49f --out-dir /home/alex/code/cargo-vendor/a/target/debug/build/a-9c9757b7d885b49f -C incremental=/home/alex/code/cargo-vendor/a/target/debug/incremental -L dependency=/home/alex/code/cargo-vendor/a/target/debug/deps`
error: expected one of `!` or `::`, found `<eof>`
 --> b/src/lib.rs:1:1
  |
1 | ix
  | ^^ expected one of `!` or `::` here

error: aborting due to previous error

error: Could not compile `b`.

Caused by:
  process didn't exit successfully: `rustc --crate-name b b/src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=159cd516bfae43d6 -C extra-filename=-159cd516bfae43d6 --out-dir /home/alex/code/cargo-vendor/a/target/debug/deps -C incremental=/home/alex/code/cargo-vendor/a/target/debug/incremental -L dependency=/home/alex/code/cargo-vendor/a/target/debug/deps` (exit code: 101)
warning: build failed, waiting for other jobs to finish...
error: build failed

where the build script wasn't even executed here, it was just compiled

@dwijnand
Copy link
Member

dwijnand commented May 8, 2018

So where does this leave this issue?

I thought the whole premise is that the build script failure should be output. But if it doesn't even run..

@alexcrichton
Copy link
Member

@dwijnand oh I think this has since been basically fixed, although it may not be easily testable. Cargo will stop running commands as soon as one fails, which is why you're not seeing the build script output

@dwijnand
Copy link
Member

dwijnand commented May 8, 2018

Oh I see!

Then I'll leave this one as is. (and suggest dropping E-easy)

@alexcrichton alexcrichton removed the E-easy Experience: Easy label May 8, 2018
@AchalaSB
Copy link

Im trying to build cargo but got an error
Need help! Thanks in advance

achala@laptop:~/GIT/mir2wasm$ cargo build
Compiling mir2wasm v0.1.0 (file:///home/achala/GIT/mir2wasm)
error: failed to run custom build command for mir2wasm v0.1.0 (file:///home/achala/GIT/mir2wasm)
process didn't exit successfully: /home/achala/GIT/mir2wasm/target/debug/build/mir2wasm-4f880614b2dd408e/build-script-build (exit code: 101)
--- stdout
running: "cmake" "/home/achala/GIT/mir2wasm/binaryen" "-DBUILD_STATIC_LIB=ON" "-DCMAKE_INSTALL_PREFIX=/home/achala/GIT/mir2wasm/target/debug/build/mir2wasm-cadbd25f2f277410/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC-m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_BUILD_TYPE=Debug"
-- Building with -std=c++11
-- Building with -msse2
-- Building with -mfpmath=sse
-- Building with -Wall
-- Building with -Werror
-- Building with -Wextra
-- Building with -Wno-unused-parameter
-- Building with -fno-omit-frame-pointer
-- Building with -fPIC
-- Building with -O0
-- Building with -g3
-- Configuring done
-- Generating done
-- Build files have been written to: /home/achala/GIT/mir2wasm/target/debug/build/mir2wasm-cadbd25f2f277410/out/build
running: "cmake" "--build" "." "--target" "install" "--config" "Debug" "--"
[ 7%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/optimizer-shared.cpp.o
[ 7%] Building CXX object src/asmjs/CMakeFiles/asmjs.dir/shared-constants.cpp.o
[ 14%] Built target wasm
[ 14%] Built target ast
[ 15%] Building CXX object src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/parser.cpp.o
[ 56%] Built target passes
[ 57%] Building CXX object src/support/CMakeFiles/support.dir/threads.cpp.o
src/asmjs/CMakeFiles/asmjs.dir/build.make:86: recipe for target 'src/asmjs/CMakeFiles/asmjs.dir/shared-constants.cpp.o' failed
CMakeFiles/Makefile2:430: recipe for target 'src/asmjs/CMakeFiles/asmjs.dir/all' failed
src/support/CMakeFiles/support.dir/build.make:206: recipe for target 'src/support/CMakeFiles/support.dir/threads.cpp.o' failed
CMakeFiles/Makefile2:595: recipe for target 'src/support/CMakeFiles/support.dir/all' failed
src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/build.make:86: recipe for target 'src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/parser.cpp.o' failed
src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/build.make:62: recipe for target 'src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/optimizer-shared.cpp.o' failed
CMakeFiles/Makefile2:485: recipe for target 'src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/all' failed
Makefile:129: recipe for target 'all' failed

--- stderr
In file included from /home/achala/GIT/mir2wasm/binaryen/src/emscripten-optimizer/istring.h:32:0,
from /home/achala/GIT/mir2wasm/binaryen/src/asmjs/shared-constants.h:20,
from /home/achala/GIT/mir2wasm/binaryen/src/asmjs/shared-constants.cpp:17:
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:51:8: error: ‘function’ in namespace ‘std’ does not name a template type
std::function<ThreadWorkState ()> doWork = nullptr;
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:59:18: error: ‘std::function’ has not been declared
void work(std::function<ThreadWorkState ()> doWork);
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:59:26: error: expected ‘,’ or ‘...’ before ‘<’ token
void work(std::function<ThreadWorkState ()> doWork);
^
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: error: ‘function’ is not a member of ‘std’
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: note: suggested alternative: ‘is_function’
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~~~~~~~
is_function
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: error: ‘function’ is not a member of ‘std’
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: note: suggested alternative: ‘is_function’
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~~~~~~~
is_function
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:56: error: template argument 1 is invalid
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:56: error: template argument 2 is invalid
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:57: error: expected ‘,’ or ‘...’ before ‘>’ token
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~
In file included from /home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:23:0:
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:51:8: error: ‘function’ in namespace ‘std’ does not name a template type
std::function<ThreadWorkState ()> doWork = nullptr;
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:59:18: error: ‘std::function’ has not been declared
void work(std::function<ThreadWorkState ()> doWork);
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:59:26: error: expected ‘,’ or ‘...’ before ‘<’ token
void work(std::function<ThreadWorkState ()> doWork);
^
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: error: ‘function’ is not a member of ‘std’
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: note: suggested alternative: ‘is_function’
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~~~~~~~
is_function
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: error: ‘function’ is not a member of ‘std’
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: note: suggested alternative: ‘is_function’
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~~~~~~~
is_function
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:56: error: template argument 1 is invalid
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:56: error: template argument 2 is invalid
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:57: error: expected ‘,’ or ‘...’ before ‘>’ token
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:65:24: error: variable or field ‘work’ declared void
void Thread::work(std::function<ThreadWorkState ()> doWork_) {
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:65:24: error: ‘function’ is not a member of ‘std’
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:65:24: note: suggested alternative: ‘is_function’
void Thread::work(std::function<ThreadWorkState ()> doWork_) {
^~~~~~~~
is_function
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:65:53: error: ‘doWork_’ was not declared in this scope
void Thread::work(std::function<ThreadWorkState ()> doWork_) {
^~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp: In static member function ‘static void wasm::Thread::mainLoop(void*)’:
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:83:17: error: ‘class wasm::Thread’ has no member named ‘doWork’; did you mean ‘work’?
if (self->doWork) {
^~~~~~
work
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:86:22: error: ‘class wasm::Thread’ has no member named ‘doWork’; did you mean ‘work’?
while (self->doWork() == ThreadWorkState::More) {}
^~~~~~
work
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:87:15: error: ‘class wasm::Thread’ has no member named ‘doWork’; did you mean ‘work’?
self->doWork = nullptr;
^~~~~~
work
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:96:33: error: ‘class wasm::Thread’ has no member named ‘doWork’; did you mean ‘work’?
if (!self->done && !self->doWork) {
^~~~~~
work
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp: At global scope:
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:137:40: error: ‘function’ is not a member of ‘std’
void ThreadPool::work(std::vector<std::function<ThreadWorkState ()>>& doWorkers) {
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:137:40: note: suggested alternative: ‘is_function’
void ThreadPool::work(std::vector<std::function<ThreadWorkState ()>>& doWorkers) {
^~~~~~~~
is_function
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:137:40: error: ‘function’ is not a member of ‘std’
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:137:40: note: suggested alternative: ‘is_function’
void ThreadPool::work(std::vector<std::function<ThreadWorkState ()>>& doWorkers) {
^~~~~~~~
is_function
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:137:66: error: template argument 1 is invalid
void ThreadPool::work(std::vector<std::function<ThreadWorkState ()>>& doWorkers) {
^
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:137:66: error: template argument 2 is invalid
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:137:28: error: variable or field ‘work’ declared void
void ThreadPool::work(std::vector<std::function<ThreadWorkState ()>>& doWorkers) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.cpp:137:71: error: ‘doWorkers’ was not declared in this scope
void ThreadPool::work(std::vector<std::function<ThreadWorkState ()>>& doWorkers) {
^~~~~~~~~
make[2]: *** [src/asmjs/CMakeFiles/asmjs.dir/shared-constants.cpp.o] Error 1
make[1]: *** [src/asmjs/CMakeFiles/asmjs.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /home/achala/GIT/mir2wasm/binaryen/src/emscripten-optimizer/istring.h:32:0,
from /home/achala/GIT/mir2wasm/binaryen/src/emscripten-optimizer/parser.h:31,
from /home/achala/GIT/mir2wasm/binaryen/src/emscripten-optimizer/parser.cpp:17:
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:51:8: error: ‘function’ in namespace ‘std’ does not name a template type
std::function<ThreadWorkState ()> doWork = nullptr;
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:59:18: error: ‘std::function’ has not been declared
void work(std::function<ThreadWorkState ()> doWork);
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:59:26: error: expected ‘,’ or ‘...’ before ‘<’ token
void work(std::function<ThreadWorkState ()> doWork);
^
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: error: ‘function’ is not a member of ‘std’
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~~~~~~~
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: note: suggested alternative: ‘is_function’
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~~~~~~~
is_function
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: error: ‘function’ is not a member of ‘std’
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:30: note: suggested alternative: ‘is_function’
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~~~~~~~
is_function
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:56: error: template argument 1 is invalid
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:56: error: template argument 2 is invalid
/home/achala/GIT/mir2wasm/binaryen/src/support/threads.h:93:57: error: expected ‘,’ or ‘...’ before ‘>’ token
void work(std::vector<std::function<ThreadWorkState ()>>& doWorkers);
^~
make[2]: *** [src/support/CMakeFiles/support.dir/threads.cpp.o] Error 1
make[1]: *** [src/support/CMakeFiles/support.dir/all] Error 2
make[2]: *** [src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/parser.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/achala/GIT/mir2wasm/binaryen/src/emscripten-optimizer/optimizer-shared.cpp: In function ‘AsmSign detectSign(cashew::Ref, cashew::IString)’:
/home/achala/GIT/mir2wasm/binaryen/src/emscripten-optimizer/optimizer-shared.cpp:157:9: error: this statement may fall through [-Werror=implicit-fallthrough=]
if (op == TRSHIFT) return ASM_UNSIGNED;
^~
/home/achala/GIT/mir2wasm/binaryen/src/emscripten-optimizer/optimizer-shared.cpp:160:7: note: here
case '|': case '&': case '^': case '<': case '=': case '!': return ASM_SIGNED;
^~~~
cc1plus: all warnings being treated as errors
make[2]: *** [src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/optimizer-shared.cpp.o] Error 1
make[1]: *** [src/emscripten-optimizer/CMakeFiles/emscripten-optimizer.dir/all] Error 2
make: *** [all] Error 2
thread '' panicked at '
command did not execute successfully, got: exit code: 2

build script failed, must exit now', /home/achala/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.33/src/lib.rs:773:5
note: Run with RUST_BACKTRACE=1 for a backtrace.
thread 'main' panicked at 'called Result::unwrap() on an Err value: Any', libcore/result.rs:945:5

@ehuss
Copy link
Contributor

ehuss commented Mar 31, 2019

I'm going to close this, I don't think there is anything to do here. What happens depends on what is being built, and in both cases I think Cargo does the right thing. I don't think a test would be helpful here.

The dependency graph looks like:

build-a
  │
  ├──> build-b
  │
  └──> run script-a ──> build script-a

In a clean state, build-b and build-script-a will run at the same time. If it fails fast enough, then the build script never gets a chance to run. If the build script is already built (or build-b takes a long time to fail), then build-b and run script-a run at the same time, and you get both errors displayed.

@ehuss ehuss closed this as completed Mar 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-execution Area: anything dealing with executing the compiler A-diagnostics Area: Error and warning messages generated by Cargo itself.
Projects
None yet
Development

No branches or pull requests

7 participants