-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8254024: Enhance native libs for AWT and Swing to work with GraalVM Native Image #562
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
Conversation
Hi @arodionov, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user arodionov" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
@arodionov The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
/covered |
Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
Hi, please send the details whose OCA you are covered under to Dalibor.topic@oracle.com so that I can verify your account. Thanks! |
@robilad Hi Dalibor! Have sent you email with details. |
/signed |
Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
@bobvandette Could you please join to the review? |
Webrevs
|
It is generally not expected for such a proposed change to pop up out of nowhere from someone who is a new contributor |
/reviewers 3 |
@prrace |
I've been coaching @arodionov through this change. This fix extends the work I did to allow a Java program to be created using all static libraries. This PR fixes issues where there are multiply defined symbols in libawt, the headless and xawt toolkits when linked into a single executable. It also solves the problem where dlsym doesn't work for non shared libraries. |
Sorry I am not familiar with that work. Please provide more info. |
Here's the JEP for the work done in JDK8 to allow libraries to be built and used statically. https://bugs.openjdk.java.net/browse/JDK-8046168 Here's the changes done to allow a Mac build to be done fully statically. |
fa908d9
to
65d3e83
Compare
/reviewers 2 |
@mrserb |
Does it mean that in the case of static-libs both variants of AWT libraries(xawt and headless) will be loaded? |
I would have to suppose that isn't possible but it is not clear whether the authors I don't get the motivation from the JEP as to how it applies here.
|
No, they shouldn't. If this happens it causes duplicate symbol error during linkage phase.
For GraalVM native image, we run JCK tests |
The changes in awt_LoadLibrary.c and XToolkit.c is mostly noop except excluding dladdr/dlopen. Since XsessionWMcommand/AWTIsHeadless are not used at least in the mainline(jdk16). The testing is in progress. |
please merge the master to this branch, it is quite outdated, and update the last copyright date to 2020. |
65d3e83
to
47252ec
Compare
@mrserb I have rebased PR on the master, but |
@dougxc could you please review AWT static-libs enhancement for GraalVM Native Image? |
@prrace I have added more information to PR description, sorry for the inconvenience. Regarding the use case of using AWT static libraries: with GraalVM Native image we can take a jar with some AWT/Swing application and convert it (using gcc and static libraries) to binary executable (currently only for Linux 64) and then run it without JRE. |
So I am supposing this means you are producing two different static images ? - either all the time or based on a build flag ? Can you confirm that understanding ? |
No, we produce only one image. The headless/non-headless mode is defined by the system property With |
-Djava.awt.headless is a runtime property not a build time property. So you are doing domething very weird. So how does a "user" use all of this ? Seems they must create their own app by native compile + linking. |
At the current stage, we made the For example, for the code snippet
For simple AWT UI Java app, the set of libraries are the following:
The global idea is that any existing Java app (even without source code) can be converted into a native image, that's why we have added AWT/Swing support to GraalVM. |
@prrace It may be also useful to look at how we define a set of static libraries: |
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.
This makes sense from a build PoV, but you'll need approval from the client team as well.
@arodionov This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 270 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@mrserb, @magicus, @bobvandette) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
If by "help" you mean scare the life out of me .. If someone else wants to approve this change they can, but my conscience isn't letting me .. |
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.
I'm ok with these changes. They are no worse than the other STATIC_BUILD changes that already exist in the JDK sources.
/integrate |
@arodionov |
/sponsor |
@bobvandette @arodionov Since your change was applied there have been 270 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 7977e38. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
@prrace I agree with you that our intrusion is a large maintenance overhead and that it can lead to potential errors. It is worth mentioning two things that could make you feel less scared:
|
The following PR fixes https://bugs.openjdk.java.net/browse/JDK-8254024
Starting from version 11.0.9, all JDK libraries also build as static libraries (JEP 178: Statically-Linked JNI Libraries).
The purpose of using static libraries is to build GraalVM Native image statically linked with Java native libraries, to shipping single executable without runtime dependencies from JRE.
For some static libraries, it leads to an issue: if one static library is trying to load another static library in runtime using
dlopen
(and then usesdlsym
to find symbols). With static libraries, this is not possible and all dynamic calls should be replaced.This happens in
libawt
while it loadsawt-xawt
orawt_headless
and inmlib_image
.Current PR fixes this issue for AWT libraries that allow building Swing/AWT applications as a Native image and have no runtime dependencies from JRE.
Progress
Issue
Reviewers
Download
$ git fetch https://git.openjdk.java.net/jdk pull/562/head:pull/562
$ git checkout pull/562