Skip to content

[GR-50345] Get whether it is a static link when building a native image #7555

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

Open
Glavo opened this issue Oct 5, 2023 · 3 comments
Open

Comments

@Glavo
Copy link

Glavo commented Oct 5, 2023

I'm fixing some native-image related issues for Jansi.

Jansi uses FFM or JNI by default, but they do not work in statically linked native images. Therefore, I provide a slower but working implementation. The specific implementation to be used is determined at build time.

However, there seems to be no way for me to know at build time whether the native image is statically linked, so users has to add options manually to make it work.

Can you add some system properties to tell whether the program is statically linked and whether the libc used is musl or glibc?

@Glavo Glavo added the feature label Oct 5, 2023
@Glavo
Copy link
Author

Glavo commented Oct 5, 2023

Jansi uses FFM or JNI by default, but they do not work in statically linked native images. Therefore, I provide a slower but working implementation.

Some more detailed information:

On Linux/macOS, we need to call two native methods: isatty and ioctl.

Symbol.loaderLookup() cannot find these symbols in statically linked native images, so the only way to call them is the Native Image C API. Unfortunately, ioctl is a variadic function, and the Native Image C API does not yet support variadic functions (#7507), so we have to use a slower way around this limitation.

Also we cannot use Native Image C API on Windows due to #1760, this makes me depressed.

@wkgcass
Copy link

wkgcass commented Oct 14, 2023

For statically linked JNI, you may refer to this blog, which might help.

Related issues:

#3359 #4028 #7618

@kassifar
Copy link
Member

Hello @Glavo,
Thank you for your suggestion. We'll be taking a look at it.

@kassifar kassifar self-assigned this Nov 24, 2023
@wirthi wirthi changed the title Get whether it is a static link when building a native image [GR-50345] Get whether it is a static link when building a native image Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants