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

Add support for building on AArch64 #231

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -80,8 +80,8 @@ images {
options = ["--module-path", "plugins"]
bundles = ['zip', 'tar.gz']
jdk {
url = 'https://download.java.net/java/GA/jdk12/GPL/openjdk-12_linux-x64_bin.tar.gz'
sha256 = 'b43bc15f4934f6d321170419f2c24451486bc848a2179af5e49d10721438dd56'
url = project.jdkUrl
sha256 = project.jdkSha256
}
}
}
@@ -21,6 +21,59 @@
* questions.
*/

buildscript {
def deps = [:]
file('deps.env').readLines().each() {
def (key, value) = it.tokenize('=')
if (key != null && value != null) {
deps[key] = value.replaceAll(/^\"|\"$/, '')
}
}

ext {
def os = System.getProperty('os.name').toLowerCase()
osName = os.startsWith('win') ? 'Windows' :
os.startsWith('mac') ? 'Macos' : 'Linux'

def jdks = [
'Windows': [
'amd64': [
url: deps['JDK_WINDOWS_URL'],
sha256: deps['JDK_WINDOWS_SHA256']
],
],
'Linux': [
'amd64': [
url: deps['JDK_LINUX_X86_64_URL'],
sha256: deps['JDK_LINUX_X86_64_SHA256']
],
'aarch64': [
url: deps['JDK_LINUX_AARCH64_URL'],
sha256: deps['JDK_LINUX_AARCH64_SHA256']
],
],
'Macos': [
'x86_64': [
url: deps['JDK_MACOS_URL'],
sha256: deps['JDK_MACOS_SHA256']
],
],
]

if (osName in jdks) {
def arch = System.getProperty('os.arch')
if (arch in jdks[osName]) {
jdkUrl = jdks[osName][arch].url
jdkSha256 = jdks[osName][arch].sha256
} else {
throw new GradleException("Unsupported architecture: ${arch}")
}
} else {
throw new GradleException("Unsupported OS: ${os}")
}
}
}

plugins {
id 'org.openjdk.skara.gradle.proxy'
id 'org.openjdk.skara.gradle.version'
@@ -108,11 +161,8 @@ task local(type: Copy) {
doFirst {
delete project.buildDir
}
def os = System.getProperty('os.name').toLowerCase()
def osName = os.startsWith('win') ? 'Windows' :
os.startsWith('mac') ? 'Macos' : 'Linux'

dependsOn ':cli:image' + osName
dependsOn ':cli:image' + project.osName
from zipTree(file(project.rootDir.toString() +
'/cli/build/distributions/cli' +
'-' + project.version + '-' +
@@ -76,8 +76,8 @@ images {
launchers = ext.launchers
bundles = ['zip', 'tar.gz']
jdk {
url = 'https://download.java.net/java/GA/jdk12/GPL/openjdk-12_windows-x64_bin.zip'
sha256 = '35a8d018f420fb05fe7c2aa9933122896ca50bd23dbd373e90d8e2f3897c4e92'
url = project.jdkUrl
sha256 = project.jdkSha256
}
}

@@ -87,8 +87,8 @@ images {
man = 'cli/resources/man'
bundles = ['zip', 'tar.gz']
jdk {
url = 'https://download.java.net/java/GA/jdk12/GPL/openjdk-12_linux-x64_bin.tar.gz'
sha256 = 'b43bc15f4934f6d321170419f2c24451486bc848a2179af5e49d10721438dd56'
url = project.jdkUrl
sha256 = project.jdkSha256
}
}

@@ -98,8 +98,8 @@ images {
man = 'cli/resources/man'
bundles = ['zip', 'tar.gz']
jdk {
url = 'https://download.java.net/java/GA/jdk12/GPL/openjdk-12_osx-x64_bin.tar.gz'
sha256 = '52164a04db4d3fdfe128cfc7b868bc4dae52d969f03d53ae9d4239fe783e1a3a'
url = project.jdkUrl
sha256 = project.jdkSha256
Copy link
Member

@edvbld edvbld Nov 4, 2019

Choose a reason for hiding this comment

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

This is unfortunately not how the jdk property of the images target is meant to be used.

The JDK fully supports cross-platform linking, something we make use of in Skara. This means if you build the :cli:images target on a Linux x64 machine then you will actually get fully working Skara distributions for Windows, macOS and Linux (all x64), since we are downloading the JDKs for macOS, Windows and Linux. With this patch we only get Linux x64 distributions.

Fortunately the JDK not only supports cross-jlink across operating system, it also supports cross-linking across CPU architectures. So I would prefer to be able to write:

linux_x64 {
    modules = ext.modules
    launchers = ext.launchers
    man = 'cli/resources/man'
    bundles = ['zip', 'tar.gz']
    jdk {
        url = 'https://download.java.net/java/GA/jdk12/GPL/openjdk-12_linux-x64_bin.tar.gz'
        sha256 = 'b43bc15f4934f6d321170419f2c24451486bc848a2179af5e49d10721438dd56'
    }
}

linux_aarch64 {
    modules = ext.modules
    launchers = ext.launchers
    man = 'cli/resources/man'
    bundles = ['zip', 'tar.gz']
    jdk {
        url = 'https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_aarch64_linux_hotspot_12.0.2_10.tar.gz'
        sha256 = ''855f046afc5a5230ad6da45a5c811194267acd1748f16b648bfe5710703fe8c'
    }
}

This way we will always produce Linux AArch64 images on Linux x64 hosts. To get this to work you need to do some minor changes to ImagesPlugin.java (and you might have to do some adjustments to LinkTask.java). Do you want to take a stab at that? Or do you want me to try and hack something together?

Copy link
Member Author

@nick-arm nick-arm Nov 4, 2019

Choose a reason for hiding this comment

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

Ah ok, I see that now. I'm happy to have a go at redoing it.

}
}
}
@@ -1,5 +1,8 @@
JDK_LINUX_URL="https://download.java.net/java/GA/jdk12/GPL/openjdk-12_linux-x64_bin.tar.gz"
JDK_LINUX_SHA256="b43bc15f4934f6d321170419f2c24451486bc848a2179af5e49d10721438dd56"
JDK_LINUX_X86_64_URL="https://download.java.net/java/GA/jdk12/GPL/openjdk-12_linux-x64_bin.tar.gz"
JDK_LINUX_X86_64_SHA256="b43bc15f4934f6d321170419f2c24451486bc848a2179af5e49d10721438dd56"

JDK_LINUX_AARCH64_URL="https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12.0.2%2B10/OpenJDK12U-jdk_aarch64_linux_hotspot_12.0.2_10.tar.gz"
JDK_LINUX_AARCH64_SHA256="855f046afc5a5230ad6da45a5c811194267acd1748f16b648bfe5710703fe8c6"

JDK_MACOS_URL="https://download.java.net/java/GA/jdk12/GPL/openjdk-12_osx-x64_bin.tar.gz"
JDK_MACOS_SHA256="52164a04db4d3fdfe128cfc7b868bc4dae52d969f03d53ae9d4239fe783e1a3a"
17 gradlew
@@ -82,12 +82,25 @@ extract_zip() {

DIR=$(dirname $0)
OS=$(uname)
ARCH=$(uname -m)

. $(dirname "${0}")/deps.env
case "${OS}" in
Linux )
JDK_URL="${JDK_LINUX_URL}"
JDK_SHA256="${JDK_LINUX_SHA256}"
case "${ARCH}" in
x86_64 )
JDK_URL="${JDK_LINUX_X86_64_URL}"
JDK_SHA256="${JDK_LINUX_X86_64_SHA256}"
;;
aarch64 )
JDK_URL="${JDK_LINUX_AARCH64_URL}"
JDK_SHA256="${JDK_LINUX_AARCH64_SHA256}"
;;
*)
echo "error: unsupported Linux architecture ${ARCH}"
exit 1
;;
esac
Copy link
Member

@edvbld edvbld Nov 4, 2019

Choose a reason for hiding this comment

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

This part looks good 👍

;;
Darwin )
JDK_URL="${JDK_MACOS_URL}"