From 76bbe9216b47048fb6b44ffc20fa6d4f041bdc9a Mon Sep 17 00:00:00 2001 From: Johan Vos Date: Wed, 14 Feb 2024 21:52:12 +0100 Subject: [PATCH] Add required ios changes for building static libs. Add sample configure script for ios --- configure-ios.sh | 10 ++++++++++ make/Main.gmk | 4 ++-- make/common/NativeCompilation.gmk | 2 +- make/common/modules/LauncherCommon.gmk | 2 +- make/modules/java.desktop/Gensrc.gmk | 2 +- make/modules/java.desktop/Java.gmk | 2 +- make/modules/java.desktop/Lib.gmk | 4 ++-- make/modules/java.instrument/Lib.gmk | 2 +- make/modules/jdk.hotspot.agent/Lib.gmk | 2 +- make/modules/jdk.jdwp.agent/Lib.gmk | 2 +- make/modules/jdk.sctp/Lib.gmk | 2 +- .../macosx/native/libnio/fs/UTIFileTypeDetector.c | 2 ++ .../native/libmanagement_ext/OperatingSystemImpl.c | 6 ++++++ 13 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 configure-ios.sh diff --git a/configure-ios.sh b/configure-ios.sh new file mode 100644 index 00000000000..8d9d13086e0 --- /dev/null +++ b/configure-ios.sh @@ -0,0 +1,10 @@ +# sample configure command for ios + +bash configure \ +--enable-headless-only \ +--with-boot-jdk=/opt/jdk-22.jdk/Contents/Home \ +--with-build-jdk=/opt/jdk-23.jdk/Contents/Home \ +--openjdk-target=aarch64-macos-ios \ +--with-cups-include=../support/cups-2.3.6 \ +--with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk + diff --git a/make/Main.gmk b/make/Main.gmk index a91bbcd6aa3..2eb6a06612a 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -242,7 +242,7 @@ define DeclareHotspotGensrcRecipe JVM_VARIANT=$1) endef -ifeq ($(call isTargetOs, android), false) +ifeq ($(call isTargetOs, android ios), false) $(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotGensrcRecipe,$v))) endif @@ -260,7 +260,7 @@ define DeclareHotspotStaticLibsRecipe JVM_VARIANT=$1 STATIC_LIBS=true) endef -ifeq ($(call isTargetOs, android), false) +ifeq ($(call isTargetOs, android ios), false) $(foreach v, $(JVM_VARIANTS), $(eval $(call DeclareHotspotStaticLibsRecipe,$v))) endif diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index 68d1dba27ff..1a163a1894b 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -1171,7 +1171,7 @@ define SetupNativeCompilationBody # If we are building static library, 'AR' on macosx/aix may not support @-file. ifeq ($$($1_TYPE), STATIC_LIBRARY) - ifeq ($(call isTargetOs, macosx aix), true) + ifeq ($(call isTargetOs, macosx aix ios), true) $1_LD_OBJ_ARG := `cat $$($1_OBJ_FILE_LIST)` endif endif diff --git a/make/common/modules/LauncherCommon.gmk b/make/common/modules/LauncherCommon.gmk index be99773ea04..aeefeba5872 100644 --- a/make/common/modules/LauncherCommon.gmk +++ b/make/common/modules/LauncherCommon.gmk @@ -52,7 +52,7 @@ LAUNCHER_CFLAGS += -I$(TOPDIR)/src/java.base/share/native/launcher \ ifeq ($(call isTargetOs, ios), true) LAUNCHER_CFLAGS += -I$(TOPDIR)/src/java.base/macosx/native/libjli -fi +endif MACOSX_PLIST_DIR := $(TOPDIR)/src/java.base/macosx/native/launcher JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest diff --git a/make/modules/java.desktop/Gensrc.gmk b/make/modules/java.desktop/Gensrc.gmk index d2be340f7d8..4d432476c50 100644 --- a/make/modules/java.desktop/Gensrc.gmk +++ b/make/modules/java.desktop/Gensrc.gmk @@ -32,7 +32,7 @@ ifeq ($(call isTargetOs, windows), false) include gensrc/GensrcIcons.gmk endif -ifeq ($(call isTargetOs, linux aix android), true) +ifeq ($(call isTargetOs, linux aix android ios), true) include gensrc/GensrcX11Wrappers.gmk endif diff --git a/make/modules/java.desktop/Java.gmk b/make/modules/java.desktop/Java.gmk index 0b076398441..37899ae3bf9 100644 --- a/make/modules/java.desktop/Java.gmk +++ b/make/modules/java.desktop/Java.gmk @@ -65,7 +65,7 @@ EXCLUDE_FILES += \ .template \ # -ifeq ($(call isTargetOs, macosx android), true) +ifeq ($(call isTargetOs, macosx android ios), true) # exclude all X11 on Mac. EXCLUDES += \ sun/awt/screencast \ diff --git a/make/modules/java.desktop/Lib.gmk b/make/modules/java.desktop/Lib.gmk index ccb1844b156..6cb50bc28b0 100644 --- a/make/modules/java.desktop/Lib.gmk +++ b/make/modules/java.desktop/Lib.gmk @@ -35,14 +35,14 @@ $(call FillFindCache, $(wildcard $(TOPDIR)/src/java.desktop/*/native)) ################################################################################ # Create the AWT/2D libraries -ifeq ($(call isTargetOs, android), false) +ifeq ($(call isTargetOs, android ios), false) include lib/Awt2dLibraries.gmk endif ################################################################################ # Create the libjsound library -ifeq ($(call isTargetOs, aix android), false) +ifeq ($(call isTargetOs, aix android ios), false) LIBJSOUND_CFLAGS := \ $(ALSA_CFLAGS) \ diff --git a/make/modules/java.instrument/Lib.gmk b/make/modules/java.instrument/Lib.gmk index bf5c51540a8..0acdce5c2f6 100644 --- a/make/modules/java.instrument/Lib.gmk +++ b/make/modules/java.instrument/Lib.gmk @@ -63,7 +63,7 @@ else endif $(BUILD_LIBINSTRUMENT): $(call FindLib, java.base, java) -ifeq ($(call isTargetOs, android), false) +ifeq ($(call isTargetOs, android ios), false) TARGETS += $(BUILD_LIBINSTRUMENT) endif diff --git a/make/modules/jdk.hotspot.agent/Lib.gmk b/make/modules/jdk.hotspot.agent/Lib.gmk index e05390a3aae..b568543ed63 100644 --- a/make/modules/jdk.hotspot.agent/Lib.gmk +++ b/make/modules/jdk.hotspot.agent/Lib.gmk @@ -74,7 +74,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBSA, \ LIBS_windows := dbgeng.lib $(WIN_JAVA_LIB), \ )) -ifeq ($(call isTargetOs, android), false) +ifeq ($(call isTargetOs, android ios), false) TARGETS += $(BUILD_LIBSA) endif diff --git a/make/modules/jdk.jdwp.agent/Lib.gmk b/make/modules/jdk.jdwp.agent/Lib.gmk index cd1972129b6..e774132c57f 100644 --- a/make/modules/jdk.jdwp.agent/Lib.gmk +++ b/make/modules/jdk.jdwp.agent/Lib.gmk @@ -71,7 +71,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJDWP, \ $(BUILD_LIBJDWP): $(call FindLib, java.base, java) -ifeq ($(call isTargetOs, android), false) +ifeq ($(call isTargetOs, android ios), false) TARGETS += $(BUILD_LIBJDWP) endif diff --git a/make/modules/jdk.sctp/Lib.gmk b/make/modules/jdk.sctp/Lib.gmk index afce891eedf..618d7189d53 100644 --- a/make/modules/jdk.sctp/Lib.gmk +++ b/make/modules/jdk.sctp/Lib.gmk @@ -29,7 +29,7 @@ include LibCommon.gmk ifeq ($(call isTargetOsType, unix), true) - ifeq ($(call isTargetOs, macosx aix), false) + ifeq ($(call isTargetOs, macosx ios aix), false) $(eval $(call SetupJdkLibrary, BUILD_LIBSCTP, \ NAME := sctp, \ OPTIMIZATION := LOW, \ diff --git a/src/java.base/macosx/native/libnio/fs/UTIFileTypeDetector.c b/src/java.base/macosx/native/libnio/fs/UTIFileTypeDetector.c index 5e9451e850c..3b2f987738c 100644 --- a/src/java.base/macosx/native/libnio/fs/UTIFileTypeDetector.c +++ b/src/java.base/macosx/native/libnio/fs/UTIFileTypeDetector.c @@ -106,6 +106,7 @@ Java_sun_nio_fs_UTIFileTypeDetector_probe0(JNIEnv* env, jobject ftd, CFStringRef extension = toCFString(env, ext); if (extension != NULL) { +#ifndef TARGET_IOS // deprecated on ios CFStringRef uti = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, extension, NULL); @@ -121,6 +122,7 @@ Java_sun_nio_fs_UTIFileTypeDetector_probe0(JNIEnv* env, jobject ftd, CFRelease(mimeType); } } +#endif } return result; diff --git a/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c b/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c index 81a972999ed..0b734696b6c 100644 --- a/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c +++ b/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c @@ -38,9 +38,11 @@ #include #include #include +#ifndef TARGET_IOS #include #include #endif +#endif #elif !defined(_AIX) #include #endif @@ -271,6 +273,7 @@ Java_com_sun_management_internal_OperatingSystemImpl_getOpenFileDescriptorCount0 (JNIEnv *env, jobject mbean) { #ifdef __APPLE__ +#ifndef TARGET_IOS // This code is influenced by the darwin lsof source pid_t my_pid; struct proc_bsdinfo bsdinfo; @@ -314,6 +317,9 @@ Java_com_sun_management_internal_OperatingSystemImpl_getOpenFileDescriptorCount0 free(fds); return nfiles; +#else + return (100); +#endif #elif defined(_ALLBSD_SOURCE) /* * XXXBSD: there's no way available to do it in FreeBSD, AFAIK.