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

meson/rust: wrap bindgens wrap-static-fns functionality #12263

Merged
merged 2 commits into from Feb 24, 2024

Conversation

karolherbst
Copy link
Contributor

This way the rust.bindgen can generate a second output being a C file, which contains wrapper functions for static inline ones.

This output file can then be compiled via C targets.

@karolherbst
Copy link
Contributor Author

karolherbst commented Sep 17, 2023

I'll write and add a test later. Just wanted to see what's the general opinion on this first.

@karolherbst karolherbst force-pushed the rust/bindgen/output_wrapper branch 2 times, most recently from 2a40624 to 2e21bd0 Compare September 18, 2023 09:56
mesonbuild/modules/rust.py Show resolved Hide resolved
mesonbuild/modules/rust.py Show resolved Hide resolved
@tristan957 tristan957 added this to the 1.3.0 milestone Sep 18, 2023
@dcbaker dcbaker added the module:rust Specific to the Rust module label Sep 18, 2023
@karolherbst karolherbst force-pushed the rust/bindgen/output_wrapper branch 4 times, most recently from ca9521b to be390b1 Compare September 19, 2023 09:49
@karolherbst
Copy link
Contributor Author

karolherbst commented Sep 19, 2023

decided to bump the meson requirement to 0.65 for multiple reasons:

  1. It handles C enums properly (which most will run into)
  2. The generated code includes the original header file resolving unknown types, etc...
  3. Functions with a void argument get a void argument in the generated wrapper instead of no argument (which means something different).

So while technically it's a 0.64 feature, it's almost impossible to use without running into problems. There also has been some fixes with variadic functions in 0.66, but at least that's rare enough.

@karolherbst
Copy link
Contributor Author

Okay, now the CI jobs fail because they don't have a new enough bindgen. But it is also unclear to me on why that happens. Arch has newer bindgen in their repository and so should ubuntu Rolling. What would I/you/whoever needs to do to resolve this problem?

@dcbaker
Copy link
Member

dcbaker commented Sep 21, 2023

We'd need to rebuild the images, which I thought we had a weekly job to do... Let me follow up on that. It might also be worth checking the bindgen version and skipping the test if bindgen is too old.

@eli-schwartz
Copy link
Member

They are refreshed weekly, but that doesn't automatically mean they are successfully refreshed.

I periodically try to nudge those if they are in a failing state. Currently e.g. arch has a broken refresh attempt due to:

  1. LLVM is broken, fixed in git, but they refused to backport the fix because they do not backport fixes for the last bugfix unless it's a fix for a broken backport in the previous bugfix, apparently because they don't want to risk the dreadful horror of a bugfix being wrong and having to roll out more bugfix releases than their policy document says they are going to release
  2. Protobuf is... broken, dunno how else to describe it.

@dcbaker
Copy link
Member

dcbaker commented Sep 21, 2023

To reiterate what I said on IRC in regards to the mypy error:

We can't actually hit the Executable case currently, that would require working cargo subprojects. The solution that is needed, is for executable to be handled like dependency, and be versioned by the project version and return that. I started looking into that, and it's not exactly trivial to implement, and not something I'd wish on you.

So, I think it's fine to do something like:

assert not isinstance(exe, Executable), 'Cannot do a version compare on Executable, implement the get_version() method'
<do version check>

and move on.

@karolherbst
Copy link
Contributor Author

okay, I think I fixed the linter stuff, so now all we need are new images with a newer bindgen

@dcbaker
Copy link
Member

dcbaker commented Sep 22, 2023

Do we have any images that have a new enough bindgen currently?

@karolherbst
Copy link
Contributor Author

Do we have any images that have a new enough bindgen currently?

at least the ones used in the test doesn't seem to have it.

@karolherbst
Copy link
Contributor Author

anyway, anything which can be done to move this forward?

@eli-schwartz
Copy link
Member

I've been investigating CI errors yet again, still haven't figured out how to actually get any of them to fully complete.

I'd really love to know more about this llvm issue. :(

@xclaesse xclaesse modified the milestones: 1.3.0, 1.4.0 Oct 17, 2023
@karolherbst
Copy link
Contributor Author

I really like to get this in.. is there anything we can do about that CI stuff being broken?

@eli-schwartz
Copy link
Member

