-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8017234: Hotspot should stop using mapfiles #17955
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
|
👋 Welcome back ihse! A progress list of the required criteria for merging this PR into |
|
First some general notes on related build changes: This was the last place in the build system where mapfiles where used. It will now be possible to clean up a lot of this framework, but I will do that separately after this has been integrated. Also, Hotspot is now built much closer to the rest of the native libraries in the JDK, so there is potential for more unification (e.g. placing On Windows, we still need to do the dance of finding symbols from the object files, and add them to a list of exported files (included by I have checked the resulting libjvm.so/jvm.dll using the When I first started doing this conversion, I got a lot more differences. First of all, the Secondly, it turned out that there were several symbols declared To be consistent with the old behavior, I have undefined a) say we want to remove this b) say we really don't want to export these functions on Linux, only on Windows. In that case, we should probably replace This is a decision for the Hotspot team; let me know which solution you chose. (It can be different in different places, of course). And thirdly, there seem to be a bug in gcc, which ignores the About the changes on linux/x64 and linux/aarch64: I believe the new values are in some way more correct, but I also think the difference is insignificant. The difference is that the data (variable) symbols Finally, in the gtest libjvmo.so there are some additional differences as well. I did not really care about these, since this is only used for testing, but for the sake of completeness, here are the differences. They belong to two different categories. Group 1 includes four symbols like in Group 2 includes symbols that seem to originate in the googletest library. They have changed
|
Webrevs
|
There appear to be two main categories of functions here:
Have you verified those functions can still be called from the debugger?
The Graal folk will need to chime in here as it may be that these are needed for libgraal. |
|
My main concern with a change like this as that it likely has little effect on the OpenJDK itself, but we may be changing something that 3rd party applications linking with libjvm are relying on. I realize this is a bit "hand wavy" but are we sure this presents the exact same view of libjvm as before? |
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.
Thanks for doing this! This is a good improvement IMO.
If the SUNWprivate_1.1 part of the symbols is still needed, it can be added using --default-symver ld parameter.
You might want to run tier1-5 tests; compilation-related changes are often detected by higher-level builds and tests only.
They should be fine. JNI linkage is only used by the native methods in |
I tried to be clear, but apparently I failed: There is no change to these symbols in the patch! So everything should work just as before! The reason I even brought it up to discussion is that it required a bit of a "hack" to keep the functionality identical, and this looks suspicious in the source code. |
Thanks!
Ah, good to know. In the spirit of making as minimal changes as possible in this PR, I will add it.
I can run tier 4 and 5 also. But once again, the entire point of this PR being so convoluted is that there should be a minimum of differences in compilation. On macOS and Windows, the binaries before and after this patch are almost identical; just a few hundred assembler instructions have been reordered slightly. (Why this is even so I don't know, but in the end I did not care to dig into the details.) On Linux, more code is shuffled around, making for a greater bit-by-bit difference. Still, the symbol tables are (almost) identical, and these changes should only affect symbol visibility, so I believe this is mostly an artifact of how the linker organises stuff. |
Once again, it is a misunderstanding that anything here changes. These functions will stay the same before and after this PR. However, I interpret your comment as that it is possible to remove the JNIEXPORT from these functions in a follow-up PR. And that is good to know! |
I realize that my essay-style comment was a bit TL;DR, but I tried to answer questions like this ahead of time in it. Let me quote:
On linux/x64 and linux/aarch64 there are some very minor changes:
So yes, I have worked hard to make sure the resulting libjvm.so/jvm.dll is as close as humanly possible before and after this PR. I cannot think of a way in which 3rd party applications could even spot the difference before and after this patch. (Except for a contrived counterexample like explicitly looking up the visibility of |
|
Let me also add some background to the why of this PR. A good reason is to get rid of a lot of weird code and special cases in the build. It will also speed up the build since we needed to scan all .o files with nm after they were compiled but before they were linked, adding to the slow path of linking hotspot. But for the 10+ years this has been a JBS issue it has never completely pushed the scales. The triggering factor now is the Hermetic Java project. We need to make properly supported static libraries for all native code in the JDK. One of the main issues with creating a single static library from all the native code is symbol visibility. If the same symbol name is exported from two different libraries, this will cause a failure. This weird "dance" in Hotspot makes it much harder to reason about, or fix, issues related to symbol visibility. That is why I want to have this fixed, once and for all. |
Unfortunately, that was not so easy. :( |
I believe you're right. In any case, most of the JVMCI tests will fail if JNIEXPORT is removed and it turns out to be needed. |
|
I just realized I could keep an extremely simplified linker script ("mapfile") for gcc, and thereby keeping the I think we can get rid of this as well going forward, but as with other cleanups, let's do that separately. |
Regarding SUNWprivate_1.1, reading JDK-4916160 it seems like it could cause problems for native user libraries linked against an older JDK version if we remove it. I think this is what David Holmes was referring to. So it seems like a good idea to figure out a way to keep it around. |
"Forward compatibility issue : 1.4.1_03 onwards". Wow, that's a blast from the past! The sins of the fathers, etc. :) I'm not sure I understand JDK-4916160 completely, but it seems they had the opposite situation -- prior to 1.4.1_03 we did not link with version scripts, and from 1.4.1_03 we did. And this was closed as "not an issue". Nevertheless, I have found a way to keep the |
I have thought the same. :) There seem to be room for improvement in a simple "framework" to reduce duplication across the .S files. (There is also plenty of room for improvement in coordinating the style across the .S files...) I believe one reason this has not yet happened is that up until a year or two ago, most Hotspot assembly files where .s (which are not preprocessed) as opposed to .S. I standardized on .S for all assembly code in the JDK project in JDK-8264188, and after that, the door has been open for the Hotspot developers to create such a macro.
I'm way ahead of you there. :) That is the next one up my pipeline in "turning on jcheck for all text files, one file type at the time". But is a chore, really, to get those kinds of fixes approved. And I wanted to get progress in the mapfile question first. |
Yes but "should work" and "does work" may not be the same unless you have actually verified the functionality. That said I now see that we only actually need to export on Windows for the debugging functions to work, so I agree everything should work just fine in that regard. Apologies - It took me a little while to click to the fact not all JNIEXPORT symbols were actually being exported due to their omission in the mapfile - hence the need to now actually hide them to keep things working the same. (FWIW I don't think it matters if we export the debug functions unnecessarily on some platforms - I'd go for code simplicity/consistency. EDIT and I see you went that way too.) |
|
Just to confirm: this PR passes tier 1-5. |
We had the PR in our SAP internal build/test queue, no issues seen with it. |
This reverts commit 00e40a7.
What issues did you see? Or was that a typo for "no issues"? |
Sorry Magnus, tests were fine no issues were observed. |
|
Great. The only remaining difference I see is that the PR adds the following export: Any idea what it might be? If not, I guess we can live with that. |
Why do this just for GCC? Shouldn't this be for Linux as we are doing it for backwards compatibility with user JNI 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.
Windows-x64 and Linux-x64 look fine to me.
|
@magicus 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 9 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
No. I vaguely recognize this symbol as sticking out, but can't find it now in my runs. Which gcc version are you using? I think this is another example of the gcc bug. But I think we can live with that anyway, even if it gets exported for some gcc versions after this PR. |
|
This is on GCC 9.4.0, Ubuntu 20.04. |
Good point. I did not really consider the case of clang on linux, since this is a secondary option, and I did not believe keeping consistency there was important. But as you say, the fix is trivial and makes a lot of sense. I have now verified that the symbols look identical when compiling with clang, between this PR and the latest (and hopefully last!) update, and mainline. |
|
Can I get a second Hotspot reviewer for the Hotspot changes? |
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.
From a build point of view, I think this looks good now.
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.
Given discussions and additional testing/validation, the hotspot changes appear okay. Thanks.
|
/integrate |
|
Going to push as commit da14aa4.
Your commit was automatically rebased without conflicts. |
Summary: Finally get rid of the mapfiles in Hotspot, and replace it with compiler options and
JNIEXPORTon all platforms.The bug that this PR solves, JDK-8017234, was created in 2013. Even back then the use of mapfiles in Hotspot was dated, so this is really good riddance with old rubbish.
This code touches on central but not well understood parts of the Hotspot dynamic library, which has contributed to why this bug has stayed unresolved for so long. I will need to explain this fix in more detail than usually necessary. (Please bare with me if this gets long.) I also anticipate that not all solutions that I've picked will be accepted, and we'll have to discuss how to proceed. I think it is better to have actual concrete code to discuss around, rather than starting by an abstract discussion. To keep this description short, I will post the discussion as a comment to the PR.
I have run this PR through tier 1-3 in our CI system. I have also carefully checked how the resulting dynamic library differs with this patch (not much; see discussion below). For build system changes, this is often the most relevant metric.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17955/head:pull/17955$ git checkout pull/17955Update a local copy of the PR:
$ git checkout pull/17955$ git pull https://git.openjdk.org/jdk.git pull/17955/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17955View PR using the GUI difftool:
$ git pr show -t 17955Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17955.diff
Webrev
Link to Webrev Comment