Conversation
Replace hardcoded instances of `-lpthread` with `$(LIBPTHREAD)`, so that it's possible to parameterize this for platforms that use different flags for enabling posix threads. This work is a continuation of the work done by Greg Lewis in [1], but generalized for the full JDK, and set at the configure stage. Sponsored by: The FreeBSD Foundation Co-authored-by: Greg Lewis <glewis@eyesbeyond.com> [1]: battleblow/jdk23u@dbd90aa
|
👋 Welcome back snake66! A progress list of the required criteria for merging this PR into |
|
@snake66 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 32 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 (@dholmes-ora, @erikj79, @magicus) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
@snake66 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. |
Webrevs
|
dholmes-ora
left a comment
There was a problem hiding this comment.
Abstracting this out seems reasonable to me, though I should say I thought we already used -pthread rather than -lpthread.
Needs build team approval before integrating.
I noticed there were a few places that used |
| BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libnativeStack += -lpthread | ||
| BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libTestUnloadedClass += -lpthread | ||
| BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exeGetCreatedJavaVMs := -lpthread | ||
| BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libbootclssearch_agent += $(LIBPTREAD) |
There was a problem hiding this comment.
Hi. Should this read $(LIBPTHREAD) instead (i.e., missing H)?
Could be me too, I need new reading glasses...
There was a problem hiding this comment.
You're absolutely right.
@snake66 Making changes to makefiles is tricky, since a misspelled variable do not get any warning but is just silently ignored.
For a change like this, that is a pure refactoring that is not supposed to change the output, I highly recommend using the COMPARE_BUILD system. Unfortunately, this is severely underdocumented. There is a short paragraph at https://openjdk.org/groups/build/doc/building.html under "Developing the Build System Itself", but in short, what I'd do is to create a diff files of these changes compared to a baseline (e.g. master, a specific build or commit), make sure you have the baseline checked out, and then run make jdk-image test-image COMPARE_BUILD=PATCH=my_patch.diff. This will build the targets twice, one without the patch and one with the patch, and then automatically run the compare script to analyze any differences. For this particular patch, there should be none. This would likely have caught this typo. (Given that the test-image is actually compared; I suddenly got a bit uncertain about that...)
|
/reviewers 2 reviewers |
erikj79
left a comment
There was a problem hiding this comment.
What is the intended way of using this? Do you run make with LIBPTHREAD=-pthread or do you apply a patch on libraries.m4 for the specific way of linking to pthread?
| # Threading library | ||
| if test "x$OPENJDK_TARGET_OS" = xlinux || test "x$OPENJDK_TARGET_OS" = xaix; then | ||
| BASIC_JVM_LIBS="$BASIC_JVM_LIBS -lpthread" | ||
| BASIC_JVM_LIBS="$BASIC_JVM_LIBS $(LIBPTHREAD)" |
There was a problem hiding this comment.
If you specifically need this to be resolved in the makefile rather than here, then please add a comment explaining why, otherwise use a shell script variable reference.
| BASIC_JVM_LIBS="$BASIC_JVM_LIBS $(LIBPTHREAD)" | |
| BASIC_JVM_LIBS="$BASIC_JVM_LIBS $LIBPTHREAD" |
There was a problem hiding this comment.
Yes, this is incorrect. Remember that m4 are shell scripts so you need to use shell syntax here. (I know it is confusing).
There was a problem hiding this comment.
@erikj79 There will be a later patch to libraries.m4 that sets the variable based on the target platform, and then populates the LIBPTHREAD variable in spec.gmk. (https://github.com/openjdk/jdk/pull/23930/files#diff-56172cd2ec5804a5f764a6d0d5970da6144b024a06e008571f9822b2dc83cc36R147) That means the parenthesis should stay, right?
There was a problem hiding this comment.
I'm not sure what you mean now. The link is to this very patch, which does what you describe -- sets LIBPTHREAD according to OS and stores it in spec.gmk.
And no, the paranthesis should not stay. If you keep them, the variable will be re-evaluated in make every time BASIC_JVM_LIBS is evaluated. That is not needed; by dropping the parenthesis the actual value to be used will be inserted as a string constant. Which is what we want, since we know the value at configure time.
This is in preparation of the upcoming BSD port, which uses |
| HSDIS_TOOLCHAIN_LIBS := $(MINGW_DLLCRT) -lmingw32 -lgcc -lgcc_eh -lmoldname \ | ||
| -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 | ||
| -lmingwex -lmsvcrt $(LIBPTHREAD) -ladvapi32 -lshell32 -luser32 -lkernel32 | ||
| else |
There was a problem hiding this comment.
The hsdis build is very weird and outside the normal integrated JDK build. I recommend you leave this instance alone. If you want to port hsdis to BSD you are likely to have to rewrite large parts of the compilation logic here anyway.
There was a problem hiding this comment.
Ack, I'll drop that one from the patch.
|
@magicus why can't we just use |
|
@dholmes-ora Good question. I don't know the answer. I know we used Regardless, I would still like to see this change. We have generalized almost all system libraries to variable (like We can then check if we can turn |
|
Another follow-up is if it would hurt to include $LIBPTHREAD for all Hotspot tests, to avoid the huge list. @dholmes-ora Do you have anything coming to mind directly that would make that infeasible, or is it just a matter of testing to add it and see if any tests fail? |
|
@snake66 To integrate this, you need to give the command |
|
/integrate |
|
/sponsor |
|
Going to push as commit b957e5e.
Your commit was automatically rebased without conflicts. |
|
@sendaoYan @snake66 Pushed as commit b957e5e. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Sorry I was out of contact for a while. I can't imagine why any test would fail if linked with libpthread, given the VM is linking to it anyway.
I have a vague recollection that at one time |
I'm happy to test this, if you want. Won't have time this week, though. |
Is there any gain then in changing away from |
True - what we have works and using |
Replace hardcoded instances of
-lpthreadwith$(LIBPTHREAD), so that it's possible to parameterize this for platforms that use different flags for enabling posix threads.This work is a continuation of the work done by Greg Lewis in 1, but generalized for the full JDK, and set at the configure stage.
Sponsored by: The FreeBSD Foundation
Co-authored-by: Greg Lewis glewis@eyesbeyond.com
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23930/head:pull/23930$ git checkout pull/23930Update a local copy of the PR:
$ git checkout pull/23930$ git pull https://git.openjdk.org/jdk.git pull/23930/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23930View PR using the GUI difftool:
$ git pr show -t 23930Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23930.diff
Using Webrev
Link to Webrev Comment