Skip to content

8357119: Make Zero the default and only variant of HotSpot for iOS #35

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

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

Conversation

TheShermanTanker
Copy link
Contributor

@TheShermanTanker TheShermanTanker commented May 16, 2025

Currently, the Zero variant of HotSpot must be manually selected for mobile to compile properly for iOS, since iOS does not allow writeable and executable sections. Since Zero is, to my knowledge, the only valid HotSpot variant for iOS, this default should be handled by the build rather than require the developer to have specific knowledge about iOS and the mobile fork. I also took the opportunity to explicitly disallow selecting other JVM variants at all for iOS, this can be rolled back if my assumption turns out to be incorrect. While here, also touch up the build docs a little.


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-8357119: Make Zero the default and only variant of HotSpot for iOS (Enhancement - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 35

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/mobile/pull/35.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 16, 2025

👋 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 May 16, 2025

❗ 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 8357119 8357119: Make Zero the default and only variant of HotSpot for iOS May 16, 2025
@openjdk openjdk bot added the rfr label May 16, 2025
@mlbridge
Copy link

mlbridge bot commented May 16, 2025

Webrevs

@@ -74,6 +78,10 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_VARIANTS],
JVM_VARIANTS=`$ECHO $JVM_VARIANTS_OPT | $SED -e 's/,/ /g' -e 's/minimal1/minimal/'`
AC_MSG_RESULT([$JVM_VARIANTS])

if test "x$OPENJDK_TARGET_OS" = xios; then
VALID_JVM_VARIANTS="zero"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be guarded with a check on Device versus simulator. When running on an iOS simulator, it is technically possible to dynamically generate AND execute code, hence this is not restricted to zero.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I was not aware that one could run server on the iOS simulator. I can remove this part since my assumption seems to be incorrect.

README.md Outdated
@@ -19,8 +19,8 @@ tracking.

### Pre-requisites
Following are the prerequisites to build JDK on Mac targeting iOS:
1. Download and unzip pre-built JDK24 to be used as boot JDK
2. Download the [support zip](https://download2.gluonhq.com/mobile/mobile-support-20250106.zip) which contains an ios build for libffi and cups. Unzip it in the root directory of the project.
1. Download and install JDK24 for macOS. You can use the JDK you just built targeting macOS in the above note instead, but this is not recommended.
Copy link
Collaborator

Choose a reason for hiding this comment

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

out of curiosity, why is that not recommended?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I can't see why that would be a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was conservative and thought we wouldn't want to encourage using a bleeding edge JDK compiled off master as the boot JDK. If this is ok, I can remove that "Not recommended" note.

README.md Outdated
--with-libffi-include=<support-dir-absolute-path>/libffi/include \
--with-libffi-lib=<support-dir-absolute-path>/libffi/libs \
--with-cups-include=<support-dir-absolute-path>/cups-2.3.6
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk \
```

If you need to tell configure the path of the boot JDK, or if configure fails with an error saying
it can't find the boot JDK, for instance if you downloaded a JDK in compressed archive form rather
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: change "the boot JDK" to "a boot JDK"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change this as soon as possible.

@johanvos
Copy link
Collaborator

@TheShermanTanker thank you for the PR. Looks good, some minor comments.
The biggest minor comment is probably about restricting the VM variant to Zero for all iOS builds. I believe there is value in building the server variant for the iOS simulator. While you can't distribute apps with it, it might help developers testing their apps quickly.

README.md Outdated
--disable-warnings-as-errors \
--openjdk-target=aarch64-macos-ios \
--with-boot-jdk=/Users/abhinay/.sdkman/candidates/java/24.ea.29-open \
--with-jvm-variants=zero \
--with-libffi-include=<support-dir-absolute-path>/libffi/include \
--with-libffi-lib=<support-dir-absolute-path>/libffi/libs \
--with-cups-include=<support-dir-absolute-path>/cups-2.3.6
Copy link
Member

Choose a reason for hiding this comment

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

Configure arguments don't have to be absolute paths; configure will rewrite then to absolute path if they are relative.

@magicus
Copy link
Member

magicus commented May 16, 2025

@johanvos How can you test if you are building for the device or an emulator?

If this can/should be supported, then we also need to write something about it in the documents, not only update configure.

And if we can't detect the difference, then maybe most of this PR will need to be scrapped.

@johanvos
Copy link
Collaborator

@johanvos How can you test if you are building for the device or an emulator?

If this can/should be supported, then we also need to write something about it in the documents, not only update configure.

And if we can't detect the difference, then maybe most of this PR will need to be scrapped.

That is defined in the sysroot that is passed with configure. If you provide
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk you are building for the device.

If you provide
--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/
you are building the the simulator.

If the latter SDK is selected, #ifdef TARGET_OS_SIMULATOR will return true when compiling code. (but that won't help for the makefiles to detect if we're building for device or simulator)

@magicus
Copy link
Member

magicus commented May 16, 2025

We can test for ifdefs by test compiling code, but it is not the most efficient way. Checking for if [[ SYSROOT =~ .*Simulator.* ]] seems simpler.

@TheShermanTanker
Copy link
Contributor Author

@johanvos How can you test if you are building for the device or an emulator?

If this can/should be supported, then we also need to write something about it in the documents, not only update configure.

And if we can't detect the difference, then maybe most of this PR will need to be scrapped.

I still think defaulting to Zero for iOS is helpful, but I can remove the restricting of valid iOS JVM variants to only Zero since that is problematic.

@johanvos
Copy link
Collaborator

@johanvos How can you test if you are building for the device or an emulator?
If this can/should be supported, then we also need to write something about it in the documents, not only update configure.
And if we can't detect the difference, then maybe most of this PR will need to be scrapped.

I still think defaulting to Zero for iOS is helpful, but I can remove the restricting of valid iOS JVM variants to only Zero since that is problematic.

Defaulting to Zero for iOS sounds like a good idea indeed.

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

Successfully merging this pull request may close these issues.

3 participants