facebookincubator / below

A time traveling resource monitor for modern Linux systems
Apache License 2.0
1.08k stars 61 forks source link

build-failed : thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value #8131

Open bhzhu203 opened 2 years ago

bhzhu203 commented 2 years ago

''' Compiling below v0.5.0 (/home/bhzhu/source/below/below) error: failed to run custom build command for below v0.5.0 (/home/bhzhu/source/below/below)

Caused by: process didn't exit successfully: /home/bhzhu/source/below/target/release/build/below-718216cef9c31e46/build-script-build (exit status: 101) --- stderr thread 'main' panicked at 'called Result::unwrap() on an Err value: Build("Failed to run regex on version string")', below/build.rs:19:47 stack backtrace: 0: 0x5555557ee5ec - std::backtrace_rs::backtrace::libunwind::trace::h26ded3cee286f9ec at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x5555557ee5ec - std::backtrace_rs::backtrace::trace_unsynchronized::h830d548378790fdc at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x5555557ee5ec - std::sys_common::backtrace::_print_fmt::h7356e27371ec940d at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/sys_common/backtrace.rs:66:5 3: 0x5555557ee5ec - ::fmt::h3da18fd93237a444 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/sys_common/backtrace.rs:45:22 4: 0x555555810c3c - core::fmt::write::h1b11e7c3b9f52b83 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/core/src/fmt/mod.rs:1190:17 5: 0x5555557ea318 - std::io::Write::write_fmt::h2530d62e754fd8dc at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/io/mod.rs:1657:15 6: 0x5555557f0657 - std::sys_common::backtrace::_print::ha001eea1f09df837 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/sys_common/backtrace.rs:48:5 7: 0x5555557f0657 - std::sys_common::backtrace::print::he19aad5eb563cdb7 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/sys_common/backtrace.rs:35:9 8: 0x5555557f0657 - std::panicking::default_hook::{{closure}}::h4bec003d220dffc8 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panicking.rs:295:22 9: 0x5555557f031f - std::panicking::default_hook::hbf9de44b5ceb445d at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panicking.rs:314:9 10: 0x5555557f0dba - std::panicking::rust_panic_with_hook::hba49b95df3772ed5 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panicking.rs:698:17 11: 0x5555557f0aa7 - std::panicking::begin_panic_handler::{{closure}}::he9fc0b4286f77c60 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panicking.rs:588:13 12: 0x5555557eea94 - std::sys_common::backtrace::rust_end_short_backtrace::h07791585b84f81da at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/sys_common/backtrace.rs:138:18 13: 0x5555557f07a9 - rust_begin_unwind at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panicking.rs:584:5 14: 0x5555555b9c13 - core::panicking::panic_fmt::he8540b011fb85aaa at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/core/src/panicking.rs:143:14 15: 0x5555555b9ca3 - core::result::unwrap_failed::h5b5a61b4f1a3fe39 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/core/src/result.rs:1749:5 16: 0x5555555babe2 - core::result::Result<T,E>::unwrap::hbd8ff0f689370095 17: 0x5555555bcb7a - build_script_build::main::h64c087248aa8d4af 18: 0x5555555bb2c3 - core::ops::function::FnOnce::call_once::h3fe4fb01b7d47e7e 19: 0x5555555bb509 - std::sys_common::backtrace::rust_begin_short_backtrace::h4b18e62f18ccc92a 20: 0x5555555bcac9 - std::rt::lang_start::{{closure}}::hf32d562c9a5ca0c2 21: 0x5555557edcd1 - core::ops::function::impls::<impl core::ops::function::FnOnce for &F>::call_once::hb16268c89c211835 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/core/src/ops/function.rs:259:13 22: 0x5555557edcd1 - std::panicking::try::do_call::h42af4c24be01d864 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panicking.rs:492:40 23: 0x5555557edcd1 - std::panicking::try::hcddad39c2668977b at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panicking.rs:456:19 24: 0x5555557edcd1 - std::panic::catch_unwind::h17be4d22360f6801 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panic.rs:137:14 25: 0x5555557edcd1 - std::rt::lang_start_internal::{{closure}}::he399a7bc5b46d1ed at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/rt.rs:128:48 26: 0x5555557edcd1 - std::panicking::try::do_call::he22e88faa301e128 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panicking.rs:492:40 27: 0x5555557edcd1 - std::panicking::try::h179e28dc63c29e66 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panicking.rs:456:19 28: 0x5555557edcd1 - std::panic::catch_unwind::h926c540a0059105b at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/panic.rs:137:14 29: 0x5555557edcd1 - std::rt::lang_start_internal::hcf3b4e612381f709 at /rustc/09cb29c64c2a0e15debf2d6fca2bc7c71a682033/library/std/src/rt.rs:128:20 30: 0x5555555bcab1 - std::rt::lang_start::hfb5e709917bc1f4e 31: 0x5555555bcc43 - main 32: 0x7ffff6f1f50d - __libc_start_main at /home/bhzhu/source/glibc-2.33/csu/../csu/libc-start.c:332:16 33: 0x5555555ba43a - _start at /home/bhzhu/source/glibc-2.33/csu/../sysdeps/x86_64/start.S:120 34: 0x0 - warning: build failed, waiting for other jobs to finish... error: build failed '''

