-
Notifications
You must be signed in to change notification settings - Fork 729
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
Allow static and dynamic linking #1620
Conversation
☔ The latest upstream changes (presumably 3062841) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I thought ::is_loaded()
and co would not work on statically-linked stuff.
This looks great, do you know if it'd be a lot of work to at least cargo-check the new build configuration? That'd prevent it from breaking in the future.
It doesn't - they're all behind
I'll see what I can do. |
Then how does this build? |
? I added the necessary |
Sorry, we were talking past each other looks like :) I was talking about the individual function's But looks like clang-sys stubs them properly: https://github.com/KyleMayes/clang-sys/blob/ad5b1d0c64b19c4bfe00df6dfd661b80203dd161/src/link.rs#L195 |
@emilio The checks are failing because this doesn't support libclang <= 4.0 any more - it tries to resolve symbols which don't exist in those versions. It might work with "runtime" because it only dynamically looks up symbols which do exist. |
Yeah, that's ~expected, I guess... Can we not test building the static version in those rather than removing the platforms? What's what triggers the Alternatively, we need to remove a bunch of |
It's triggered by non-"runtime". (nothing) is link with whatever is available (static or dynamic), and "static" is specifically statically link. "static" is hard to test because libclang doesn't build static out of the box and I haven't found any prebuilt libclangs available as static. But clang-sys does support static, so presumably someone is using it (well, including me, but we're using a slightly different mechanism). Are you suggesting:
? |
☔ The latest upstream changes (presumably 807fa1e) made this pull request unmergeable. Please resolve the merge conflicts. |
(FWIW, I haven't forgotten about this and still looks good. Will try to figure out a way to test this properly without regressing the Thanks again for this! |
(And really sorry for the lag replying, I had missed your previous comment) |
Do you need me to rebase it? |
That'd be ideal, but no worries if you don't get to it.
…On 10/9/19 4:38 PM, Jeremy Fitzhardinge wrote:
Do you need me to rebase it?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1620?email_source=notifications&email_token=AAKDBOV6FOG55UNUWVP23C3QNXUGRA5CNFSM4IW6Q6C2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAYDR5Y#issuecomment-540031223>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKDBOVA4WDPOAGVCLWLGIDQNXUGRANCNFSM4IW6Q6CQ>.
|
#1646 is the version that adds support for libclang 9 on CI. That should allow to test this, and we should be able to avoid testing on other platforms. |
We get link-time missing symbols with llvm before 5.x, so don't try to directly link with them.
Currently bindgen always uses clang-sys with the "runtime" feature - that is, load libclang at runtime with dlopen (or similar) at runtime. This PR keeps this default, but also - adds "static" to statically link libclang - without either "runtime" or "static", link with the shared library Many distributions don't ship with a static libclang, but linking with the dynamic library will use normal ld.so mechanisms to define where the .so file should be found. (Ditto for the Mac and Windows equivalents.)
Rebased; fixed trivial conflict |
So I put in #1649 my current WIP. One annoyance of having two separate features is that downstream crates that want to use I think ideally we'd make |
I think that's a fundamental problem with using features this way - it isn't intended to support non-cumulative build-time options, and trying to do so breaks things. On the other hand, there's no better suited alternative mechanism. |
So I gave a shot at finishing this, but apparently there are no pre-built static libclang versions, so we'd need to build our own which is not great... Is the plan to build your own libclang.a and distribute it statically linked? Anyhow I guess I can land the patch without the tests if you need it and got it working. |
Yes, the clang build system seems to make generating a static libclang really tricky, and I couldn't find any Linux distro which ships a prebuilt static libclang. However our internal libclang has a static build, so its useful for that. The non- So I'm not too concerned about not specifically testing |
☔ The latest upstream changes (presumably c462b63) made this pull request unmergeable. Please resolve the merge conflicts. |
Ok, so I landed #1649 with your changes and a slightly different/smaller set of CI tweaks, so that this is tested to the extent possible based on the comment above. Thanks for the patch! |
Hi @emilio this fix added a new default feature which wasn't mentioned in the changelog. This made upgrading my dependency with Can we add a note to the changelog when features are added? |
Yeah, that's fair, I added a changelog note just now, but I'll keep it in mind for the future too. Thanks :) |
As it became non-default in rust-lang/rust-bindgen#1620.
* Fix bindings. PR #74 introduced a manually-generated change to the bindings that I accidentally broke in #76. * Specify the "runtime" feature of bindgen. As it became non-default in rust-lang/rust-bindgen#1620. * Make binding generation work properly on Windows too.
Currently bindgen always uses clang-sys with the "runtime" feature -
that is, load libclang at runtime with dlopen (or similar)
at runtime. This PR keeps this default, but also
Many distributions don't ship with a static libclang, but linking with the dynamic
library will use normal ld.so mechanisms to define where the .so file should be found.
(Ditto for the Mac and Windows equivalents.)
Fixes #1617