-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
8351322: Parameterize link option for pthreads #23930
base: master
Are you sure you want to change the base?
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 <[email protected]> [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 30 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
|
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.
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 |
make/test/JtregNativeHotspot.gmk
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...)
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.
/reviewers 2 reviewers |
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.
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?
make/autoconf/libraries.m4
Outdated
@@ -139,7 +139,7 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES], | |||
# 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
make/Hsdis.gmk
Outdated
@@ -127,7 +127,7 @@ ifeq ($(HSDIS_BACKEND), binutils) | |||
HSDIS_LDFLAGS += -L$(MINGW_GCC_LIB_PATH) -L$(MINGW_SYSROOT_LIB_PATH) | |||
MINGW_DLLCRT := $(MINGW_SYSROOT_LIB_PATH)/dllcrt2.o | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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 looks good now. Thanks!
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 |
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 [email protected]
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23930/head:pull/23930
$ git checkout pull/23930
Update a local copy of the PR:
$ git checkout pull/23930
$ git pull https://git.openjdk.org/jdk.git pull/23930/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23930
View PR using the GUI difftool:
$ git pr show -t 23930
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23930.diff
Using Webrev
Link to Webrev Comment