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

8344458: [11u] Add initial support for building with XCode 14 #2966

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vieiro
Copy link
Contributor

@vieiro vieiro commented Nov 18, 2024

An implementation of JDK-8344458 that adds conditional support for building on macos with XCode 14 while keeping compatibility with previous XCode versions.

The PR is separated in three commits for easier review:

  • First commit adds a new --enable-xcode14 configuration flag (which is currently disabled in GHA) and two additional variables:
    • CFLAGS_XCODE14_DEPR_DECLARATIONS (empty on current XCode versions, set to and -Wno-deprecated-declarations when --enable-xcode14is used)
    • And CFLAGS_XCODE14_DEPR_NON_PROTOTYPE (empty on current XCode versions, set to -Wno-deprecated-non-prototype when --enable-xcode14 is used).
  • The second commit applies CFLAGS_XCODE14_DEPR_DECLARATIONS to those parts of the codebase that use the deprecated sprintf function (i.e., avoiding sprintf usage errors in XCode 14).
  • The third commit applies CFLAGS_XCODE14_DEPR_NON_PROTOTYPE to those parts of AWT lib that generate a compilation error (i.e., avoiding the passing arguments to a function without prototype).

Since the new flag --enable-xcode14 is not set the build should run exactly the same on the current XCode versions and, consequently, the GitHub checks should pass on all platforms, including the current macos-12 & XCode 13.4.1.


Progress

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

Issue

  • JDK-8344458: [11u] Add initial support for building with XCode 14 (Enhancement - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2966

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 18, 2024

👋 Welcome back vieiro! 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 18, 2024

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

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 18, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 18, 2024

Webrevs

@vieiro
Copy link
Contributor Author

vieiro commented Nov 18, 2024

NOTE: The GHA macos-12 runners have been shut-down between November 18, 14:00 UTC and November 19, 00:00 UTC and are currently unavailable. The tests will be re-run when again available.

@openjdk
Copy link

openjdk bot commented Nov 19, 2024

@vieiro 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
Copy link

openjdk bot commented Nov 19, 2024

@vieiro 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.

Copy link
Contributor

@jerboaa jerboaa left a comment

Choose a reason for hiding this comment

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

Seems OK to me. I'm not sure we need the doc fixes.

@@ -314,6 +314,7 @@ <h3 id="apple-xcode">Apple Xcode</h3>
<li>Use configure option <code>--with-xcode-path</code>, e.g. <code>configure --with-xcode-path=/Applications/Xcode13.1.app</code> This allows using a specific Xcode version for an OpenJDK build, independently of the active Xcode version by <code>xcode-select</code>.</li>
</ul>
<p>If you have recently (inadvertently) updated your OS and/or Xcode version, and the JDK can no longer be built, please see the section on <a href="#problems-with-the-build-environment">Problems with the Build Environment</a>, and <a href="#getting-help">Getting Help</a> to find out if there are any recent, non-merged patches available for this update.</p>
<p>Experimental support for XCode 14 can be enabled using the <code>--enable-xcode14</code> configuration flag.</p>
Copy link
Contributor

@jerboaa jerboaa Nov 19, 2024

Choose a reason for hiding this comment

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

Please remove this. We don't usually update doc/building.html for every build change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in last commit

doc/building.md Outdated
Comment on lines 358 to 359
Experimental support for XCode 14 can be enabled using the `--enable-xcode14` configuration flag.

Copy link
Contributor

@jerboaa jerboaa Nov 19, 2024

Choose a reason for hiding this comment

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

Same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed in last commit.

Copy link
Member

@gnu-andrew gnu-andrew 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 think this is the right approach. This new flag is called --enable-xcode14, but its implementation has nothing to do with the compiler version or enabling XCode 14. It simply adds additional compiler flags to disable the warnings. Someone can add --enable-xcode14 with 13 installed and these flags will be added (and presumably the build will fail, as you said these flags are not supported there). Alternatively, someone could have XCode 14 and not know about this flag, and it still fail to build. Also, I fail to see the point of the macosx check, because presumably this is due to a new version of clang that is part of XCode 14, and so the build would fail if someone uses that version of clang on Linux.

If these flags are needed for builds with XCode 14, we should detect that this newer compiler is being used and add them automatically. In fact, ideally, you should not depend on the version at all but test the compiler with the flag and add it if it works. Take a look at FLAGS_SETUP_GCC6_COMPILER_FLAGS also in flags-cflags.m4

You also don't need to define your own variables and pepper them all over every Makefile. This should be something handled in FLAGS_SETUP_CFLAGS_HELPER. Look at the area around line 587 where warnings are added to gcc and clang. They are already different there for Linux and MacOS for the JDK. Detecting whether these new flags work and then adding them to WARNING_CFLAGS_JVM and WARNING_CFLAGS_JDK looks the right way to go.

@gnu-andrew
Copy link
Member

I tried with clang 15, 16, 17 & 18 on Linux and did not see similar errors with -Wdeprecated-declarations and -Wdeprecated-non-prototype. With --disable-warnings-as-errors on, it gets as far as running the built JDK, which then segfaults. I think this may be due to undefined behaviour issues mentioned in JDK-8229258 and JDK-8276453

With warnings as errors on (the default), it fails with:

+ /usr/bin/head -n 15
/localhome/andrew/projects/openjdk/upstream/jdk11u-dev/src/hotspot/share/compiler/compilerDefinitions.cpp:85:13: error: implicit conversion from 'const intx' (aka 'const long') to 'double' changes value from 9223372036854775807 to 9223372036854775808 [-Werror,-Wimplicit-const-int-float-conversion]
    if (v > max_intx) {
          ~ ^~~~~~~~
1 error generated.

which I believe is JDK-8287052

Is --disable-warnings-as-errors not sufficient to make the GHA build work on MacOS 13? It's not an ideal solution but it's a less disruptive way to keep a working MacOS build in the short term.

@vieiro
Copy link
Contributor Author

vieiro commented Nov 21, 2024

[...]
If these flags are needed for builds with XCode 14, we should detect that this newer compiler is being used and add them automatically. In fact, ideally, you should not depend on the version at all but test the compiler with the flag and add it if it works. Take a look at FLAGS_SETUP_GCC6_COMPILER_FLAGS also in flags-cflags.m4
[...]

Yep, I came to the same conclusion in the updates_dev mailing list after pushing. The flag was useful to try to compile on XCode 13 and XCode 14 during experiments, but detecting the compiler is probably the way to go.

@vieiro
Copy link
Contributor Author

vieiro commented Nov 21, 2024

[...]
Is --disable-warnings-as-errors not sufficient to make the GHA build work on MacOS 13? It's not an ideal solution but it's a less disruptive way to keep a working MacOS build in the short term.

I'll give it a try. Yep, it's not ideal (we may not be able to run the tests as in #2967) but it's indeed less disruptive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants