Skip to content
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

8345265: Fix gcc LTO without disabling LTO for g1ParScanThreadState.cpp #22464

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

TheShermanTanker
Copy link
Contributor

@TheShermanTanker TheShermanTanker commented Nov 30, 2024

JDK-8343698 fixed LTO for gcc when compiling for platforms where the FORBID_C_FUNCTION mechanism is active, however the fix does so by inhibiting LTO for a specific file. This can hinder optimization, which is the end goal if one is indeed doing an LTO build. Fix the issue in a different way by disabling FORBID_C_FUNCTION entirely for os.cpp, which is where the error originates. This has a wide downstream effect, as os.cpp contains a call to os::malloc which contains the forbidden malloc that causes errors that cannot be suppressed by ALLOW_C_FUNCTION in an LTO build. This is a stopgap fix until FORBID_C_FUNCTION is fixed to work properly with LTO on all platforms. While here, also fix a memory leak in jvmciEnv.cpp


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8345265: Fix gcc LTO without disabling LTO for g1ParScanThreadState.cpp (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22464/head:pull/22464
$ git checkout pull/22464

Update a local copy of the PR:
$ git checkout pull/22464
$ git pull https://git.openjdk.org/jdk.git pull/22464/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22464

View PR using the GUI difftool:
$ git pr show -t 22464

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22464.diff

Using Webrev

Link to Webrev Comment

@TheShermanTanker TheShermanTanker marked this pull request as draft November 30, 2024 00:36
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 30, 2024

👋 Welcome back jwaters! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 30, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title 8345265 8345265: Fix gcc LTO without disabling LTO for g1ParScanThreadState.cpp Nov 30, 2024
@openjdk
Copy link

openjdk bot commented Nov 30, 2024

@TheShermanTanker The following labels will be automatically applied to this pull request:

  • build
  • hotspot

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.

@TheShermanTanker TheShermanTanker marked this pull request as ready for review November 30, 2024 00:43
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 30, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 30, 2024

Webrevs

@TheShermanTanker TheShermanTanker marked this pull request as draft November 30, 2024 03:09
@openjdk openjdk bot removed the rfr Pull request is ready for review label Nov 30, 2024
Copy link

@kimbarrett kimbarrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only noticed this had been changed back to Draft after I was mostly done looking
at it. But I don't think this should be done this way, esp. since it didn't seem to work
(as in suppressing warnings from LTO) for me.

@@ -613,7 +613,7 @@ JVMCIEnv::~JVMCIEnv() {
if (_init_error_msg != nullptr) {
// The memory allocated in libjvmci was not allocated with os::malloc
// so must not be freed with os::free.
ALLOW_C_FUNCTION(::free((void*) _init_error_msg));
ALLOW_C_FUNCTION(::free, ::free((void*) _init_error_msg);)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do this bug fix change under a separate JBS issue & PR. I've created a JBS issue for it:
https://bugs.openjdk.org/browse/JDK-8345267
Fix memory leak in JVMCIEnv dtor

@@ -86,7 +86,7 @@
// so uses of functions that are both forbidden and fortified won't cause
// forbidden warnings in such builds.
#define FORBID_C_FUNCTION(signature, alternative) \
extern "C" __attribute__((__warning__(alternative))) signature;
[[gnu::warning(alternative)]] signature noexcept;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you making this change at all, let alone under this JBS issue?

Among other problems, noexcept is mostly irrelevant in HotSpot, since we build with
exceptions disabled. (There are a few places where noexcept affects semantics, like for
operator new, but otherwise there is no point.)

@@ -22,6 +22,9 @@
*
*/

// Stopgap fix until FORBID_C_FUNCTION can work properly with LTO
#define DISABLE_POISONING_STOPGAP

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed if not using LTO.

@@ -22,6 +22,9 @@
*
*/

// Stopgap fix until FORBID_C_FUNCTION can work properly with LTO
#define DISABLE_POISONING_STOPGAP

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far as I can tell, this doesn't work. I still get tons of -Wattribute-warnings when building
with LTO, because of similar problem from other files.

@@ -22,6 +22,9 @@
*
*/

// Stopgap fix until FORBID_C_FUNCTION can work properly with LTO
#define DISABLE_POISONING_STOPGAP

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents precompiled headers from being used for this file. -Winvalid-pch will warn if enabled.

@TheShermanTanker
Copy link
Contributor Author

I only noticed this had been changed back to Draft after I was mostly done looking at it. But I don't think this should be done this way, esp. since it didn't seem to work (as in suppressing warnings from LTO) for me.

Yeah, I had noticed that it didn't work too, which is why I returned it to draft. It also causes VC to explode when compiling the Windows HotSpot, so that isn't ideal. I guess returning g1ParScanThreadState.cpp to LTO status will have to wait until FORBID_C_FUNCTION is properly fixed up to be LTO proof

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants