Skip to content

Commit 44a615a

Browse files
Require opt-in via force-arch to run x86 on macOS arm (#352)
* require opt-in via `force-arch` to run x86 on macOS arm * Update src/setup-julia.ts * Run `make everything-from-scratch`, and check-in * Fix CI in #352 (#373) * Fix CI in #352 * Clarify a statement about the support for 32-bit builds --------- Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
1 parent 4c0cb0f commit 44a615a

7 files changed

Lines changed: 100 additions & 24 deletions

File tree

.github/workflows/example-builds-nightly.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,23 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
julia-version: [nightly, 1.13-nightly]
24-
julia-arch: [x64, x86]
25-
os: [ubuntu-latest, macOS-latest, windows-latest]
23+
julia-version:
24+
- nightly
25+
- 1.13-nightly
26+
julia-wordsize:
27+
- 64
28+
- 32
29+
os:
30+
- ubuntu-latest
31+
- windows-latest
32+
- macos-15-intel # Intel
33+
- macos-latest # Apple Silicon
2634
# 32-bit Julia binaries are not available on macOS
2735
exclude:
28-
- os: macOS-latest
29-
julia-arch: x86
36+
- os: macos-15-intel # Intel
37+
julia-wordsize: 32
38+
- os: macos-latest # Apple Silicon
39+
julia-wordsize: 32
3040

3141
steps:
3242
- uses: actions/checkout@v6.0.2
@@ -47,7 +57,14 @@ jobs:
4757
uses: ./
4858
with:
4959
version: ${{ matrix.julia-version }}
50-
arch: ${{ matrix.julia-arch }}
60+
# If `julia-wordsize` is 32, then we set `arch` to `x86`, because we know that
61+
# 32-bit builds of Julia are only available for x86.
62+
#
63+
# If `julia-wordsize` is 64, then we set `arch` to `${{ runner.arch }}`, which
64+
# GitHub will automatically expand to the correct value (`x86_64` or `aarch64`)
65+
# based on the architecture of the underlying GitHub Runner (virtual machine).
66+
arch: ${{ matrix.julia-wordsize == '32' && 'x86' || runner.arch }}
67+
5168
- run: julia --version
5269
- run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()'
5370
- name: "Check that the correct julia is used and that archive mtimes are maintained"

.github/workflows/example-builds.yml

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,50 @@ on:
1212
pull_request:
1313
workflow_dispatch:
1414

15+
permissions:
16+
contents: read
17+
1518
jobs:
1619
test:
1720
runs-on: ${{ matrix.os }}
1821
timeout-minutes: 60
1922
strategy:
2023
fail-fast: false
2124
matrix:
22-
# include '1.6' here to test info message about lts tag existing
23-
julia-version: ['1.0.5', '1.2', '^1.5.0-beta1', '1', '1.6', 'lts', 'pre']
24-
julia-arch: [x64, x86]
25-
os: [ubuntu-latest, macOS-latest, windows-latest]
25+
julia-version:
26+
- '1.0.5'
27+
- '1.2'
28+
- '^1.5.0-beta1'
29+
- '1'
30+
- '1.6'
31+
- '1.10' # include '1.10' here to test info message about lts tag existing
32+
- 'lts'
33+
- 'pre'
34+
julia-wordsize:
35+
- 64
36+
- 32
37+
os:
38+
- ubuntu-latest
39+
- windows-latest
40+
- macos-15-intel # Intel
41+
- macos-latest # Apple Silicon
2642
# 32-bit Julia binaries are not available on macOS
2743
exclude:
28-
- os: macOS-latest
29-
julia-arch: x86
30-
include:
31-
- os: macOS-latest
32-
julia-arch: aarch64
33-
julia-version: 'lts'
34-
- os: macOS-latest
35-
julia-arch: aarch64
36-
julia-version: '1'
37-
44+
- os: macos-15-intel # Intel
45+
julia-wordsize: 32
46+
- os: macos-latest # Apple Silicon
47+
julia-wordsize: 32
48+
# Julia versions prior to 1.8 do not have native builds for Apple Silicon
49+
- os: macos-latest # Apple Silicon
50+
julia-version: '1.0.5'
51+
- os: macos-latest # Apple Silicon
52+
julia-version: '1.2'
53+
- os: macos-latest # Apple Silicon
54+
julia-version: '1.6'
3855
steps:
3956
- uses: actions/checkout@v6.0.2
57+
with:
58+
persist-credentials: false
4059

4160
- uses: actions/setup-node@v6
4261
if: ${{ ! startsWith(github.ref, 'refs/heads/releases') }}
@@ -55,7 +74,14 @@ jobs:
5574
uses: ./
5675
with:
5776
version: ${{ matrix.julia-version }}
58-
arch: ${{ matrix.julia-arch }}
77+
# If `julia-wordsize` is 32, then we set `arch` to `x86`, because we know that
78+
# Tier 1 32-bit builds of Julia are only available for x86.
79+
#
80+
# If `julia-wordsize` is 64, then we set `arch` to `${{ runner.arch }}`, which
81+
# GitHub will automatically expand to the correct value (`x86_64` or `aarch64`)
82+
# based on the architecture of the underlying GitHub Runner (virtual machine).
83+
arch: ${{ matrix.julia-wordsize == '32' && 'x86' || runner.arch }}
84+
5985
- run: julia --version
6086
- run: julia --compile=min -O0 -e 'import InteractiveUtils; InteractiveUtils.versioninfo()'
6187
- name: "Check that the correct julia is used and that archive mtimes are maintained"

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@ This action sets up a Julia environment for use in actions by downloading a spec
5656
# Specifying 'default' uses the architecture of the runner executing the job.
5757
arch: 'default'
5858

59+
# Force the use of the specified architecture even when it may be suboptimal on the runner.
60+
#
61+
# By default, requesting x86 or x64 on an aarch64 macOS runner (Apple Silicon) will fail with an error,
62+
# as this is usually a misconfiguration. Set this to 'true' to override the error and allow the installation.
63+
#
64+
# Note: x64 Julia can run on Apple Silicon via Rosetta 2, but native aarch64 is typically preferred.
65+
#
66+
# Supported values: true | false
67+
#
68+
# Default: false
69+
force-arch: 'false'
70+
5971
# Set the display setting for printing InteractiveUtils.versioninfo() after installing.
6072
#
6173
# Starting Julia and running InteractiveUtils.versioninfo() takes a significant amount of time (1s or ~10% of the total build time in testing),

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
description: 'Architecture of the Julia binaries. Defaults to the architecture of the runner executing the job.'
1414
required: false
1515
default: 'default'
16+
force-arch:
17+
description: 'Force the use of the specified architecture even when it may be suboptimal on the runner (e.g., x86 on Apple Silicon macOS runners). By default, requesting x86/x64 on aarch64 macOS runners will fail with an error.'
18+
required: false
19+
default: 'false'
1620
show-versioninfo:
1721
description: 'Display InteractiveUtils.versioninfo() after installing'
1822
required: false

dist/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ function run() {
585585
const versionInput = core.getInput('version').trim();
586586
const includePrereleases = core.getInput('include-all-prereleases').trim() == 'true';
587587
const originalArchInput = core.getInput('arch').trim();
588+
const forceArch = core.getInput('force-arch').trim() == 'true';
588589
const projectInput = core.getInput('project').trim(); // Julia project file
589590
// It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
590591
// while the strategy matrix only contains a key `${{ matrix.version }}`.
@@ -601,7 +602,12 @@ function run() {
601602
throw new Error(`Arch input must not be null`);
602603
}
603604
if (originalArchInput == 'x64' && os.platform() == 'darwin' && os.arch() == 'arm64') {
604-
core.warning('[setup-julia] x64 arch has been requested on a macOS runner that has an arm64 (Apple Silicon) architecture. You may have meant to use the "aarch64" arch instead (or left it unspecified for the correct default).');
605+
if (forceArch) {
606+
core.warning('[setup-julia] x64 arch has been requested on a macOS runner that has an arm64 (Apple Silicon) architecture. The "force-arch" input is set to "true", so proceeding with x64 installation. Note that this will mean Julia will be run under Rosetta emulation.');
607+
}
608+
else {
609+
throw new Error('[setup-julia] x64 arch has been requested on a macOS runner that has an arm64 (Apple Silicon) architecture. You may have meant to use the "aarch64" arch instead (or "default" or left it unspecified for the correct default). To force the use of x64 on this runner, set the "force-arch" input to "true".');
610+
}
605611
}
606612
let processedArchInput;
607613
if (originalArchInput == "default") {

lib/setup-julia.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/setup-julia.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ async function run() {
4545
const versionInput = core.getInput('version').trim()
4646
const includePrereleases = core.getInput('include-all-prereleases').trim() == 'true'
4747
const originalArchInput = core.getInput('arch').trim()
48+
const forceArch = core.getInput('force-arch').trim() == 'true'
4849
const projectInput = core.getInput('project').trim() // Julia project file
4950

5051
// It can easily happen that, for example, a workflow file contains an input `version: ${{ matrix.julia-version }}`
@@ -63,7 +64,11 @@ async function run() {
6364
}
6465

6566
if (originalArchInput == 'x64' && os.platform() == 'darwin' && os.arch() == 'arm64') {
66-
core.warning('[setup-julia] x64 arch has been requested on a macOS runner that has an arm64 (Apple Silicon) architecture. You may have meant to use the "aarch64" arch instead (or left it unspecified for the correct default).')
67+
if (forceArch) {
68+
core.warning('[setup-julia] x64 arch has been requested on a macOS runner that has an arm64 (Apple Silicon) architecture. The "force-arch" input is set to "true", so proceeding with x64 installation. Note that this will mean Julia will be run under Rosetta emulation.')
69+
} else {
70+
throw new Error('[setup-julia] x64 arch has been requested on a macOS runner that has an arm64 (Apple Silicon) architecture. You may have meant to use the "aarch64" arch instead (or "default" or left it unspecified for the correct default). To force the use of x64 on this runner, set the "force-arch" input to "true".')
71+
}
6772
}
6873

6974
let processedArchInput: string;

0 commit comments

Comments
 (0)