Skip to content

Commit

Permalink
Add code to cross compile x64 jdk8 on arm64 mac (#3492)
Browse files Browse the repository at this point in the history
* Add cross compile steps for x64 jdk8 on m1 macs

* syntax error

* syntax error

* resolve linter error

* add export

* make link to xcode11.7 using - instead of _

* Update build-farm/platform-specific-configurations/mac.sh

Co-authored-by: Stewart X Addison <[email protected]>

* Update build-farm/platform-specific-configurations/mac.sh

Co-authored-by: Stewart X Addison <[email protected]>

* debug

* wrong uname flag

* add MAC_ROSETTA_PREFIX to the echo command

* temp fix for xcode switch so I can run the tests with the build

* add /opt/homebrew/bin to beginning of PATH jdk8 mac build

* add /opt/homebrew/bin to beginning of PATH jdk8 mac build on arm machines

* remove debug

---------

Co-authored-by: Stewart X Addison <[email protected]>
  • Loading branch information
Haroon-Khel and sxa authored Oct 10, 2023
1 parent c5a4237 commit 40b4b12
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

This comment has been minimized.

Copy link
@netomi

netomi Oct 10, 2023

Contributor

this change looks very spurious

- name: Build macOS
run: |
Expand Down
7 changes: 4 additions & 3 deletions build-farm/make-adopt-build-farm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}"
11 changes: 10 additions & 1 deletion build-farm/platform-specific-configurations/mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 40b4b12

Please sign in to comment.