Skip to content

bindgen can't generate thread local variables correctly #1187

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

Open
framlog opened this issue Dec 11, 2017 · 3 comments
Open

bindgen can't generate thread local variables correctly #1187

framlog opened this issue Dec 11, 2017 · 3 comments
Labels

Comments

@framlog
Copy link
Contributor

framlog commented Dec 11, 2017

I don't know whether it's really an issue since stable rust doesn't support thread_local yet.

Input C/C++ Header

static __thread int variable_1 = 0;
thread_local int variable_2 = 0;

Bindgen Invocation

bindgen::Builder::default()
    .header("input.h")
    .rust_target(bindgen::RustTarget::Nightly)
    .generate()
    .unwrap()

or

$ bindgen input.h --whatever --flags

Actual Results

pub static mut variable_1 ...

Expected Results

#[thread_local]
pub static mut variable_1
@emilio
Copy link
Contributor

emilio commented Dec 11, 2017

There's another issue, I think, which is that thread-local vars don't have symbols, so I'm not sure it's possible to touch a C thread-local variable without going through FFI.

There's definitely a bug in there, if I'm right we shouldn't be generating TLS vars at all anyway.

@emilio emilio added the bug label Dec 11, 2017
@fintelia
Copy link

fintelia commented Jan 9, 2018

I'm also impacted by this issue. Is it possible to work around by blacklisting and providing the correct Rust incantation myself, or will there still be problems at the link stage?

@emilio
Copy link
Contributor

emilio commented Jan 10, 2018

Yes, you should be able to just whitelist it, but I don't think you can provide the rust definition, given I don't think there's a standard way to create TLS vars across languages

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

No branches or pull requests

3 participants