jdk8u-dev icon indicating copy to clipboard operation
jdk8u-dev copied to clipboard

8281096: Flags introduced by configure script are not passed to ADLC build

Open gnu-andrew opened this issue 1 year ago • 32 comments

The 8u configure script defines compiler flags in EXTRA_CFLAGS, EXTRA_LDFLAGS and EXTRA_ASFLAGS. Some are added by configure tests, while others are taken directly from corresponding options passed by the user.

8u still use the legacy HotSpot build system which is not fully integrated with the autoconf system. Variables defined by configure thus have to be explicitly passed down to the separate HotSpot build.

ADLC is a tool used at build-time and so the flags it uses don't impact on the end product. So, for a long time, it has been ignoring these flags defined by configure and using just its own minimal set.

However, with newer compilers, this means that the code is compiled to a newer version of the C++ standard, as the default has changed in GCC 6 and later (see JDK-8151841). With the latest versions of GCC (11 and 12), this actually leads to build failures due to the use of 'register' (GCC 11) and the way comments are used (GCC 12) in the code.

We should fix the ADLC build to use the same flags as the rest of the build. The impact should be negligible, given the same flags are already used in the code that is actually shipped.

This does not affect 9+ where HotSpot's build system has been replaced with full integration in the autoconf system.

With this change, 8u can be built with GCC 11 on GNU/Linux. I'd appreciate testing on other platforms, particularly those not covered by GHA (Solaris, AIX - @adamfarley, @sxa & @deepa181 who have provided previous fixes for these platforms)

During testing, we found we could not use the EXTRA_ prefixed variables as they include flags for the target compiler on cross-compilation builds. To fix this, we split out new HOST_ prefixed variables which include all the flags of the EXTRA_ prefixed variables, bar the --sysroot options.


Progress

  • [x] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [ ] JDK-8281096 needs maintainer approval
  • [x] Commit message must refer to an issue

Issue

  • JDK-8281096: Flags introduced by configure script are not passed to ADLC build (Bug - P4 - Requested)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk8u-dev.git pull/357/head:pull/357
$ git checkout pull/357

Update a local copy of the PR:
$ git checkout pull/357
$ git pull https://git.openjdk.org/jdk8u-dev.git pull/357/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 357

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk8u-dev/pull/357.diff

Webrev

Link to Webrev Comment

gnu-andrew avatar Aug 23 '23 03:08 gnu-andrew

:wave: Welcome back andrew! 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.

bridgekeeper[bot] avatar Aug 23 '23 04:08 bridgekeeper[bot]

Hi @gnu-andrew , It successfully built on jdk8u-dev on AIX. This is a positive sign that the changes are effective. Please let me know for further assistance. I would be happy to check. Thank You.

deepa181 avatar Sep 04 '23 12:09 deepa181

@gnu-andrew 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!

bridgekeeper[bot] avatar Oct 02 '23 17:10 bridgekeeper[bot]

@gnu-andrew 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 /open pull request command.

bridgekeeper[bot] avatar Oct 30 '23 18:10 bridgekeeper[bot]

/open

@deepa181 thanks for the feedback. It's good to know it doesn't break AIX. @tstuefe good catch. I need to find out why LFLAGS is missing on Solaris (assuming at the moment it's not used generally) and also check why it seemed to be failing on cross-compiles (we don't use them ourselves so that is untested prior to this)

gnu-andrew avatar Nov 20 '23 18:11 gnu-andrew

@gnu-andrew This pull request is now open

openjdk[bot] avatar Nov 20 '23 18:11 openjdk[bot]

@gnu-andrew 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!

bridgekeeper[bot] avatar Dec 19 '23 02:12 bridgekeeper[bot]

@gnu-andrew 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 /open pull request command.

bridgekeeper[bot] avatar Jan 16 '24 10:01 bridgekeeper[bot]

/open

gnu-andrew avatar Jan 22 '24 19:01 gnu-andrew

@gnu-andrew This pull request is now open

openjdk[bot] avatar Jan 22 '24 19:01 openjdk[bot]

@gnu-andrew Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

openjdk[bot] avatar Jan 24 '24 01:01 openjdk[bot]

Looks good and makes sense. Why not passing LFLAGS to solaris?

It seems this matches what Solaris does in vm.make. These new lines are effectively just copied over from vm.make which handles the rest of the build, and for some reason, Solaris does not set LFLAGS for the VM build either.

gnu-andrew avatar Jan 24 '24 01:01 gnu-andrew

I think I know what's wrong here now with the cross-compilation builds. The EXTRA_CFLAGS that HotSpot gets end up including the --sysroot options on cross-compile builds, which are really destined for the target compiler, not a build compiler which is compiling a build tool that is going to be run during the build.

I can fix this, but it's going to make this fix a bit more involved than I initially thought.

gnu-andrew avatar Feb 19 '24 16:02 gnu-andrew

Mailing list message from Thorsten Glaser on jdk8u-dev:

On Mon, 19 Feb 2024, Andrew John Hughes wrote:

I think I know what's wrong here now with the cross-compilation builds. The `EXTRA_CFLAGS` that HotSpot gets end up including the `--sysroot` options on cross-compile builds, which are really destined for the target compiler, not a build compiler which is compiling a build tool that is going to be run during the build.

Ouch. So no clean distinction between CFLAGS and HOSTCFLAGS?

I can fix this, but it's going to make this fix a bit more involved than I initially thought.

Yocto has an ugly workaround: https://github.com/ostroproject/ostro-os/blob/master/meta-java/recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-adlc-flags.patch

