diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b06351200..13cd50c9f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -135,6 +135,7 @@ jobs: run: | rm -rf /Applications/Xcode.app ln -s /Applications/Xcode_11.7.app /Applications/Xcode.app + ln -s /Applications/Xcode_11.7.app /Applications/Xcode-11.7.app - name: Build macOS run: | diff --git a/build-farm/make-adopt-build-farm.sh b/build-farm/make-adopt-build-farm.sh index 7170eab15..4d8f2e1a4 100755 --- a/build-farm/make-adopt-build-farm.sh +++ b/build-farm/make-adopt-build-farm.sh @@ -32,7 +32,7 @@ if [ -z "$ARCHITECTURE" ]; then if [ "$ARCHITECTURE" = "powerpc" ]; then ARCHITECTURE=ppc64; fi # AIX if [ "$ARCHITECTURE" = "arm" ]; then ARCHITECTURE=aarch64; fi # mac/aarch64 if [ "$ARCHITECTURE" = "armv7l" ]; then ARCHITECTURE=arm; fi # Linux/arm32 - echo ARCHITECTURE not defined - assuming $ARCHITECTURE + echo ARCHITECTURE not defined - assuming "$ARCHITECTURE" export ARCHITECTURE fi @@ -132,6 +132,7 @@ CONFIGURE_ARGS_FOR_ANY_PLATFORM="" CONFIGURE_ARGS=${CONFIGURE_ARGS:-""} BUILD_ARGS=${BUILD_ARGS:-""} VARIANT_ARG="" +MAC_ROSETTA_PREFIX="" if [ -z "${JDK_BOOT_VERSION}" ] then @@ -238,11 +239,11 @@ if [ "${JAVA_FEATURE_VERSION}" -lt 16 ]; then export BUILD_ARGS="${BUILD_ARGS} --create-jre-image" fi -echo "$PLATFORM_SCRIPT_DIR/../makejdk-any-platform.sh --clean-git-repo --jdk-boot-dir ${JDK_BOOT_DIR} --configure-args ${CONFIGURE_ARGS_FOR_ANY_PLATFORM} --target-file-name ${FILENAME} ${TAG_OPTION} ${OPTIONS} ${BUILD_ARGS} ${VARIANT_ARG} ${JAVA_TO_BUILD}" +echo "$MAC_ROSETTA_PREFIX $PLATFORM_SCRIPT_DIR/../makejdk-any-platform.sh --clean-git-repo --jdk-boot-dir ${JDK_BOOT_DIR} --configure-args ${CONFIGURE_ARGS_FOR_ANY_PLATFORM} --target-file-name ${FILENAME} ${TAG_OPTION} ${OPTIONS} ${BUILD_ARGS} ${VARIANT_ARG} ${JAVA_TO_BUILD}" # Convert all speech marks in config args to make them safe to pass in. # These will be converted back into speech marks shortly before we use them, in build.sh. CONFIGURE_ARGS_FOR_ANY_PLATFORM="${CONFIGURE_ARGS_FOR_ANY_PLATFORM//\"/temporary_speech_mark_placeholder}" # shellcheck disable=SC2086 -bash -c "$PLATFORM_SCRIPT_DIR/../makejdk-any-platform.sh --clean-git-repo --jdk-boot-dir ${JDK_BOOT_DIR} --configure-args \"${CONFIGURE_ARGS_FOR_ANY_PLATFORM}\" --target-file-name ${FILENAME} ${TAG_OPTION} ${OPTIONS} ${BUILD_ARGS} ${VARIANT_ARG} ${JAVA_TO_BUILD}" +bash -c "$MAC_ROSETTA_PREFIX $PLATFORM_SCRIPT_DIR/../makejdk-any-platform.sh --clean-git-repo --jdk-boot-dir ${JDK_BOOT_DIR} --configure-args \"${CONFIGURE_ARGS_FOR_ANY_PLATFORM}\" --target-file-name ${FILENAME} ${TAG_OPTION} ${OPTIONS} ${BUILD_ARGS} ${VARIANT_ARG} ${JAVA_TO_BUILD}" \ No newline at end of file diff --git a/build-farm/platform-specific-configurations/mac.sh b/build-farm/platform-specific-configurations/mac.sh index 94a7bab40..c519f8a5f 100755 --- a/build-farm/platform-specific-configurations/mac.sh +++ b/build-farm/platform-specific-configurations/mac.sh @@ -22,10 +22,19 @@ source "$SCRIPT_DIR/../../sbin/common/constants.sh" export MACOSX_DEPLOYMENT_TARGET=10.9 export BUILD_ARGS="${BUILD_ARGS}" +## JDK8 only: If, at this point in the build, the architecure of the machine is arm64 while the ARCHITECTURE variable +## is x64 then we need to add the cross compilation option --openjdk-target=x86_64-apple-darwin +MACHINEARCHITECTURE=$(uname -m) + if [ "${JAVA_TO_BUILD}" == "${JDK8_VERSION}" ] then - XCODE_SWITCH_PATH="/Applications/Xcode.app" + XCODE_SWITCH_PATH="/Applications/Xcode-11.7.app" export CONFIGURE_ARGS_FOR_ANY_PLATFORM="${CONFIGURE_ARGS_FOR_ANY_PLATFORM} --with-toolchain-type=clang" + if [[ "${MACHINEARCHITECTURE}" == "arm64" ]] && [[ "${ARCHITECTURE}" == "x64" ]]; then + export CONFIGURE_ARGS_FOR_ANY_PLATFORM="${CONFIGURE_ARGS_FOR_ANY_PLATFORM} --openjdk-target=x86_64-apple-darwin" + export MAC_ROSETTA_PREFIX="arch -x86_64" + export PATH=/opt/homebrew/bin:/usr/local/bin:$PATH + fi if [ "${VARIANT}" == "${BUILD_VARIANT_OPENJ9}" ]; then export CONFIGURE_ARGS_FOR_ANY_PLATFORM="${CONFIGURE_ARGS_FOR_ANY_PLATFORM} --with-openssl=fetched --enable-openssl-bundling" export BUILD_ARGS="${BUILD_ARGS} --skip-freetype"