Ping. Ubuntu rolling currently has images that successfully update. Please yeet bindgen in.

@tristan957
Copy link
Contributor

You might need to skip tests on some platforms. Let's see how it plays out.

@karolherbst
Copy link
Contributor Author

mhh, still no luck it seems? Are some of the containers still outdated?

Maybe CI should just use cargo to install bindgen, because this is getting frustrating...

@tristan957
Copy link
Contributor

Well I think we need a separate PR to update the images to include the version of bindgen this PR requires. Haven't seen anything in the PR queue

@tristan957
Copy link
Contributor

Looked in the ubuntu repositories: https://pkgs.org/download/bindgen. Doesn't look like much hope for an updated image, so to me, installing it via cargo (at least temporarily) seems like a great solution.

@eli-schwartz
Copy link
Member

Well I think we need a separate PR to update the images to include the version of bindgen this PR requires. Haven't seen anything in the PR queue

If it's updated in this PR then the ciimage test run would pass with the changes included.

Looked in the ubuntu repositories: https://pkgs.org/download/bindgen. Doesn't look like much hope for an updated image, so to me, installing it via cargo (at least temporarily) seems like a great solution.

What on earth is "pkgs.org".

https://packages.ubuntu.com/noble/bindgen

@tristan957
Copy link
Contributor

pkgs.org is usually good about saying what repos have what versions of software. I can see it isn't accurate here though!

I see in the image files, we already have bindgen, so how can we kick the images to be regenerated to pickup the version you just posted.

