-
Notifications
You must be signed in to change notification settings - Fork 14
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
Upgrade the generator script to test Clang.jl's new generator #39
Conversation
1e9999b
to
3779719
Compare
Codecov Report
@@ Coverage Diff @@
## master #39 +/- ##
===========================================
- Coverage 73.80% 34.42% -39.39%
===========================================
Files 3 3
Lines 84 61 -23
===========================================
- Hits 62 21 -41
- Misses 22 40 +18
Continue to review full report at Codecov.
|
Looks clearer! While quickly browsing through the changes, a few things got my attention. I saw that all handle types ( Also, what happened with some structs such as
against |
This behavior is now configurable with the new generator. The full configuration list can be found here. As of the mutable part, it prevents the compiler from doing some aggressive optimizations. In practice, there is no much difference since opaques should only be used in the form of an opaque pointer.
Nice catch! That's definitely a bug of the new generator. UPDATE: this is addressed on the Clang.jl side. |
hi @serenity4, I just added a new feature that all "top-level structs"(structs that are not served as a field type of any other structs, so it's safe to mark them mutable) can be automatically generated as |
OK, just found the reason. It turns out that if a function accepts a |
Ah, indeed in that case it's better to have them non-mutable. What was the reason for introducing this feature? |
I find in some cases(e.g. init and fill |
Maybe we can do this for the |
Now I implemented a more strict rule for this feature and exposed
and I added a more strict rule to exclude the situation where the type needs to be passed a la a
here I'm assuming if a C function expects a vector input argument, it needs a pointer + a size integer. For the sake of safety, I agree we should use |
This kind of logic reminds me of Vulkan.jl, where there is basically some kind of IR (generated from the spec) that is used to generate the wrapper. There is a function that tells you whether a parameter/field is used as a vector, by checking whether its spec type is a pointer and if there is an integer (except Thinking about it, if some structs are mutable and others not, depending on the proportion of immutable structs the user may not want to bother checking whether the type is mutable, and just not use the feature. As in, there would be 1 chance out of 10 that the pattern may not work (due to a particular struct being immutable), and when using VulkanCore.jl directly any uncaught error is very likely to cause a segfault (due to finalizers being run in an unordered fashion at an unexpected point, or resources that were not cleaned up before GC if finalizers aren't used for that). So I am a bit skeptical about having this feature at the core. I'm still not against having it as a package option, but only if there is a concrete use in line with the goal of the library and if the limitations are made known to the user. |
Thanks for the feedback. That makes sense to me but I don't have time to make it a package option at the moment, so just disable this behavior for VulkanCore.jl. |
@serenity4 may I ask why you bundled the old version of CEnum.jl in #42 ? |
@@ -4,7 +4,7 @@ on: | |||
push: | |||
pull_request: | |||
env: | |||
JuliaVersion: 1.5 | |||
JuliaVersion: 1.6 | |||
VulkanSDKVersion: 1.2.148.1 |
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.
This needs to be bumped.
Hmm it wasn't done on purpose. I just ran the generator script, which produced the CEnum.jl file, and assumed it was good. If that was an old version then we need to update it. |
OK, this is ready for a review. Feel free to merge this if there are no other problems. It's too late at my local time, I'm going to sleep. :) |
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.
Looks good to me. I can't test it yet with Vulkan.jl (will need some changes because I just expected everything to be included until now) and I trust you with the setup of the generator, otherwise I didn't see anything to change. That's really awesome, thanks for the work! 💯
I'll let you merge it, I don't know if you want to squash this or keep the full commit history.
No description provided.