bye, //mirabilos -- Infrastrukturexperte ? Qvest Digital AG Am Dickobskreuz 10, D-53121 Bonn ? https://www.qvest-digital.com/ Telephon +49 228 54881-393 ? Fax: +49 228 54881-235 HRB AG Bonn 18196 ? USt-ID (VAT): DE274355441 Vorstand: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg Vorsitzender Aufsichtsrat: Peter N?then

mlbridge[bot] avatar Feb 20 '24 11:02 mlbridge[bot]

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

openjdk[bot] avatar Mar 13 '24 20:03 openjdk[bot]

@gnu-andrew 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!

bridgekeeper[bot] avatar Apr 11 '24 03:04 bridgekeeper[bot]

@gnu-andrew Finally got around to looking at this (and this comment will stop the bot trying to close it!) and performed an initial test on Linux/aarch64 before trying elsewhere. I can build ok with GCC 10.3 but not 11.2 due to this error:

/home/sxa/temurin-build/build-farm/workspace/build/src/hotspot/src/share/vm/opto/type.cpp:2556:71: error: 'this' pointer is null [-Werror=nonnull]

sxa avatar May 02 '24 16:05 sxa

Solaris build of this branch using our default Sun Studio compiler seems to build ok (x64 and SPARC) 👍🏻

sxa avatar May 02 '24 18:05 sxa

@gnu-andrew Finally got around to looking at this (and this comment will stop the bot trying to close it!) and performed an initial test on Linux/aarch64 before trying elsewhere. I can build ok with GCC 10.3 but not 11.2 due to this error:

/home/sxa/temurin-build/build-farm/workspace/build/src/hotspot/src/share/vm/opto/type.cpp:2556:71: error: 'this' pointer is null [-Werror=nonnull]

Thanks for verifying this. Once we can get this change in, I'll look and replicating other failures and resolving those. I think the type.cpp one has been raised in a few other places, but I've not seen it myself (maybe it requires warnings as errors)

gnu-andrew avatar May 22 '24 15:05 gnu-andrew

Mailing list message from Thorsten Glaser on jdk8u-dev:

On Mon, 19 Feb 2024, Andrew John Hughes wrote:

I think I know what's wrong here now with the cross-compilation builds. The EXTRA_CFLAGS that HotSpot gets end up including the --sysroot options on cross-compile builds, which are really destined for the target compiler, not a build compiler which is compiling a build tool that is going to be run during the build.

Ouch. So no clean distinction between CFLAGS and HOSTCFLAGS?

Yes, this is the conclusion I've come to as well.

I can fix this, but it's going to make this fix a bit more involved than I initially thought.

Yocto has an ugly workaround: https://github.com/ostroproject/ostro-os/blob/master/meta-java/recipes-core/openjdk/patches-openjdk-8/openjdk8-fix-adlc-flags.patch

Ah good to see someone else has encountered this. I think we can resolve it in a similar way, but by defining a new flag in configure rather than trying to filter things apart later.

bye, //mirabilos -- Infrastrukturexperte ? Qvest Digital AG Am Dickobskreuz 10, D-53121 Bonn ? https://www.qvest-digital.com/ Telephon +49 228 54881-393 ? Fax: +49 228 54881-235 HRB AG Bonn 18196 ? USt-ID (VAT): DE274355441 Vorstand: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg Vorsitzender Aufsichtsrat: Peter N?then

gnu-andrew avatar May 22 '24 15:05 gnu-andrew

I've rewritten the patch so it now uses HOST_CFLAGS and HOST_LDFLAGS in the ADLC build. These are created in configure by not including the sysroot arguments.

The below shows the old and new flags in the aarch64 cross-compile, which now passes:

# Retain EXTRA_{CFLAGS,CXXFLAGS,LDFLAGS,ASFLAGS} for the target flags to
# maintain compatibility with the existing Makefiles
EXTRA_CFLAGS= --sysroot="/home/runner/sysroot-arm64/" -fstack-protector  $(NO_DELETE_NULL_POINTER_CHECKS_CFLAG) \
				    $(NO_LIFETIME_DSE_CFLAG) $(CXXSTD_CXXFLAG)
EXTRA_CXXFLAGS= --sysroot="/home/runner/sysroot-arm64/" -fstack-protector 
EXTRA_LDFLAGS= --sysroot="/home/runner/sysroot-arm64/" -Wl,-z,relro 
EXTRA_ASFLAGS=
# Define an equivalent set for the host flags (i.e. without sysroot options)
HOST_CFLAGS= -fstack-protector  $(NO_DELETE_NULL_POINTER_CHECKS_CFLAG) \
				 $(NO_LIFETIME_DSE_CFLAG) $(CXXSTD_CXXFLAG)
HOST_CXXFLAGS= -fstack-protector 
HOST_LDFLAGS= -Wl,-z,relro
HOST_ASFLAGS=

I'll remove the verbose build log now, but leave the printing of the spec files as I think it does no harm and may be useful for future debugging.

The remaining failures are due to download issues (Debian Buster release on some architectures, Windows VS2010) and the cacerts tests, both of which are not caused by this patch. It may be worth trying to bump the cross-compile to a later Debian release in another PR, as Buster is about to go EOL.

gnu-andrew avatar May 23 '24 00:05 gnu-andrew

I'll remove the verbose build log now, but leave the printing of the spec files as I think it does no harm and may be useful for future debugging.

Actually looks like the main build has had LOG_LEVEL=debug since inception so I'll leave this in for cross-compiles. It makes things easier to debug.

gnu-andrew avatar May 23 '24 00:05 gnu-andrew