Skip to content

8343698: Linux x86_64 lto build gives a lot of warnings and fails lto-wrapper: fatal error: make returned 2 exit status #22069

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

Closed
wants to merge 4 commits into from

Conversation

MBaesken
Copy link
Member

@MBaesken MBaesken commented Nov 13, 2024

When trying LTO (configure flag --enable-jvm-feature-link-time-opt=yes) on Linux x86_64, gcc 11.3.0, we run into a lot of warnings and finally into this error :

.. tons of free and malloc related warnings ...

    inlined from 'pop_segment' at src/hotspot/share/utilities/stack.inline.hpp:188:9,
    inlined from 'pop' at src/hotspot/share/utilities/stack.inline.hpp:84:30,
    inlined from 'pop_overflow' at src/hotspot/share/gc/shared/taskqueue.inline.hpp:231:28,
    inlined from 'trim_queue_to_threshold' at src/hotspot/share/gc/g1/g1ParScanThreadState.cpp:328:37:
src/hotspot/share/runtime/os.cpp:666:3: warning: call to 'malloc' declared with attribute warning: use os::malloc [-Wattribute-warning]
src/hotspot/share/runtime/os.cpp:666:3: warning: call to 'malloc' declared with attribute warning: use os::malloc [-Wattribute-warning]
In function 'malloc',
    inlined from 'malloc' at src/hotspot/share/runtime/os.cpp:637:0,
    inlined from 'AllocateHeap' at src/hotspot/share/memory/allocation.cpp:42:31,
    inlined from 'new_entry' at src/hotspot/share/nmt/mallocSiteTable.cpp:181:25,
    inlined from 'lookup_or_add' at src/hotspot/share/nmt/mallocSiteTable.cpp:122:48,
    inlined from 'allocation_at' at src/hotspot/share/nmt/mallocSiteTable.hpp:151:37,
    inlined from 'record_malloc' at src/hotspot/share/nmt/mallocTracker.cpp:179:35,
    inlined from 'record_malloc' at src/hotspot/share/nmt/memTracker.hpp:81:42,
    inlined from 'realloc' at src/hotspot/share/runtime/os.cpp:746:58,
    inlined from 'ReallocateHeap' at src/hotspot/share/memory/allocation.cpp:59:32,
    inlined from 'grow' at src/hotspot/share/utilities/ostream.cpp:377:15,
    inlined from 'write' at src/hotspot/share/utilities/ostream.cpp:400:11,
    inlined from 'write' at src/hotspot/share/utilities/ostream.cpp:382:0,
    inlined from 'put' at src/hotspot/share/utilities/ostream.cpp:212:8,
    inlined from 'print_ascii_form' at src/hotspot/share/runtime/os.cpp:965:19,
    inlined from 'print_hex_location' at src/hotspot/share/runtime/os.cpp:1008:21,
    inlined from 'print_hex_dump' at src/hotspot/share/runtime/os.cpp:1050:23,
    inlined from 'print_hex_dump' at src/hotspot/share/runtime/os.hpp:869:19,
    inlined from 'print_block_on_error' at src/hotspot/share/nmt/mallocHeader.cpp:64:23,
    inlined from 'resolve_checked_impl' at src/hotspot/share/nmt/mallocHeader.inline.hpp:106:41,
    inlined from 'resolve_checked' at src/hotspot/share/nmt/mallocHeader.inline.hpp:113:66,
    inlined from 'record_free_block' at src/hotspot/share/nmt/mallocTracker.cpp:206:55,
    inlined from 'record_free' at src/hotspot/share/nmt/memTracker.hpp:93:44,
    inlined from 'free' at src/hotspot/share/runtime/os.cpp:787:54,
    inlined from 'free' at src/hotspot/share/runtime/os.cpp:773:0,
    inlined from 'FreeHeap' at src/hotspot/share/memory/allocation.cpp:68:11,
    inlined from 'free' at src/hotspot/share/utilities/stack.inline.hpp:148:0,
    inlined from 'pop_segment' at src/hotspot/share/utilities/stack.inline.hpp:188:9,
    inlined from 'pop' at src/hotspot/share/utilities/stack.inline.hpp:84:30,
    inlined from 'pop_overflow' at src/hotspot/share/gc/shared/taskqueue.inline.hpp:231:28,
    inlined from 'trim_queue_to_threshold' at src/hotspot/share/gc/g1/g1ParScanThreadState.cpp:328:37:
