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

--use-core bindings refers std #1015

Closed
pepyakin opened this Issue Sep 22, 2017 · 8 comments

Comments

Projects
None yet
4 participants
@pepyakin
Copy link
Contributor

pepyakin commented Sep 22, 2017

Input C/C++ Header

// bindgen-flags: --impl-debug --use-core --raw-line "extern crate core;"

class C {
    bool a: 1;
    bool b: 7;
    int large_array[50];
};

Bindgen Invocation

See bindgen-flags above

Actual Results

// ... stripped

extern crate core;

#[repr(C)]
#[derive(Copy)]
pub struct C {
    pub _bitfield_1: u8,
    pub large_array: [::std::os::raw::c_int; 50usize]
}

// stripped ...

Expected Results

Despite that --use-core flag is provided large_array field having a type which refers std.
I expect that either error is printed stating that bindings couldn't be generated with --use-core or bindings which don't use std generated.

@fitzgen

This comment has been minimized.

Copy link
Member

fitzgen commented Sep 22, 2017

Nice catch!

I expect the fix for this is really easy (just forgetting to look at the prefix and emitting std regardless somewhere in src/codegen/mod.rs), but I hesitate marking it E-easy without being able to add clear instructions on how to fix this. Needs a little bit of investigation, so marking it E-less-easy.

@fitzgen fitzgen added the E-less-easy label Sep 22, 2017

@emilio

This comment has been minimized.

Copy link
Collaborator

emilio commented Sep 24, 2017

This is working as expected, --use-core doesn't replace std, since it doesn't include them. You need to manually point to somewhere, e.g., libc, using --ctypes-prefix.

Worth pointing it out in the FAQ or something though, I guess.

@joshlf

This comment has been minimized.

Copy link
Contributor

joshlf commented Jul 29, 2018

To clarify: The issue is that some types are present in std and not in core, and thus --use-core has to still rely on std for those types? Would it be feasible to add the offending types to core to fix this problem?

@emilio

This comment has been minimized.

Copy link
Collaborator

emilio commented Jul 29, 2018

Either that, or using the --ctypes-prefix option, which is meant just for that. I'm not sure the c_* types are meant to be in core.

@emilio

This comment has been minimized.

Copy link
Collaborator

emilio commented Jul 29, 2018

Closing per #1015 (comment), since as things stand ctypes-prefix should be used. If rust puts the ctypes in core, then another issue can be opened to make bindgen adapt to that.

@emilio emilio closed this Jul 29, 2018

@joshlf

This comment has been minimized.

Copy link
Contributor

joshlf commented Jul 29, 2018

If these types aren't in core, what would we pass to ctypes-prefix?

Also, I've asked about moving them to core.

@emilio

This comment has been minimized.

Copy link
Collaborator

emilio commented Jul 30, 2018

You should pass, e.g., libc, to use the libc crate, or a module / crate of your own that defines the needed types for the target architecture.

Though usually you'd want libc, I suspect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.