-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8328614: hsdis: dlsym can't find decode symbol #18400
Conversation
👋 Welcome back rehn! A progress list of the required criteria for merging this PR into |
@robehn 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 263 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. ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
@magicus is this how you want us to export these symbols? |
Close but no cigar. :-) Use
If this is not picked up correctly, let me know and I'll help you get the include paths correctly in the build. |
Also, apologies for forgetting to check hsdis when I changed the visibility. :-( |
It's stand alone library, should we really make it dependent on the JDK? |
Unless you start calling JDK functions, you will not make a program less stand-alone by including jni.h. In this case, you will only use a compile-time definition. Ideally, we should have had more general EXPORT definitions separate from the rest of the JNI code, but someone started doing things that way, and well, here we are, 25 years later and now JNIEXPORT is everywhere in the JDK source base. :( I'd say that access to JNIEXPORT is about 50% of the reason jni.h is included... |
No. And neither should we compile or link it with "-fvisibility=hidden". That is the root of |
If you suggest that we should not compile hsdis with hidden visibility, I disagree. I have been working hard on unifying build of native libraries across the entire product, to fix holes where we have not used a consistent way of compiling and/or linking. There is no reason to tread hsdis differently. If I restore using hidden visibility as an option that all native libraries, except hsdis, must opt in to, then we are just back to square one, and suddenly someone will forget about it. Instead, now we set -fvisibility=hidden in configure so nobody can forget about it. That was the more general argument for alinging compilation and linking flags and behavior across the product. Regarding the symbol visibility more specifically, there is also the question of consistency across platforms. On Windows, the behavior corresponding to "-fvisibility=hidden" is always turned on. Functions can only be exported if they are explicitly annotated in the source code (or specified otherwise to the linker). So we are in any case forced to export functions on Windows. Let's have a look at this patch. Currently we have code like:
Robbin proposes to change this to
My counter-proposal was to replace it with just |
(In fact, I think we have a problem everywhere in the code base where someone is using |
src/java.base/share/native/libzip/zlib/zconf.h:# define ZEXPORT __declspec(dllexport) ZEXPORT is only defined on win32, so we must build with default on linux. |
zlib is third party source that is copied into our repo. I did not mean that what I said for that applies to it. (Also, we should not really export any functions from zlib -- we encapsulate it in our own native shared library. I might have to look into if we are doing this wrong on Windows. But that is a separate question from this PR.) |
Okay, so the difference is that me and @theRealAph consider hsdis a thrid party library, although the JDK folks maintain it. (correct me if I'm wrong) |
It is original code in the JDK library. zlib is copied in from elsewhere. That is what I mean by third party code. The only reason hsdis is specially treated is due to the fact that the original implementation was based on binutils, which could not -- for legal reason -- be distributed as a compiled library alongside the JDK. That forced us to erect an artificial barrier. There are multiple JBS issues trying to rectify this, with different approaches, to get a non-binutils hsdis library build and shipped as any other native library in the JDK. |
How would you add jni.h ? |
Yes, that's what I would do.
OK, OK! So please can we get this fix in?
JNIEXPORT is better, I guess, but it does mean that hsdis is no longer standalone, and IMO it should have a pathological dependency on some JVM header file. That's the problem here. But really, whatever works is good with me. The last thing I want to do is delay this fix any further. Robbin has asked "How would you add jni.h ?" Is anyone going to answer? |
Ideally, it should just be enough to add To solve it you can either set |
I apologize for the late reply. I've been just working spotty hours due to spring break. |
Thanks, updated. (Since windows build seems to need HSDIS_TOOLCHAIN_DEFAULT_CFLAGS, just adding java.base:include seemed a good easy way) |
Riiiight. That is since we use a completely different compiler, gcc instead of cl. (Which is probably the worst hack in all of the JDK build system...) |
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.
Looks good to me now. Thanks for indulging me in doing it this way. :-)
I plan on adding support for using gcc to compile hsdis on Windows sometime soon (Like proper support for gcc as a toolchain on Windows, at least enough to support hsdis, so people can freely use any gcc instead of only being restricted to Cygwin), what might be an elegant solution to this issue, if you have any in mind? |
The proper solution is, I think, to encapsulate toolchain variables/definitions into a package, and update the build system to not assume anything about toolchains. In a proper language, I'd create like a That would require some major surgery of the build system, but I think it will come out better in the end. After that is done, fixing so that hsdis/binutils can be compiled with gcc on Windows will be a trivial side-effect. |
I apologize for my bad temper. 😀 Thanks to everyone working on this. I still think that hsdis ought not to have any dependencies on HotSpot, but I'm not going to be fanatical about it. |
I agree, good :) If everyone is 'okay' with this, can someone do the second review? |
Thank you @luhenry ! |
FYI: The 2-reviewer rule only applies to Hotspot (and some other specific parts of the code base), and not generally for JDK fixes. So you had been fine to push with just one reviewer. |
Yea, I know, but if hsdis is not an external library I considered it part of hotspot as it is the only use, hence I want two reviews. :) |
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.
Looks good.
Although I'm not the right person to review this, thanks for explanation and discussion.
/integrate |
Going to push as commit 1e02a13.
Your commit was automatically rebased without conflicts. |
Hi, please consider.
8327045 hide these symbols.
Tested with gcc and clang, and llvm and binutils backend.
I didn't find any use of the "DLL_ENTRY", so I removed it.
Thanks, Robbin
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18400/head:pull/18400
$ git checkout pull/18400
Update a local copy of the PR:
$ git checkout pull/18400
$ git pull https://git.openjdk.org/jdk.git pull/18400/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18400
View PR using the GUI difftool:
$ git pr show -t 18400
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18400.diff
Webrev
Link to Webrev Comment