src/hotspot/share/runtime/os.cpp:666:3: warning: call to 'malloc' declared with attribute warning: use os::malloc [-Wattribute-warning]
src/hotspot/share/runtime/os.cpp:666:3: warning: call to 'malloc' declared with attribute warning: use os::malloc [-Wattribute-warning]

src/hotspot/share/runtime/os.cpp:666:3: warning: call to 'malloc' declared with attribute warning: use os::malloc [-Wattribute-warning]
g++: fatal error: Killed signal terminated program lto1
compilation terminated.
make[4]: *** [/tmp/cc6nPei6.ltrans63.ltrans.o] Error 1
make[4]: *** Waiting for unfinished jobs....

Looks like the flattening attribute usage in src/hotspot/share/gc/g1/g1ParScanThreadState.cpp causes the issues.
So it was discussed to remove the flattening attributes in this file but this was not seen as a good idea. So better disable lto when building this special file with gcc .


Progress

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

Issue

  • JDK-8343698: Linux x86_64 lto build gives a lot of warnings and fails lto-wrapper: fatal error: make returned 2 exit status (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22069

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 13, 2024

👋 Welcome back mbaesken! 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 13, 2024

@MBaesken 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:

8343698: Linux x86_64 lto build gives a lot of warnings and fails lto-wrapper: fatal error: make returned 2 exit status

Reviewed-by: ihse, jwaters

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 214 new commits pushed to the master branch:

  • 93aa7e2: 8328085: C2: Use after free in PhaseChaitin::Register_Allocate()
  • 10def48: 8344236: Revisit SecurityManager usage in jdk.net after JEP 486 integration
  • 7105bb9: 8344664: Remove some un-used java/sun.security imports in the java.desktop module
  • a01aa22: 8342281: Deprecate for removal javax.sound.sampled.AudioPermission
  • 4fbf272: 8344526: RISC-V: implement -XX:+VerifyActivationFrameSize
  • 1343911: 8340334: Update jcmd VM.events max parameter to be INT
  • 400eb9b: 8344524: Remove SecurityManager related code from jdk.jlink module
  • a599c30: 8344471: Remove SecurityManager related code from java.compiler module
  • b9bf447: 8344057: Remove doPrivileged calls from unix platform sources in the java.desktop module
  • da2d7a0: 8344595: State transitions in internal VirtualThread comment needs to be updated
  • ... and 204 more: https://git.openjdk.org/jdk/compare/e5eaa7f1eb0cb072d02bc18e23b0daaee875b077...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title JDK-8343698: Linux x86_64 lto build gives a lot of warnings and fails lto-wrapper: fatal error: make returned 2 exit status 8343698: Linux x86_64 lto build gives a lot of warnings and fails lto-wrapper: fatal error: make returned 2 exit status Nov 13, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 13, 2024
@openjdk
Copy link

openjdk bot commented Nov 13, 2024

@MBaesken The following label will be automatically applied to this pull request:

  • build

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the build build-dev@openjdk.org label Nov 13, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 13, 2024

Webrevs

@TheShermanTanker
Copy link
Contributor

TheShermanTanker commented Nov 13, 2024

Could we simply disable the attribute warning for the affected area with a comment explaining why the warning is disabled as a workaround rather than disabling LTO for the whole file? This current solution would cause decline in the quality of the resulting assembly when LTO is enabled

@MBaesken
Copy link
Member Author

Could we simply disable the attribute warning for the affected area as a workaround rather than disabling LTO for the whole file? This current solution would cause decline in the quality of the compiled assembly in g1ParScanThreadState.cpp when LTO is enabled

We can try but I am not sure how to do it (and not sure if this will fix the build error) .

@TheShermanTanker
Copy link
Contributor

TheShermanTanker commented Nov 13, 2024

From a cursory glance it seems that the problem is with trim_queue_to_threshold. I see 3 possible solutions, from most likely to work to least likely. I'll try to test them and come back to you

// See 8343698 for why this is NOINLINE
// FIXME: This worsens code quality by inhibiting compiler inlining heuristics, but is the only solution for now
NOINLINE void* os::malloc(size_t size, MemTag mem_tag, const NativeCallStack& stack)
DISABLED_WARNINGS_gcc_linux_g1ParScanThreadState.cpp := attribute-warning, \
// See 8343698 for the reason this workaround is in place
PRAGMA_DIAG_PUSH
PRAGMA_DISABLE_GCC_WARNING("-Wattribute-warning")
// trim_queue_to_threshold definition here
PRAGMA_DIAG_POP

@MBaesken
Copy link
Member Author

Hi Julian ,

From a cursory glance it seems that the problem is with trim_queue_to_threshold. I see 3 possible solutions, from most likely to >work to least likely. I'll try to test them and come back to you

thanks for looking into it! Maybe you find something better than disabling lto for the file (or disabling the flatten attributes in the file).

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 think the approach being taken by the proposed changes is not the right way to
address the issue.

# disable lto in g1ParScanThreadState because of special inlining/flattening used there
ifeq ($(call check-jvm-feature, link-time-opt), true)
BUILD_LIBJVM_g1ParScanThreadState.cpp_CXXFLAGS := -fno-lto
endif

Choose a reason for hiding this comment

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

Even with this change I still get ~200 warnings when building with gcc13.2,
mostly -Wattribute-warning. This is consistent with what I reported previously
with ATTRIBUTE_WARNING as a nop. So this change isn't sufficient.

I'm also not sure it's desirable. We don't know the impact of LTO on top of
flattening. It might be beneficial. This change ought to come with some
performance measurements, if made at all. And not under the rubric of a
warnings fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

There are quite a number of things in HotSpot that seemingly wouldn't work with LTO enabled. One notable example is os::current_stack_pointer, which on many platforms simply returns the frame pointer of os::current_stack_pointer or the address of a local inside os::current_stack_pointer. With LTO enabled this becomes eligible for inlining, and the "stack pointer" ends up becoming the frame pointer of the caller, which is not correct. Fixing these issues and making LTO viable is one of the things I hope to do, although not now

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm ... I thought we had LTO enabled in the past for Java SE Embedded ...

Copy link
Member Author

Choose a reason for hiding this comment

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

And not under the rubric of a warnings fix.

Maybe the title is a bit misleading, it is more about a build fix (lto build did not work for me with gcc 11.3.0; with this fix it works).
If the lot stuff is broken and there is no intent to fix it, we might consider removing it (but fixing it would probably be better).

Copy link
Contributor

Choose a reason for hiding this comment

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

I would hope that LTO won't be removed. I plan to try making it viable, and I also use it downstream on Windows. I'm having trouble downgrading my gcc package on WSL to reproduce the warning, so might take me some time to find a better fix

Choose a reason for hiding this comment

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

For the record, I'm seeing 3 warnings, 2 of which are for the same code. Both
are -Walloc-size-larger-than= warnings for calls to operator new[].

In gtestMain.cpp, in init_jvm, new JavaVMOption[num_jvm_options] is being
warned about. The warning is obviously wrong, as the value it is complaining
about uint64_max, while the variable has int type.

The other is in (non-Windows) CreateArgvFromArgs in gtest-death-test.cc, and
is being too conservative about value bounds, so also wrong.

So both of these appear to be LTO bugs.

Of course, it's not possible to suppress these warnings via pragmas, because
of the bug that LTO doesn't honor such.

Copy link
Member

Choose a reason for hiding this comment

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

Catching up with the discussion...

LTO has been working before, and was indeed enabled for the old embedded platform. Since then, it has not been regularly tested and has certainly bit-rottet.

I think it is a good thing to try to keep it alive. There is potential for big performance improvements, even if that will only be utilized for special builds. The additional build time is the main culprit here. But it is possible that, as Kim says, the entire build is perhaps "just" slowed down by a factor of 2x, and that might be acceptable, even if the Hotspot build is slowed down several magnitudes.

Also, there are many promising efforts going on right now, that is trying to get some or all of the LTO benefits in different ways. In particular, iirc, the LLVM linker lld has some kind of "partial LTO" which, iiuc, tries to pick the most important aspeect of LTOs but implemented in a way that has minimal build performance impact.

It is not entirely clear what correspondence there is between keeping the traditional gcc LTO alive, and being able to use this new clang partial LTO, but as a reasonable first guess it will be helpful to keep it working.

Copy link
Contributor

@TheShermanTanker TheShermanTanker Nov 15, 2024

Choose a reason for hiding this comment

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

The old LTO used to set -O3 directly on both LDFLAGS and CFLAGS, bypassing OPTIMIZATION variable entirely. Just wanted to put this out there, since the topic of traditional gcc LTO came up. I changed that to set OPTIMIZATION to HIGHEST_JVM some time ago, and I'm not sure whether my change played any part in breaking LTO

LTO is currently only supported for VC and gcc. I can look into how to implement it for clang, though not now. First I'm committed to fixing all the issues with LTO, and making sure Kim's worry of poisoning virtually disappearing when LTO is enabled doesn't become a reality

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, we should support LTO for gcc AND clang on Linux/macOS.
Regarding the longer link/build times , I can add some info how much longer it takes in our environment (SUSE Linux/gcc).

Copy link
Contributor

Choose a reason for hiding this comment

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

I can add some info here: On Windows, with LTO enabled it takes gcc about 15-20 minutes to link the JVM, without it takes anywhere between 8-10 minutes to do so. ld is very slow on Windows due to a bug, so the numbers are skewed towards the high end. I don't have any numbers for VC, but I can assume that even LTO with VC and link.exe is very fast, because VC in general is an extremely fast compiler

@@ -170,12 +170,12 @@ ifeq ($(call check-jvm-feature, link-time-opt), true)
# later on if desired
JVM_OPTIMIZATION := HIGHEST_JVM
ifeq ($(call isCompiler, gcc), true)
JVM_CFLAGS_FEATURES += -flto=auto -fuse-linker-plugin -fno-strict-aliasing \
JVM_CFLAGS_FEATURES += -DINCLUDE_LTO=1 -flto=auto -fuse-linker-plugin -fno-strict-aliasing \

Choose a reason for hiding this comment

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

I'm not sure why this was included in this PR (and similarly below), since
there's no use of it anywhere. However, it would be useful for
conditionalizing the definition of FORBID_C_FUNCTION, as suggested in JBS. But
just adding the defines here is not sufficient. In utilities/macros.hpp, there
should be a conditional #define to the default value (0) if the macro is not
already defined, so that we can consistently use #if INCLUDE_LTO and
#if !INCLUDE_LTO.

Copy link
Member Author

@MBaesken MBaesken Nov 14, 2024

Choose a reason for hiding this comment

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

It was included because all JVM features have a related define (e.g. INCLUDE_JFR, INCLUDE_JVMCI) and I missed that one here.
Or is it already available and I just missed the define related to link-time-optimization ?
But in a way you are correct , currently the added define it not needed technically in this PR .
And we might think about the naming (INCLUDE_LINK_TIME_OPTIMIZATION vs. INCLUDE_LTO).

Choose a reason for hiding this comment

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

I'd prefer a more meaningful name. LTO seems a little generic and opaque. If you know then you
know, but if you don't then you are puzzled.

Copy link
Member Author

Choose a reason for hiding this comment

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

I renamed the define to INCLUDE_LINK_TIME_OPTIMIZATION.

@MBaesken
Copy link
Member Author

In utilities/macros.hpp, there
should be a conditional #define to the default value (0) if the macro is not
already defined, so that we can consistently use #if INCLUDE_LTO and
#if !INCLUDE_LTO.

If you want me to change that I can add the handling of INCLUDE_LINK_TIME_OPTIMIZATION to macros.hpp . But unlikely many other macros the LTO JVM feature is usually not enabled, so this would mean we would set for every compilation unit -DINCLUDE_LINK_TIME_OPTIMIZATION=0 which bloats the build log even more.

@@ -170,12 +170,12 @@ ifeq ($(call check-jvm-feature, link-time-opt), true)
# later on if desired
JVM_OPTIMIZATION := HIGHEST_JVM
ifeq ($(call isCompiler, gcc), true)
JVM_CFLAGS_FEATURES += -flto=auto -fuse-linker-plugin -fno-strict-aliasing \
JVM_CFLAGS_FEATURES += -DINCLUDE_LINK_TIME_OPTIMIZATION=1 -flto=auto -fuse-linker-plugin -fno-strict-aliasing \
Copy link
Member

Choose a reason for hiding this comment

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

I don't get this. I find no pre-existing INCLUDE_LINK_TIME_OPTIMIZATION ifdefs, and you are not adding any. What is the purpose of this?

Choose a reason for hiding this comment

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

I asked the same question. But as further discussion has indicated, we might need this define for
disabling the poisoning of selected C library functions when building with LTO, because LTO doesn't
support the mechanism used for that.

Copy link
Member Author

@MBaesken MBaesken Nov 18, 2024

Choose a reason for hiding this comment

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

I think all JVM features have these INCLUDE macros so I wanted to add it it for this JVM feature too. But I can remove it from the PR if it is just wanted for the other JVM features but not this one for some reason.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the link-time-opt feature is a bit different from the others -- it does not select a different set of sources to be compiled, but affects how the JVM is compiled/linked. I don't think there is a need to define these preprocessor macros just out of pure symmetry reason.

If it turns out in the future that we need to compile code differently, then we can add these defines at that time.

@kimbarrett
Copy link

In utilities/macros.hpp, there
should be a conditional #define to the default value (0) if the macro is not
already defined, so that we can consistently use #if INCLUDE_LTO and
#if !INCLUDE_LTO.

If you want me to change that I can add the handling of INCLUDE_LINK_TIME_OPTIMIZATION to macros.hpp . But unlikely many other macros the LTO JVM feature is usually not enabled, so this would mean we would set for every compilation unit -DINCLUDE_LINK_TIME_OPTIMIZATION=0 which bloats the build log even more.

There's no need to set it for every compilation unit. Like other feature handling in macros.hpp, something like this
needs to be added there:

#ifndef INCLUDE_LINK_TIME_OPTIMIZATION
#define INCLUDE_LINK_TIME_OPTIMIZATION 0
#endif

And of course, flip things if we later change to make LTO the default.

@MBaesken
Copy link
Member Author

As suggested, I moved INCLUDE_LINK_TIME_OPTIMIZATION to macros.hpp .

Regarding build time (of a scratch build) I saw no significant decrease for lto compared to my normal build , it was even a little faster (but it is on a server where more stuff is running than my build so probably the results are a bit influenced by this).
This was for the whole scratch build, not just looking at HS; gcc 11.3.0 devkit was used.

@MBaesken
Copy link
Member Author

Btw. regarding the disabling of lto for g1ParScanThreadState.cpp
g1ParScanThreadState.cpp_CXXFLAGS := -fno-lto
if I got that right, there might be a follow up by Julian making this local workaround unnecessary.

@MBaesken
Copy link
Member Author

MBaesken commented Nov 18, 2024

Those were the build time numbers (JOBS=16, SUSE 15 Linux x86_64, gcc 11.3.0 devkit)
lto build

real	6m50.307s
user	87m29.529s
sys	7m26.234s

non-lto

real	7m20.574s
user	84m28.755s
sys	7m10.073s

both builds were opt scratch builds, without gtest (--with-gtest=... removed from my build script).

@MBaesken
Copy link
Member Author

MBaesken commented Nov 18, 2024

A first nice advantage seems to be the smaller size of libjvm.so coming from the lto build;
lto build

du -sh images/jdk/lib/server/libjvm.so
22M	images/jdk/lib/server/libjvm.so

normal build

du -sh images/jdk/lib/server/libjvm.so
26M	images/jdk/lib/server/libjvm.so

This is in line to what TI claims here for some lto vs non-lto builds (but at TI for aarch/arm and not for x86_64)
https://software-dl.ti.com/codegen/docs/tiarmclang/compiler_tools_user_guide/compiler_manual/link_time_optimization/lto_benefits.html#code-size-reduction-due-to-use-of-lto

@MBaesken
Copy link
Member Author

MBaesken commented Nov 18, 2024

A first nice advantage seems to be the smaller size of libjvm.so coming from the lto build; lto build

du -sh images/jdk/lib/server/libjvm.so
22M	images/jdk/lib/server/libjvm.so

normal build

du -sh images/jdk/lib/server/libjvm.so
26M	images/jdk/lib/server/libjvm.so

This is in line to what TI claims here for some lto vs non-lto builds (but at TI for aarch/arm and not for x86_64) https://software-dl.ti.com/codegen/docs/tiarmclang/compiler_tools_user_guide/compiler_manual/link_time_optimization/lto_benefits.html#code-size-reduction-due-to-use-of-lto

When switching to size-optimization (adding --enable-jvm-feature-opt-size=yes to both the lto and 'normal' build) this changes to
lto build

du -sh images/jdk/lib/server/libjvm.so
17M	images/jdk/lib/server/libjvm.so

normal build

du -sh images/jdk/lib/server/libjvm.so
21M	images/jdk/lib/server/libjvm.so

@TheShermanTanker
Copy link
Contributor

There's no need to add the =yes at the end there, simply --enable-jvm-feature-link-time-opt or --enable-jvm-feature-opt-size will do

@MBaesken
Copy link
Member Author

On Linux ppc64le (uses also a gcc 11.3.0 devkit) the size improvements can be observed too when using lto .
Normal build

du -sh  images/jdk/lib/server/libjvm.so
27M	images/jdk/lib/server/libjvm.so

lto enabled

du -sh  images/jdk/lib/server/libjvm.so
21M	images/jdk/lib/server/libjvm.so

lto enabled + opt-size enabled

du -sh  images/jdk/lib/server/libjvm.so
16M	images/jdk/lib/server/libjvm.so

Copy link
Member

@magicus magicus left a comment

Choose a reason for hiding this comment

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

At this point, the PR looks good from a build perspective. I think you need buy-in from at least one Hotspot developer as well.

@magicus
Copy link
Member

magicus commented Nov 18, 2024

/reviewers 2

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 18, 2024
@openjdk
Copy link

openjdk bot commented Nov 18, 2024

@magicus
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Nov 18, 2024
@MBaesken
Copy link
Member Author

Hi Magnus, thanks for the review !
Can I have a second one please ?

Copy link
Contributor

@TheShermanTanker TheShermanTanker left a comment

Choose a reason for hiding this comment

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

I don't know if I count as a HotSpot developer, and admittedly I am still not very fond of these changes since they adversely affect the quality of the resulting assembly when LTO is active, but this gets a reluctant ok from me since without it LTO doesn't even work on Linux, and Kim doesn't seem very happy about disabling the attribute warning when LTO is on. I still think you should let @kimbarrett have the final say on whether this gets the go ahead or not. I hope we can work on removing this workaround as fast as possible

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 21, 2024
@MBaesken
Copy link
Member Author

Hi Julian, thanks for the review !
Any more comments / ideas ? Having the lto/gcc build fixed, even with a workaround, is much better than a broken build I think.
And even with lto disabled for one single file, I see good improvements in binary size when using lto.

@TheShermanTanker
Copy link
Contributor

Hi Julian, thanks for the review ! Any more comments / ideas ? Having the lto/gcc build fixed, even with a workaround, is much better than a broken build I think. And even with lto disabled for one single file, I see good improvements in binary size when using lto.

Yes, I agree that getting it working is more important. In the meantime, I am trying to find a solution to the FORBID_C_FUNCTION and LTO problem. It is my hope that I can find something that makes this workaround not needed, and quickly. But if you asked me if I had any ideas now, the only thing I can think of is to NOINLINE os::malloc, since that it where the inlined call to malloc originates from. But I cannot replicate the LTO failure on my WSL install for some reason, so have no way of verifying if it works. Either way, this is probably ok, though might want to ask Kim for the final go ahead, since I don't know if I count as a HotSpot developer

@MBaesken
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 25, 2024

Going to push as commit 9576546.
Since your change was applied there have been 274 commits pushed to the master branch:

  • 68ba7ee: 8340205: Native linker allows MemoryLayout consisting of only PaddingLayout
  • 6f622da: 8344923: Problem list on java/awt/Robot/ScreenCaptureRobotTest.java on macOS
  • 8f08020: 8344903: Improve error handling TestJhsdbJstackPrintVMLocks.java
  • a83cfe2: 8344917: Fix recent NULL usage backsliding
  • 6711e13: 8344914: OOME in several tests since JDK-6672644 - JComboBox still scrolling
  • a6220fa: 8344303: Remove usage of URLUtil.getConnectPermission from sun.awt.SunToolkit and sun.awt.image.URLImageSource
  • 7be94d0: 8344891: Remove uses of sun.misc.ReflectUtil in java.desktop
  • 822a155: 8341427: JFR: Adjust object sampler span handling
  • d00f311: 8343150: Change URLClassLoader.getPermissions to return empty PermissionCollection
  • effee12: 8344533: CTW: Add option to remove clinits before loading
  • ... and 264 more: https://git.openjdk.org/jdk/compare/e5eaa7f1eb0cb072d02bc18e23b0daaee875b077...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 25, 2024
@openjdk openjdk bot closed this Nov 25, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 25, 2024
@openjdk
Copy link

openjdk bot commented Nov 25, 2024

@MBaesken Pushed as commit 9576546.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@TheShermanTanker
Copy link
Contributor

TheShermanTanker commented Nov 26, 2024

I spent a lot of time trying to come up with a different and more cross platform way of poisoning code within HotSpot that doesn't break on LTO. I think I'm almost there, but a few kinks need to be worked out first: https://godbolt.org/z/o1WPPexad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

5 participants