bhzhu203 commented 2 years ago

bash-4.3$ cargo --version cargo 1.60.0-nightly (c082648 2022-02-08)

bash-4.3$ rustc --version rustc 1.60.0-nightly (09cb29c64 2022-02-15)

brianc118 commented 2 years ago

The custom build command is failing to extract clang version with this function: https://github.com/libbpf/libbpf-rs/blob/master/libbpf-cargo/src/build.rs#L33

Can you show the output of clang --version on your system?

bhzhu203 commented 2 years ago

The custom build command is failing to extract clang version with this function: https://github.com/libbpf/libbpf-rs/blob/master/libbpf-cargo/src/build.rs#L33

Can you show the output of clang --version on your system?

clang --version clang (GCC) 10.2.0 Copyright © 2020 Free Software Foundation, Inc.

brianc118 commented 2 years ago

Yeah that definitely fails on the regex: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=73762a6c7452f51f289cbfe5f0c580bc

bhzhu203 commented 2 years ago

So how to fix this issue? Thanks

brianc118 commented 2 years ago

I'll try to put out a fix for this in the next few days. I won't bump the version for below though as this only affects the build script.

brianc118 commented 2 years ago

@bhzhu203 which Linux distribution are you on? Would be helpful to document and understand the differences.

I'm surprised at the output of clang --version as it should usually show something like:

Ubuntu clang version 11.0.0-++20200916113328+8f2c29681ce-1~exp1~20200916094014.99
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
bhzhu203 commented 2 years ago

Hello . I am using LFS for years , not any of a distribution . I followed the document from the BLFS.

https://www.linuxfromscratch.org/blfs/view/svn/general/llvm.html

EGQM commented 2 years ago

I get the same error:

error: failed to run custom build command for `below v0.5.0`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installNdwkIq/release/build/below-4a107ec4e84fce69/build-script-build` (exit status: 101)
  --- stderr
  Warning: unrecognized map: .maps
  Warning: unrecognized map: license
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Generate("Failed to generate skeleton for /tmp/.tmpI39P8c/exitstat.o: Failed to spawn rustfmt")', /home/lu/.cargo/registry/src/github.com-1ecc6299db9ec823/below-0.5.0/build.rs:19:47
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `below v0.5.0`, intermediate artifacts can be found at `/tmp/cargo-installNdwkIq`

Caused by:
  build failed

my system is ubuntu22.04,and the clang version is:

Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
EGQM commented 2 years ago

I fixed it after installed rustfmt:

sudo apt install rustfmt