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

Prevent error with musl libc and GraalVM native image #191

Merged
merged 1 commit into from
Jul 28, 2024

Conversation

hubvd
Copy link
Contributor

@hubvd hubvd commented Jul 27, 2024

When compiling a native image for linux with musl libc, the following error was displayed:
'struct termios' has no member named 'c_ispeed'

On musl, it is named __c_ispeed

Since we don't really need those fields anyway,
we can remove them from the struct definition.

We then need to mark the struct definition as incomplete. The documentation says:
If marked as incomplete, we will not try to determine the size of the struct.

StackValue.get(structType) is actually a shortcut for StackValue.get(SizeOf.get(structType))

We now simply need to pass the explicit size in bytes.

Fixes #189

When compiling a native image for linux with musl libc,
the following error was displayed:
`'struct termios' has no member named 'c_ispeed'`

On musl, it is named `__c_ispeed`

Since we don't really need those fields anyway,
we can remove them from the struct definition.

We then need to mark the struct definition as incomplete.
The documentation says:
If marked as incomplete, we will not try to determine the size of the struct.

`StackValue.get(structType)` is actually a shortcut for
`StackValue.get(SizeOf.get(structType))`

We now simply need to pass the explicit size in bytes.
@hubvd hubvd force-pushed the graal-native-musl branch from 03063d2 to 0b8d12e Compare July 27, 2024 22:04
@hubvd
Copy link
Contributor Author

hubvd commented Jul 27, 2024

I saw a LibCSpecific annotation, but I didn't manage to get it working, so I hardcoded the struct size.

On another note, I saw your ffm-syscalls branch. The project Panama is now supported in GraalVM native images starting from version 22. It is still experimental, but I didn't encounter any issues from what I tested on linux x64.

https://www.graalvm.org/latest/reference-manual/native-image/native-code-interoperability/foreign-interface/

Not sure how many people are using versions prior to that one, but I guess one day, there could be one less binding.

As always, thanks for the awesome library

@ajalt ajalt merged commit 3fc5f32 into ajalt:master Jul 28, 2024
4 checks passed
@ajalt
Copy link
Owner

ajalt commented Jul 28, 2024

Thank you! I really appreciate it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants