-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8311846: Resolve duplicate 'Thread' related symbols with JDK static linking #17456
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 jiangli! A progress list of the required criteria for merging this PR into |
|
/contributor add Chuck Rasbold rasbold@google.com |
|
@jianglizhou Syntax:
User names can only be used for users in the census associated with this repository. For other contributors you need to supply the full name and email address. |
|
@jianglizhou 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. |
|
/contributor add Chuck Rasbold rasbold@google.com |
|
@jianglizhou |
|
Hooboy, this is an ugly solution, with some nasty side effects such as confusing error mesasges for developers and a very confusing debugger experience. Let's try to find a solution with a smaller blast radius. |
|
Hi @theRealAph Thanks for looking into this! #14808 comments touched on several options:
Earlier discussions and feedback seem to prefer options requiring non-large scale change (except hotspot namespace solution). If acceptable by everyone, direct renaming would be the least confusion causing option. Any other suggestions and ideas for resolving the Thanks! |
|
I was reading through the other PR for StringTable and was wonder how difficult it would be to wrap all of hotspot in namespace hotspot {}; using namespace hotspot; It would need a JEP as discussed in the other PR. Alternatively if there's a #ifdef you can use for renaming the Thread to HotspotThread for static linking only, it might make this change less worrysome. |
So the problem is that the user native code defines Thread as well - right? So this could keep happening for name after name depending on what native code is being linked. I second what @theRealAph said! This is really ugly. The way disparate libraries just get munged into a single namespace with static linking just seems wrong to me. At a minimum this hack should only be used when doing static linking as Coleen suggested. But I'd much prefer a solution that came from the tools doing the linking. |
|
Okay so now that I have context switched in the discussion from: what happened to doing a JEP for namespaces? |
|
Thanks @coleenp, @dholmes-ora. For using a hotspot namespace, there are probably similar complications like the symbol usages that the current PR addresses in src/hotspot/os_cpu/linux_aarch64/threadLS_linux_aarch64.S and src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/Thread.java. There might also be some complications with accessing hotspot code in JNI code. Those issues probably could be resolved relatively easily, I haven't experimented it. It seems that we may be converging on using hotspot namespace? For just redefining the symbol only when doing static linking, it adds more differences between the static and non-static support. It's more useful when we can create both |
Based on previous discussions I had been expecting to see a JEP on this after last US summer. I was surprised to see this PR pop up in this form. |
Ah, I see. Thanks for the clarification. I had an offline conversation with @iklam about the namespace and JEP topic during during last August JVM Language Summit. Based on the feedback from the conversion, it was not very clear if the namespace approach was broadly acceptable. |
Using a default namespace for everything could have bad effects on debugging and other maintenance tools. it's unlikely to be a low-cost option. Perhaps it could be restricted to the static linking case, but that further complicates testing. |
|
You could support one build by adding something like -DSUPPORTS_STATIC_LINK for both .so and .a builds for Google, then use that to protect the renaming. I don't know how bad "namespace hotspot" would be for debugging. At least for some of the common names. I suppose breakpoints would have to be specified in gdb as break at hotspot::Thread::is_owning_thread or something like that, and with a using namespace hotspot, it wouldn't be visible looking at the source code in that form. |
Thanks. Agreed to both points. It seems to add too much complexities if the namespace usage is restricted to static linking case only. |
Thanks, @coleenp. I think that could work for all different cases. I'll reflect that in this PR. For longer term we probably still want to find a cleaner solution when the static support becomes more popular. |
I think you should be able to use ld and objcopy to merge the .o files and hide all of the symbols you don't want to export. |
We also discussed about |
I replied: OK, but it is the right thing to do on Linux. If some other operating systems don't provide useful tools, that's on them. If Windows really can't do it, that's no reason to burden systems that can. Namespaces are not a low-cost solution for developers. |
Thanks, @theRealAph. Yeah, I was mainly concerned about non-unix like systems, Windows particularly. It might not work on all potentially supported compilers ( jdk/make/common/NativeCompilation.gmk Line 1245 in 2003610
gcc for linux-aarch64. The details were captured in #14064 (comment) discussion with @erikj79. Only clang currently work well with the partial linking and symbol localizing solution.
Maybe we could live with symbol redefinition using #define (conditionally for static linking in OpenJDK, as Coleen suggested earlier) for now, until the tooling can support symbol localizing better. Then localizing symbols using tools like |
I suppose so, but why? Why should any of this have to work on old systems? If their binutils is broken, static linking of openjdk won't work there. |
We ran into issues with older gcc on linux-aarch for partial linking, but the problem may not be older gcc only(?). At the current stage, limiting static/hermetic Java runtime support to only the platforms that support partial linking and
Those are my reasonings. :-) |
I believe this to be a mistake. HotSpot, by design, exports only the symbols intended for use by other components. Many of the symbol names are highly generic, and will conflict with application code. Sure, you have enough to be able to do some prototyping, but for real-world deployment you must be able to control symbol exports. |
I agree with Andrew. We don't want the perfect to be the enemy of the good. The only "perfect" solution is putting the HotSpot code in a namespace. This is going to be a huge undertaking. I don't think we have enough interest in the OpenJDK community to make such a change now. I think partial linking with objcopy is a clean solution that's good enough for the actual use cases. If someone wants to use
|
I don't think that putting all of the HotSpot code in a namespace. At least, I hope not: it'll mess up debugging so much that it'll be intolerable, IMO, and there will be other side effects. |
I forgot to qualify "perfect" only in the sense of isolating the HotSpot symbols. It's obviously not perfect at all in other aspects. |
|
/label add build |
|
@magicus |
|
We (@AlanBateman, @cushon, @magicus, @jerboaa, @pron, @jianglizhou) discussed this topic via zoom as part of a regular static/hermetic Java discussions. The outcome favors the partial-linking/objcopy to localize symbols for hotspot. Here is a summary:
|
|
@jianglizhou This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
@jianglizhou this pull request can not be integrated into git checkout JDK-8311846
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
|
❗ This change is not yet ready to be integrated. |
|
@jianglizhou This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
@jianglizhou This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
Please review this PR with a simple solution for resolving duplicate
Threadsymbol issue. In #14808 comments, there was an alternative suggestion to redefine the symbol at build time, such as using-DThread=HotSpotThread. That would not address issues when symbol were references as string literals. #14808 also discussed using namespace for hotspot code, which can have multiple benefits/motivations. We could explore further using namespace with more consensus on that approach.Contributed by Chuck Rasbold and @jianglizhou.
Progress
Integration blockers
Issue
Contributors
<rasbold@google.com>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17456/head:pull/17456$ git checkout pull/17456Update a local copy of the PR:
$ git checkout pull/17456$ git pull https://git.openjdk.org/jdk.git pull/17456/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17456View PR using the GUI difftool:
$ git pr show -t 17456Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17456.diff
Webrev
Link to Webrev Comment