Skip to content

Unable to build rust torch bindings https://github.com/posix4e/rust-torch #1154

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
posix4e opened this issue Nov 17, 2017 · 7 comments

Comments

@posix4e
Copy link

posix4e commented Nov 17, 2017

Input C/C++ Header

#include "TH/TH.h"

We actually generate it.

bindgen --no-derive-debug --builtins tmp/expanded.h -o "$output"

Actual Results

Error { repr: Custom(Custom { kind: Other, error: StringError("Cannot find binary path") }) }
http://termbin.com/lgfd
http://termbin.com/d39u

Expected Results

I expected it to compile

@posix4e posix4e changed the title Unable to build rust torch bindings Unable to build rust torch bindings https://github.com/posix4e/rust-torch Nov 17, 2017
@posix4e
Copy link
Author

posix4e commented Nov 17, 2017

I tried it with an older version of bindgen and I didn't get an error when compiling but i still get an error when building

posi@posi:~/src/rust-torch$ cargo build
   Compiling torch v0.1.0 (file:///home/posi/src/rust-torch)
error: const fn is unstable (see issue #24111)
   --> src/lib.rs:420:5
    |
420 | /     pub const fn new_bitfield_1(__w_termsig: ::std::os::raw::c_uint,
421 | |                                 __w_coredump: ::std::os::raw::c_uint,
422 | |                                 __w_retcode: ::std::os::raw::c_uint) -> u32 {
423 | |         let bitfield_unit_val =
...   |
441 | |         bitfield_unit_val | __w_retcode
442 | |     }
    | |_____^

error: const fn is unstable (see issue #24111)
   --> src/lib.rs:498:5
    |
498 | /     pub const fn new_bitfield_1(__w_stopval: ::std::os::raw::c_uint,
499 | |                                 __w_stopsig: ::std::os::raw::c_uint) -> u32 {
500 | |         let bitfield_unit_val =
501 | |             {
...   |
511 | |         bitfield_unit_val | __w_stopsig
512 | |     }
    | |_____^

error: aborting due to previous error(s)

error: Could not compile `torch`.

@posix4e
Copy link
Author

posix4e commented Nov 17, 2017

Apparently with this old version of bindgen it works if i tell it not to generate unstable rust code. Should I leave this open?

@fitzgen
Copy link
Member

fitzgen commented Nov 17, 2017

Hi @posix4e, thanks for filing a bug. Can you provide a standalone version of the input header file? https://github.com/rust-lang-nursery/rust-bindgen/blob/master/CONTRIBUTING.md#using-creduce-to-minimize-test-cases

Without that, unfortunately, this this issue is not very actionable. Thanks!

@posix4e
Copy link
Author

posix4e commented Nov 17, 2017

@fitzgen the one line h file generated http://termbin.com/lgfd

@fitzgen
Copy link
Member

fitzgen commented Nov 17, 2017

@fitzgen the one line h file generated http://termbin.com/lgfd

The "one line h file" is an include of another header, which includes an unknown further number of headers, each of which include ... etc.

In order for this issue to be actionable, we need at minimum the header after the preprocessor runs and preferrably after running creduce as well. You can find instructions for producing these things in the link I gave above.

Thanks!

@XVilka
Copy link

XVilka commented Dec 19, 2017

@fitzgen I have the same error and ran a creduce on it, sadly it returns exactly the same file after a whole night of trying to reduce it. The file is https://github.com/radare/radare2/blob/master/libr/include/r_core.h This is my creduce predicate script:

CMD="bindgen --verbose /home/user/data/tmp/r_core.h -o /home/user/data/tmp/r2-api/r_core.rs -- -I/usr/local/include/libr"
OUT=$($CMD 3>&1 1>&2 2>&3)
EXPECT="Error { repr: Custom(Custom { kind: Other, error: StringError(\"Cannot find binary path\") }) }"

if [ "$OUT" == "$EXPECT" ]; then
	exit 0
else
	exit 1
fi

Here is the preprocessed file
__bindgen.i.gz

@XVilka
Copy link

XVilka commented Dec 29, 2017

@fitzgen should I open a separate bug for this radare2 case? Or it's fine here? Also creduce failed on this testcase, I sent them bugreport, they will check it.

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

No branches or pull requests

3 participants