Expose static inline functions to bindings
DeltaF1 opened this issue · comments
libctru has some functions that are static inline
(I ran into getThreadCommandBuffer
specifically) and so are not exposed by bindgen by default.
rust-lang/rust-bindgen#2335 adds a feature to generate bindings for such functions. I got as far as adding these arguments to bindgen.sh:
--experimental \
--wrap-static-fns \
which adds the missing functions to bindings.rs, and generates a C file with wrapper functions in /tmp/bindgen/extern.c
. I don't understand build processes enough to proceed from this point, but extern.c
needs to be compiled and then linked with the library. Here's a link discussing how to do this and also about how to enable LTO so that ctru-rs can benefit from inlining those functions. I believe this also depends upon #110 fixing the __getreent
issue.
@ian-h-chamberlain @AzureMarker Do you think we should add experimental options to bindgen
? It would better cover libctru
with the bindings, but we are already full of experimental features here and there.
I'm asking because I intend on merging #110, so I could add this in if you think it's fine.
If we do add it, it should be a separate PR. I do like having increased coverage of the libctru static functions, but since we already converted the common ones I'm not sure that we need to do this refactor now. Feel free to go ahead and open a PR for it though if someone gets it working.
I'd echo the same, the new bindgen feature seems nice but a separate PR would probably be good just to make it easier to review, since some of the manually-ported functions would have to get removed.
At first I was thinking the requirement to build an extra C source file would be kind of troublesome, but I suppose it should always work since we already have a build dependency on the devkitPro toolchain.