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

Over 100 MB of warnings emitted during bindgen build #47

Closed
intgr opened this issue May 25, 2019 · 7 comments
Closed

Over 100 MB of warnings emitted during bindgen build #47

intgr opened this issue May 25, 2019 · 7 comments

Comments

@intgr
Copy link
Contributor

intgr commented May 25, 2019

When building the postgres.rs file generated by bindgen, lots and lots of warnings are emitted like the following:

warning: `extern` block uses type `u128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI
 --> .../target/debug/build/pg-extend-f7ddabc2586f2e23/out/postgres.rs:3:186600
  |
3 | # [ repr ( C ) ] # [ derive ( Copy ...

This is annoying because line number 3 contains all the code in the generated bindings file, multiplying its size, which results in console output of 183 MB! This can also hide other more relevant warnings.

I couldn't figure out a way to suppress this warning. But I don't understand why all the generated code is on one line, given that bindgen is instructed to use rustfmt:

    let bindings = bindgen::Builder::default()
        ...
        .rustfmt_bindings(true)

Do you have any idea why this is or should I contact bindgen upstream?

Any idea if there may be other solutions to this issue?

@bluejekyll
Copy link
Owner

bluejekyll commented May 25, 2019

Really? I haven’t noticed this. I have disabled a number of warnings, are you using this is some other way than the existing import done in the pg_sys module?

@intgr
Copy link
Contributor Author

intgr commented May 26, 2019

Apparently long double types are converted to u128 by bindgen: rust-lang/rust-bindgen#1549

But more curiously, the rustfmt issue only occurs on my macOS laptop. On Linux, the generated postgres.rs file is nicely formatted. The warnings are still slightly annoying but not nearly as much:

warning: `extern` block uses type `u128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI
    --> .../pg-extend-rs/target/debug/build/pg-extend-8694441f66e957e2/out/postgres.rs:6502:22
     |
6502 |     pub fn sinl(__x: u128) -> u128;
     |                      ^^^^

warning: `extern` block uses type `u128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI
    --> .../pg-extend-rs/target/debug/build/pg-extend-8694441f66e957e2/out/postgres.rs:6502:31
     |
6502 |     pub fn sinl(__x: u128) -> u128;
     |                               ^^^^

warning: `extern` block uses type `u128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI
    --> .../pg-extend-rs/target/debug/build/pg-extend-8694441f66e957e2/out/postgres.rs:6505:24
     |
6505 |     pub fn __sinl(__x: u128) -> u128;
     |                        ^^^^

warning: `extern` block uses type `u128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI
    --> .../pg-extend-rs/target/debug/build/pg-extend-8694441f66e957e2/out/postgres.rs:6505:33
     |
6505 |     pub fn __sinl(__x: u128) -> u128;
     |                                 ^^^^

Not knowing much about bindgen, my question is: why is it even generating stubs for functions that are in the C standard library, not PostgreSQL itself? Can that be avoided in the first place?

@bluejekyll
Copy link
Owner

I’m not actually sure about this. It might be possible to disable libc bindings being generated. The libc crate might be compatible with the bindgen types, but I haven’t done any investigation of this.

@glandium
Copy link

But I don't understand why all the generated code is on one line, given that bindgen is instructed to use rustfmt

What likely happens is that you don't have rustfmt installed, or it's not in you $PATH, but bindgen doesn't error out in that case. I had the same issue, fwiw, and filed both #1600 and rust-lang/rust#62999

@intgr
Copy link
Contributor Author

intgr commented Aug 5, 2019

Oh thanks a lot @glandium, that makes sense. This issue can be closed.

@intgr intgr closed this as completed Aug 5, 2019
@intgr
Copy link
Contributor Author

intgr commented Aug 5, 2019

For the record, link to bindgen issue too: rust-lang/rust-bindgen#1600

@ldm0
Copy link

ldm0 commented Jun 22, 2020

You can disable this warning by using:#[allow(improper_ctypes)]

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

4 participants