@@ -90,6 +90,32 @@ rust_bin2 = executable(

test('generated header', rust_bin2)

# Test generating a static inline wrapper
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest making this use an option + a matrix in test.json, so that the tests can specifically check for new-bindgen-stuff.

@karolherbst karolherbst force-pushed the rust/bindgen/output_wrapper branch 2 times, most recently from 074d816 to 63797a4 Compare February 7, 2024 16:51
@@ -14,7 +14,7 @@ pkgs=(
itstool gtk3 java-environment=8 gtk-doc llvm clang sdl2 graphviz
doxygen vulkan-validation-layers openssh mercurial gtk-sharp-2 qt5-tools
libwmf cmake netcdf-fortran openmpi nasm gnustep-base gettext
python-lxml hotdoc rust-bindgen qt6-base qt6-tools wayland wayland-protocols
python-lxml hotdoc qt6-base qt6-tools wayland wayland-protocols
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify why I'm asking this...

Arch ships a new enough bindgen. There's no reason to switch to cargo for this.

The Arch CI fails for totally unrelated reasons, and as a result of that it doesn't help to switch to installing it with cargo because switching to cargo would require updating the image, and if the image could be updated then you wouldn't need cargo.

Fixing the Arch image requires figuring out what's going on with llvm, which is wonderfully wacky and I find llvm very confusing so 🤷. Hopefully someone will figure it out too because static detection is badly misbehaved there, it's not as simple as "it wasn't found".

@karolherbst
Copy link
Contributor Author

uhh.. seems like building new CI images is broken and some of the ubuntu rolling jobs also are weird and don't get rebuilt or something?

In any case, installing bindgen via cargo doesn't seem to work and at this point I have 0 motivation to continue working on this as I can't be bothered working around broken CI or broken distributions

@karolherbst
Copy link
Contributor Author

If anybody else still wants to see this land regardless, please fix those issue yourself. I'm either waiting for that or investigate other options.

@eli-schwartz
Copy link
Member

eli-schwartz commented Feb 7, 2024

uhh.. seems like building new CI images is broken and some of the ubuntu rolling jobs also are weird and don't get rebuilt or something?

The Ubuntu rolling jobs are irrelevant as long as the "image builder" job for Ubuntu passes, which it does.

The Arch "image builder" job fails with or without this PR... as I pointed out above. I'm not worried about that. As long as the non "image builder" variant of the Arch CI passes, which it doesn't (because bindgen is out of date).

But. BUT. That's why I suggested in a review comment above that the testsuite case has to handle detecting whether bindgen is new enough, and raise a SKIP instead of failing with an error. I also suggested parameterizing that test case so we can test both independently, which is needed to test old bindgen with reduced meson features on older systems, and newer bindgen with full meson features on newer systems.

And I'm sorry, but that review comment still stands. It's not about the CI, so even if the CI was passing right now I'd still be asking for that change.

Once you make that change to the test case, I will be happy to do my part and

please fix those issue yourself. I'm either waiting for that or investigate other options.

so that you don't have to worry about our CI issues.

But. There is a reason I asked for the change I did, and it is because I feel it's a blocker for me to handle the CI for you.

@karolherbst
Copy link
Contributor Author

uhh.. seems like building new CI images is broken and some of the ubuntu rolling jobs also are weird and don't get rebuilt or something?

The Ubuntu rolling jobs are irrelevant as long as the "image builder" job for Ubuntu passes, which it does.

The Arch "image builder" job fails with or without this PR... as I pointed out above. I'm not worried about that. As long as the non "image builder" variant of the Arch CI passes, which it doesn't (because bindgen is out of date).

But. BUT. That's why I suggested in a review comment above that the testsuite case has to handle detecting whether bindgen is new enough, and raise a SKIP instead of failing with an error. I also suggested parameterizing that test case so we can test both independently, which is needed to test old bindgen with reduced meson features on older systems, and newer bindgen with full meson features on newer systems.

And I'm sorry, but that review comment still stands. It's not about the CI, so even if the CI was passing right now I'd still be asking for that change.

Once you make that change to the test case, I will be happy to do my part and

please fix those issue yourself. I'm either waiting for that or investigate other options.

so that you don't have to worry about our CI issues.

But. There is a reason I asked for the change I did, and it is because I feel it's a blocker for me to handle the CI for you.

yeah, but as I said, I have 0 motivation in fixing those issues. If you think this change is important to get merged, please do so yourself as I can't be bothered with figuring out how to do all those things anymore. I literally don't care at all about installs/distributions with an outdated bindgen package.

If nobody else wants to continue working on this, please just close it.

@eli-schwartz
Copy link
Member

If you think this change is important to get merged, please do so yourself as I can't be bothered with figuring out how to do all those things anymore. I literally don't care at all about installs/distributions with an outdated bindgen package.

I asked you to parameterize a test case so that instead of testing two things in one test, you test two things in two tests.

@karolherbst
Copy link
Contributor Author

If you think this change is important to get merged, please do so yourself as I can't be bothered with figuring out how to do all those things anymore. I literally don't care at all about installs/distributions with an outdated bindgen package.

I asked you to parameterize a test case so that instead of testing two things in one test, you test two things in two tests.

To me the solution is simple: update CI images with bindgen-0.65 and make sure the tests pass. This is going on for months now and literally blocked by CI not able to rebuild images.

If you think reworking the tests so it can be tested with older bindgen is a good strategy, please make those changes yourself as I said that I don't care myself anymore.

I won't be discussing this any further and just unsubscribe from this PR. Do what you think is best. I'll just workaround meson not having this functionality for now.

@dcbaker
Copy link
Member

dcbaker commented Feb 7, 2024

@karolherbst, @eli-schwartz I'll fix this up and send out an update in the next day or two, I'm trying to rebase some stuff that's very obnoxious right now, but I'll get to this.

@dcbaker dcbaker self-assigned this Feb 7, 2024
@eli-schwartz
Copy link
Member

To me the solution is simple: update CI images with bindgen-0.65 and make sure the tests pass. This is going on for months now and literally blocked by CI not able to rebuild images.

@karolherbst no, it is not blocked by CI not being able to rebuild images.

It is being blocked by the testsuite being broken on operating systems with an older bindgen, which means that people who package meson for distros and run testsuites will not be able to update to a new meson version (including as a backport) without them, in turn, being blocked on bindgen.

I am not willing to accept that. At minimum, your test case has a coding error inside of it.

"I will not fix a coding error in my test case because I don't care about systems with older bindgen versions" is not a PR that I consider to be ready to merge.

@dcbaker thanks, much appreciated.

@dcbaker dcbaker force-pushed the rust/bindgen/output_wrapper branch 2 times, most recently from b89737d to afecfee Compare February 23, 2024 17:18
This way the `rust.bindgen` can generate a second output being a C file,
which contains wrapper functions for static inline ones.

This output file can then be compiled via C targets.
@dcbaker dcbaker merged commit 8137eb4 into mesonbuild:master Feb 24, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:rust Specific to the Rust module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants