-
Notifications
You must be signed in to change notification settings - Fork 18
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
Support static inline functions in ctru-sys #133
Conversation
I'm very happy to see you working on the project again! I'm sorry for not responding sooner, but I was busy with the documentation PR that is now finally over #134. These new changes seem very promising, especially since they are pretty much required to officially support many There are just 2 things I'd like to say before actually working towards merging this PR:
Tell me what you think about the second issue in particular. |
Both the bindings and the extern library can be created via |
5e3aa28
to
d30a827
Compare
So the CI pipeline is failing because |
Okay, so |
e9c5371
to
073ebd7
Compare
Looks like everything is working now. Other than the build script being kind of a mess to read, we should be good to go. |
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 great to me! I've had to do some cleanups before using it (most likely because the new build script completely broke all earlier incremental artifacts) but it works very nicely now.
@ian-h-chamberlain @FenrirWolf I was wondering about a way to solve the versioning system conundrum. With the changes proposed by this PR (which I’m very supportive of) the current versioning system makes very little sense. It’s good if we are the ones providing the bindings when developers pull the Instead, maybe the dependant package should be the one checking for the version, by pulling a generic Example[dependencies]
ctru-sys = “0.1.0”
[package.metadata.ctru-sys]
required-libctru = "2.2.0" This requirement would still not be restrictive, instead just printing the “wrong version” warning that is already in place. Using the |
What's the benefit of running bindgen during the build instead of via script? Will docs.rs be able to show accurate info? (I don't think it will have libctru available when building docs) |
@AzureMarker Not much really changes from an end-user perspective. I felt like it was a good change to make though since we're not only generating bindings now, but we also need to build and compile the extra static fns wrapper and it seems better to handle both those steps in one place instead of having logic split between a shell script and a dedicated bindings generator crate. Docs are still generated properly too, so there won't be any changes or issues when it comes to that. I would say the main benefit from the maintenance side is that everything is handled by cargo and we don't have to manually run any scripts or programs when updating @Meziu I would say it's still worth enforcing versions for the |
Yeah, I think an approach like this makes sense, but we probably could just hardcode a minimum version right in the
If we want to get fancy with it we could even do an actual semver check or something, although I'm not sure upstream really follows that convention -- so a minimum version seems like it would work okay IMO.
That's true for our CI environment, but probably not for |
|
||
stdout_str | ||
.split(|c: char| c.is_whitespace()) | ||
.nth(4) |
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 like gcc also has -dumpversion
/-dumpfullversion
flags to make this even simpler if you want
let system_include = sysroot.join("include"); | ||
let gcc_include = PathBuf::from(format!( | ||
"{devkitarm}/lib/gcc/arm-none-eabi/{gcc_version}/include" | ||
)); |
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.
It would be nice if we could get gcc
to list these flags for us, but it doesn't seem like there's a standard way to to do it so this seems fine.
.file(out_dir.join("libctru_statics_wrapper.c")) | ||
.flag("-march=armv6k") | ||
.flag("-mtune=mpcore") | ||
.flag("-mfloat-abi=hard") |
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.
It would be nice to have a common (function or array or something) definition for these flags, at least where they overlap between clang_args
and cc::Build::flags
At that point
It's fine,
Uff, I'd never thought about it. It's true that the Regardless, this PR can go on without all these discussions. |
Ok, let's move discussion about versioning back to #100 and this PR can move along (for now whatever version it already has should be fine since nothing's published yet). |
Will merge this one since it holds some pretty valuable changes for the repository, and it hasn't received any blocking reviews by anyone. The discussion about "generating vs including" the bindings can be made elsewhere. |
A first attempt at generating bindings for static inline functions in libctru. I'm pretty sure this functions properly, but I haven't played around with LTO settings yet and I'm sure there are some hand-written wrappers that will need to be replaced with calls to the generated fns instead.
Also now that we have to compile, build, and link a whole new C static lib as part of the process, it might be cleaner to move everything to a proper build script instead of pre-generating the ctru-sys bindings like we've been doing up until now. Honestly the only reason I set things up like that back in the day is because I didn't like having to wait for
bindgen
to build and run each time I did acargo clean
so perhaps it's finally time to change things. 😄closes #123