jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8314488: Compiling the JDK with C++17

Open kimbarrett opened this issue 4 months ago • 10 comments
trafficstars

I'm hijacking the PR mechanism as a way to discuss new C++17 features that can be more easily structured and captured than bare email. Once discussion settles down I'll turn the results into HotSpot Style Guide changes. I don't intend to integrate any version of this document to the OpenJDK repository.


Progress

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

Issue

  • JDK-8314488: Compiling the JDK with C++17 (Enhancement - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25992

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

Using diff file

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

Using Webrev

Link to Webrev Comment

kimbarrett avatar Jun 26 '25 02:06 kimbarrett

:wave: Welcome back kbarrett! 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 Jun 26 '25 02:06 bridgekeeper[bot]

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

openjdk[bot] avatar Jun 26 '25 02:06 openjdk[bot]

@kimbarrett 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[bot] avatar Jun 26 '25 02:06 openjdk[bot]

/label remove build /label add hotspot

kimbarrett avatar Jun 26 '25 02:06 kimbarrett

@kimbarrett The build label was successfully removed.

openjdk[bot] avatar Jun 26 '25 02:06 openjdk[bot]

@kimbarrett The hotspot label was successfully added.

openjdk[bot] avatar Jun 26 '25 02:06 openjdk[bot]

@kimbarrett 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 Jun 26 '25 02:06 openjdk[bot]

Webrevs

mlbridge[bot] avatar Jun 26 '25 02:06 mlbridge[bot]

Are we supposed to put our comments in this PR :-)?

constexpr if statements would be nice to have. Seldom used, but the alternative is even more 'magical looking'.

jdksjolen avatar Jun 27 '25 09:06 jdksjolen

From Julian's linked PR, apparently AIX's C++ compiler is capable of compiling C++17. Do we have any other "obscure" platform which the community is interested in supporting?

jdksjolen avatar Jun 27 '25 09:06 jdksjolen

Are we supposed to put our comments in this PR :-)?

Yes. That's kind of the point of using a PR.

constexpr if statements would be nice to have. Seldom used, but the alternative is even more 'magical looking'.

See item 10. Compile-time If, which is currently in the permitted block.

kimbarrett avatar Jun 27 '25 14:06 kimbarrett

From Julian's linked PR, apparently AIX's C++ compiler is capable of compiling C++17. Do we have any other "obscure" platform which the community is interested in supporting?

None that I know about. That's part of the point of asking the question about whether we should throw the switch at all and start building with and using C++17.

kimbarrett avatar Jun 27 '25 14:06 kimbarrett

Any comments? I know a lot of Oracle folks are on vacation, but I got comments from many of them before making this public.

If I don't hear anything soon-ish I'm going to proceed as if everyone likes this.

kimbarrett avatar Jul 15 '25 16:07 kimbarrett

@kimbarrett 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 issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Aug 12 '25 19:08 bridgekeeper[bot]

I think it is time to proceed with this change.

stefank avatar Aug 15 '25 11:08 stefank

I think it is time to proceed with this change.

Agreed. I've been working on the associated style guide updates. I'm going to leave this open for now in case anyone wants to make any late comments here, and will withdraw this PR and replace with the real change soonish, I hope.

kimbarrett avatar Aug 15 '25 11:08 kimbarrett

Would this give us size_t literal suffixes? Something like "0uz"?

tstuefe avatar Aug 15 '25 12:08 tstuefe

Would this give us size_t literal suffixes? Something like "0uz"?

That's C++23.

kimbarrett avatar Aug 15 '25 13:08 kimbarrett

Would this give us size_t literal suffixes? Something like "0uz"?

That's C++23.

On the other hand, I don't know of anything that prevents us from defining "_zu" as user-defined literal syntax while we wait for C++23. (Dropping the underscore puts us in reserved syntax land, and likely requires suppressing warnings at least.)

And I'm certainly tired of casting literals to size_t.

The style guide currently says "User-defined literals should not be added casually, but only through a proposal to add a specific UDL." So propose that syntax, implemented by adding something like the following in globalDefinitions.hpp:

constexpr operator ""_zu(unsigned long long int x) {
  // Probably only relevant for 32bit platforms.
  assert(x <= std::numeric_limits<size_t>::max(), "invalid size_t literal");
  return static_cast<size_t>(x);
}

The C++23 literal syntax supports different cases and different orders for "u" and "z". Probably don't bother with that for ours.

We should be able to provide a "_z" suffix to support ssize_t literals, but I'm failing to figure out the details of that today. (It' pretty late in my day, so I'm assuming it's possible and I'm just too sleepy to figure it out.) It's less important anyway.

kimbarrett avatar Aug 16 '25 23:08 kimbarrett

Withdrawing this discussion PR, in preparation for the real PR to use C++17 for building, with an update to the HotSpot Style Guide for C++17 feature usage.

kimbarrett avatar Aug 21 '25 14:08 kimbarrett