Skip to content

Commit df3a3f2

Browse files
authored
Build native launcher for linux aarch64 (#1703)
1 parent 5639c4b commit df3a3f2

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

.github/workflows/ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,59 @@ jobs:
187187
SCALA_CLI_IT_GROUP: 3
188188
SCALA_CLI_SODIUM_JNI_ALLOW: false
189189

190+
# Copied from https://github.com/coursier/coursier/blob/44e1a024897fb1046303f705e0e4143d808e1adc/.github/workflows/ci.yml#L263-L326
191+
generate-linux-arm64-native-launcher:
192+
runs-on: "ubuntu-20.04"
193+
steps:
194+
- uses: actions/checkout@v3
195+
with:
196+
fetch-depth: 0
197+
submodules: true
198+
- uses: VirtusLab/scala-cli-setup@2d4aee229d96837c8da9e6068322de977e2f781a
199+
with:
200+
jvm: "temurin:17"
201+
- uses: uraimo/[email protected]
202+
with:
203+
arch: aarch64
204+
distro: ubuntu20.04
205+
206+
# Speeds up builds per the run-on-arch-action README
207+
githubToken: ${{ github.token }}
208+
209+
setup: |
210+
mkdir -p artifacts
211+
mkdir -p utils
212+
cp "$(cs get https://github.com/coursier/coursier/releases/download/v2.0.16/cs-aarch64-pc-linux)" utils/cs
213+
chmod +x utils/cs
214+
dockerRunArgs: |
215+
--volume "${PWD}/artifacts:/artifacts"
216+
--volume "${PWD}/utils:/utils"
217+
env: |
218+
JAVA_HOME: /jvm
219+
JAVA_OPTS: "-Djdk.lang.Process.launchMechanism=vfork"
220+
221+
# The shell to run commands with in the container
222+
shell: /bin/bash
223+
224+
# build-essential and libz-dev are required to build native images.
225+
# git is required by some of the launcher.sc logic.
226+
# python3-pip is required for some CLI tests.
227+
# gnupg2 is for signing the resulting binary.
228+
install: |
229+
apt-get update -q -y
230+
apt-get install -q -y build-essential libz-dev git python3-pip gnupg2 curl
231+
run: |
232+
set -e
233+
export PATH="/utils:$PATH"
234+
git config --global --add safe.directory "$(pwd)"
235+
./mill -i copyDefaultLauncher artifacts/
236+
- uses: actions/upload-artifact@v3
237+
with:
238+
name: linux-aarch64-launchers
239+
path: artifacts/
240+
if-no-files-found: error
241+
retention-days: 2
242+
190243
generate-macos-launcher:
191244
timeout-minutes: 120
192245
runs-on: "macos-latest"
@@ -869,6 +922,7 @@ jobs:
869922
- format
870923
- checks
871924
- reference-doc
925+
- generate-linux-arm64-native-launcher
872926
if: github.event_name == 'push'
873927
runs-on: ubuntu-20.04
874928
steps:
@@ -885,6 +939,11 @@ jobs:
885939
with:
886940
name: linux-launchers
887941
path: artifacts/
942+
- uses: actions/download-artifact@v3
943+
if: env.SHOULD_PUBLISH == 'true'
944+
with:
945+
name: linux-aarch64-launchers
946+
path: artifacts/
888947
- uses: actions/download-artifact@v3
889948
if: env.SHOULD_PUBLISH == 'true'
890949
with:

project/settings.sc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ trait CliLaunchers extends SbtModule { self =>
167167
s"-H:IncludeResources=$defaultFilesResourcePath/.*",
168168
"-H:-ParseRuntimeOptions",
169169
s"-H:CLibraryPath=$cLibPath"
170-
)
170+
) ++ (if (Properties.isLinux && isArmArchitecture) // https://stackoverflow.com/a/61325264
171+
Seq("-Djdk.lang.Process.launchMechanism=vfork")
172+
else Nil)
171173
}
172174
def nativeImageName = "scala-cli"
173175
def nativeImageClassPath = T {

0 commit comments

Comments
 (0)