Skip to content

thread 'main' panicked at 'TranslationUnit::parse', ../src/libcore/option.rs:715 #340

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
bbigras opened this issue Dec 14, 2016 · 7 comments

Comments

@bbigras
Copy link

bbigras commented Dec 14, 2016

not sure if related to #249

rustc 1.15.0-nightly (daf8c1dfc 2016-12-05)
libbindgen = "0.1.2"
clang 3.9.0-3
Arch Linux 64-bit

wrapper.hpp

#include <opencv2/core/core.hpp>

build.rs

extern crate libbindgen;

use std::env;
use std::path::PathBuf;

fn main() {
    println!("cargo:rustc-link-lib=opencv_core");

    let bindings = libbindgen::Builder::default()
        .clang_arg("-x=c++")
        .header("wrapper.hpp")
        .generate()
        .expect("Unable to generate bindings");

    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
    bindings.write_to_file(out_path.join("bindings.rs"))
        .expect("Couldn't write bindings!");
}

$ cargo build
Compiling opencv v0.1.0 (file:///home/bbigras/dev/rust/rs-opencv)
error: failed to run custom build command for opencv v0.1.0 (file:///home/bbigras/dev/rust/rs-opencv)
process didn't exit successfully: /home/bbigras/dev/rust/rs-opencv/target/debug/build/opencv-bf020cc2abd762ca/build-script-build (exit code: 101)
--- stdout
cargo:rustc-link-lib=opencv_core

--- stderr
thread 'main' panicked at 'TranslationUnit::parse', ../src/libcore/option.rs:715
note: Run with RUST_BACKTRACE=1 for a backtrace.

@fitzgen
Copy link
Member

fitzgen commented Dec 14, 2016

@BrunoQC thanks for the bug report!

Would you mind running again with RUST_LOG=libbindgen and RUST_BACKTRACE=1 set? and attaching the output here?

@bbigras
Copy link
Author

bbigras commented Dec 14, 2016

$ RUST_LOG=libbindgen RUST_BACKTRACE=1 cargo build
   Compiling opencv v0.1.0 (file:///home/bbigras/dev/rust/rs-opencv)
error: failed to run custom build command for `opencv v0.1.0 (file:///home/bbigras/dev/rust/rs-opencv)`
process didn't exit successfully: `/home/bbigras/dev/rust/rs-opencv/target/debug/build/opencv-bf020cc2abd762ca/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-lib=opencv_core

--- stderr
thread 'main' panicked at 'TranslationUnit::parse', ../src/libcore/option.rs:715
stack backtrace:
   1:     0x5641cc2cd1ba - std::sys::imp::backtrace::tracing::imp::write::hbea47d9dd19b523c
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x5641cc2d1a9f - std::panicking::default_hook::{{closure}}::h6875a2976258b020
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:247
   3:     0x5641cc2d169e - std::panicking::default_hook::h88ffbc5922643264
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:263
   4:     0x5641cc2d1ee7 - std::panicking::rust_panic_with_hook::hc790e47d4ecc86cd
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:451
   5:     0x5641cc2d1d74 - std::panicking::begin_panic::hc066339e2fdc17d1
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:413
   6:     0x5641cc2d1c99 - std::panicking::begin_panic_fmt::h5912b2d2df332044
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:397
   7:     0x5641cc2d1c27 - rust_begin_unwind
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:373
   8:     0x5641cc30ee3d - core::panicking::panic_fmt::h561c5ee168a3d2cb
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libcore/panicking.rs:69
   9:     0x5641cc30eead - core::option::expect_failed::h6be288f6c3caa41a
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libcore/option.rs:715
  10:     0x5641cbd11eb0 - <core::option::Option<T>>::expect::hf442c9df50d2b840
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libcore/option.rs:293
  11:     0x5641cbe2e538 - libbindgen::ir::context::BindgenContext::new::h0d0e42f902f4e166
                        at /home/bbigras/.cargo/registry/src/jiasu.xzqcsaa.nyc.mn-1ecc6299db9ec823/libbindgen-0.1.2/src/ir/context.rs:134
  12:     0x5641cbe5034c - libbindgen::Bindings::generate::hc9788d9682ec912c
                        at /home/bbigras/.cargo/registry/src/jiasu.xzqcsaa.nyc.mn-1ecc6299db9ec823/libbindgen-0.1.2/src/lib.rs:535
  13:     0x5641cbe4f5f5 - libbindgen::Builder::generate::h0a2dd1c7707752ae
                        at /home/bbigras/.cargo/registry/src/jiasu.xzqcsaa.nyc.mn-1ecc6299db9ec823/libbindgen-0.1.2/src/lib.rs:350
  14:     0x5641cbcd50a3 - build_script_build::main::h95698c9937afe21a
                        at /home/bbigras/dev/rust/rs-opencv/build.rs:9
  15:     0x5641cc2da99a - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libpanic_unwind/lib.rs:97
  16:     0x5641cc2d272a - std::rt::lang_start::h5d71a3afaaa4b2ff
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panicking.rs:332
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/panic.rs:351
                        at /buildslave/rust-buildbot/slave/nightly-dist-rustc-linux/build/obj/../src/libstd/rt.rs:57
  17:     0x5641cbcd5292 - main
  18:     0x7f98dc9bc290 - __libc_start_main
  19:     0x5641cbcb7db9 - _start
  20:                0x0 - <unknown>

@emilio
Copy link
Contributor

emilio commented Dec 14, 2016

That happens when the file doesn't exist. Arguably we should be able to provide a better error here. Presumably the file is called wrapper.h and you're invoking bindgen with wrapper.hpp, or viceversa?

@bbigras
Copy link
Author

bbigras commented Dec 14, 2016

Sorry, my wrapper is called wrapper.hpp. I copy pasted the name from the other bug report.

@bbigras
Copy link
Author

bbigras commented Dec 15, 2016

I don't have the parse problem if I remove the clang_arg().

@emilio
Copy link
Contributor

emilio commented Dec 15, 2016

Oh, what happens if you do: .clang_arg("-x").clang_arg("c++")? Shouldn't be needed if the wrapper is already an hpp file, but I think that -x=c++ is an invalid argument for clang.

@bbigras
Copy link
Author

bbigras commented Dec 15, 2016

I don't have the problem with .clang_arg("-x").clang_arg("c++"). Thanks.

@bbigras bbigras closed this as completed Dec 15, 2016
roblabla added a commit to roblabla/rust-bindgen that referenced this issue Jul 17, 2017
When using -x=c++ in bindgen arguments, we hit rust-lang#340. We should use -x c++ instead.
bors-servo pushed a commit that referenced this issue Jul 17, 2017
Document -x c++, not -x=c++

When using -x=c++ in bindgen arguments, we hit #340. We should use -x c++ instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants