Skip to content
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

Make it possible to regenerate bindgen work #12

Closed
palfrey opened this issue Apr 4, 2020 · 9 comments
Closed

Make it possible to regenerate bindgen work #12

palfrey opened this issue Apr 4, 2020 · 9 comments
Assignees
Milestone

Comments

@palfrey
Copy link
Contributor

palfrey commented Apr 4, 2020

Currently this is hardcoded as https://github.com/infinyon/node-bindgen/blob/master/nj-sys/src/binding.rs with no docs/build.rs to redo it. It either needs some instructions on how to regenerate it, or ideally it gets rebuilt at build time.

@sehz
Copy link
Collaborator

sehz commented Apr 4, 2020

I will remove generated code from check-in. Will use build.rs to generate them at compile them.

@sehz sehz self-assigned this Apr 4, 2020
@sehz sehz modified the milestones: 2.0, 1.2 Apr 4, 2020
@sehz
Copy link
Collaborator

sehz commented Apr 4, 2020

Unfortunately, bindgen requires installation of LLVM which adds burden for developer. I will update instruction on how to regenerate manually at least.

@sehz
Copy link
Collaborator

sehz commented Apr 4, 2020

nj-sys crate now contain Makefile to re-generate binding.rs. let me know if this doesn't work

@palfrey
Copy link
Contributor Author

palfrey commented Apr 5, 2020

After doing brew install llvm and export PATH=/usr/local/opt/llvm/bin:$PATH I was able to run make generate successfully. However my binding.rs appears to be about half the size (38857 bytes vs. 60720). A copy of that is available at https://gist.github.com/palfrey/390e099f16c6774faa9063afa11829b7. Any ideas why the difference?

@sehz
Copy link
Collaborator

sehz commented Apr 5, 2020

What version of LLVM are you using? Existing binding.rs was generated using 9.0.0.1. When I tried using latest version 10.0, only difference is a single line with NAPI_VERSION. Also bindgen version is 0.52.

From looking at your binding.rs, it seems be missing Darwin pthread.

pub type __darwin_mbstate_t = __mbstate_t;
pub type __darwin_ptrdiff_t = ::std::os::raw::c_long;
pub type __darwin_size_t = ::std::os::raw::c_ulong;
pub type __darwin_va_list = __builtin_va_list;
pub type __darwin_wchar_t = ::std::os::raw::c_int;
pub type __darwin_rune_t = __darwin_wchar_t;
pub type __darwin_wint_t = ::std::os::raw::c_int;
pub type __darwin_clock_t = ::std::os::raw::c_ulong;
pub type __darwin_socklen_t = __uint32_t;
pub type __darwin_ssize_t = ::std::os::raw::c_long;
pub type __darwin_time_t = ::std::os::raw::c_long;
pub type __darwin_blkcnt_t = __int64_t;
pub type

Not sure if they are important. You can test binding.rs by running example test. Also be sure to generate binding.rs by

make generate

@palfrey
Copy link
Contributor Author

palfrey commented Apr 5, 2020

Last version I had installed with homebrew, which turns out to be 6.0.0. Probably worth documenting the version of LLVM used to generate binding.rs then?

@sehz
Copy link
Collaborator

sehz commented Apr 5, 2020

done. README.md updated with LLVM requirement

@palfrey
Copy link
Contributor Author

palfrey commented Apr 6, 2020

Retried with more modern LLVM. LGTM.

@sehz
Copy link
Collaborator

sehz commented Apr 6, 2020

closing

@sehz sehz closed this as completed Apr 6, 2020
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

2 participants