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

Flag for #[link = "..."] Attribute #1358

Closed
cramertj opened this issue Aug 1, 2018 · 7 comments
Closed

Flag for #[link = "..."] Attribute #1358

cramertj opened this issue Aug 1, 2018 · 7 comments

Comments

@cramertj
Copy link
Member

cramertj commented Aug 1, 2018

It'd be nice if the bindgen CLI had an arg that would allow setting the name of the library to be linked against, which would then be emitted as #[link = "<somename>"] attributes. I'd be happy to try my hand at a PR for this if it's wanted.

@emilio
Copy link
Contributor

emilio commented Aug 2, 2018

Why doesn't --raw-line address that?

@emilio
Copy link
Contributor

emilio commented Aug 2, 2018

That is, I understand it's more convenient to say --link foo (or something else), than --raw-line '#[link = "<foo"]', but I don't think the later is completely unreasonable either.

@cramertj
Copy link
Member Author

cramertj commented Aug 2, 2018

That is, I understand it's more convenient to say --link foo (or something else), than --raw-line '#[link = "<foo"]', but I don't think the later is completely unreasonable either.

Nah, definitely not unreasonable, but I think that --link is more discoverable and would be a good bit more ergonomic.

@emilio
Copy link
Contributor

emilio commented Aug 5, 2018

I'm not opposed to this if there's demand for this... It'd be nice to know what people use --raw-line for :).

But I also wouldn't want bindgen to end up with even more options for niche use cases. links have different kinds and we'd need to expose a flexible enough API, which is why I ended up removing the (already-useless because I forgot about them when rewriting bindgen) options in #104.

In any case, fine getting them back if it's a very frequent thing to do. Though given not so many people ended up caring about #104 I doubt it's the case.

@cramertj
Copy link
Member Author

cramertj commented Aug 6, 2018

In any case, fine getting them back if it's a very frequent thing to do. Though given not so many people ended up caring about #104 I doubt it's the case.

@emilio Interesting-- I would've guessed it would be very common. Do you figure most people are adding the link declarations via a build script, or are they just already including them elsewhere in their projects?

@emilio
Copy link
Contributor

emilio commented Aug 7, 2018

I don't know at all. I assume for build scripts you can println!("cargo:rustc-link-lib=foo") on your build.rs, and for CLI usage people drop the link attributes in some other part of the project or what not.

@LegNeato
Copy link
Contributor

I am trying to statically link (kind = "static") and the generated default appears to be dynamic. This will be nice to have but in the meantime I'll use println!("cargo:rustc-link-lib=foo")

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

4 participants