-
-
Notifications
You must be signed in to change notification settings - Fork 636
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
GHA: Experiment with native arm64 DMD build on macos-14 #17035
base: master
Are you sure you want to change the base?
Changes from all commits
835d2b9
70b5f03
9c858d3
f013b70
7cd178d
2ab4b9d
bbb794b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,8 +54,11 @@ jobs: | |
container_image: alpine:3.21 | ||
host_dmd: ldmd2 | ||
# macOS | ||
- job_name: macOS 13 x64, DMD (latest) | ||
os: macos-13 | ||
- job_name: macOS 14 arm64, LDC | ||
os: macos-14 | ||
host_dmd: ldc | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switching the host D compiler to LDC on these macOS arm64 runners means that a native arm64 LDC build is used, generating arm64 binaries. So the fresh DMD is built as a native arm64 executable - but still defaults to generating x86_64 code. [Using a DMD host compiler yields a fresh x86_64 DMD build, which then passes all tests on the arm64 box. In that case, both the host compiler and the fresh DMD need to run in the Rosetta 2 emulator, as both are x86_64 executables.] |
||
- job_name: macOS 14 x64, DMD (latest) | ||
os: macos-14 | ||
host_dmd: dmd | ||
# Disabled because of failure https://issues.dlang.org/show_bug.cgi?id=24518 | ||
# - job_name: macOS 13 x64, DMD (coverage) | ||
|
@@ -79,7 +82,8 @@ jobs: | |
name: ${{ matrix.job_name }} | ||
runs-on: ${{ matrix.os }} | ||
container: ${{ matrix.container_image }} | ||
timeout-minutes: 40 | ||
# for some reason, the compiler testsuite is extremely slow with x86_64 emulation on macos-14 runners | ||
timeout-minutes: ${{ matrix.os == 'macos-14' && 60 || 40 }} | ||
env: | ||
# for ci/run.sh: | ||
OS_NAME: ${{ startsWith(matrix.os, 'ubuntu') && 'linux' || (startsWith(matrix.os, 'macos') && 'osx' || (startsWith(matrix.os, 'windows') && 'windows' || '')) }} | ||
|
@@ -156,7 +160,20 @@ jobs: | |
uses: seanmiddleditch/gha-setup-vsdevenv@v4 | ||
with: | ||
arch: ${{ env.MODEL == '64' && 'x64' || 'x86' }} | ||
- name: 'macOS arm64: Run arm64 smoke test' | ||
if: matrix.os == 'macos-14' | ||
run: | | ||
set -uexo pipefail | ||
|
||
cat >hello.d <<EOF | ||
version (AArch64) {} else static assert(0); | ||
extern(C) int puts(const(char)* s); | ||
extern(C) int main() { puts("Hello world from native arm64!"); return 0; } | ||
EOF | ||
|
||
generated/osx/release/64/dmd -betterC -arm -run hello.d | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be the very first CI test of DMD compiling & linking a native arm64 executable. It currently fails to link; AFAICT, because the Mach-O object file still specifies the x86_64 architecture, although it contains arm64 code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've tried to implement the trivial Mach-O header changes; now the linker complains about an invalid relocation:
I'm not going down that rabbit hole. ;) |
||
- name: Test dmd | ||
if: success() || failure() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [continue if the arm64 smoke test step failed] |
||
run: ci/run.sh test_dmd | ||
- name: Test druntime | ||
if: '!matrix.coverage && (success() || failure())' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,12 @@ if [ "$OS_NAME" == "linux" ]; then | |
elif [ "$OS_NAME" == "osx" ]; then | ||
# upgrade GNU make | ||
brew install make | ||
sudo ln -s /usr/local/opt/make/libexec/gnubin/make /usr/local/bin/make | ||
for candidateDir in /usr/local/opt/make/libexec/gnubin /opt/homebrew/opt/make/libexec/gnubin; do | ||
if [[ -f $candidateDir/make ]]; then | ||
sudo ln -s $candidateDir/make /usr/local/bin/make | ||
break | ||
fi | ||
done | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [the location of GNU make is different for the arm64 macOS runners (vs. x86_64 macos-13 runners)] |
||
elif [ "$OS_NAME" == "freebsd" ]; then | ||
packages="git gmake devel/llvm12" | ||
if [ "$HOST_DMD" == "dmd-2.079.0" ] ; then | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -649,7 +649,7 @@ ubyte loadconst(elem* e, int im) | |
immutable double[7] dval = | ||
[0.0,1.0,PI,LOG2T,LOG2E,LOG2,LN2]; | ||
|
||
static if (real.sizeof < 10) | ||
static if (!is(targ_ldouble == real)) | ||
{ | ||
import dmd.root.longdouble; | ||
immutable targ_ldouble[7] ldval = | ||
|
@@ -742,7 +742,7 @@ ubyte loadconst(elem* e, int im) | |
// Note that for this purpose, -0 is not regarded as +0, | ||
// since FLDZ loads a +0 | ||
assert(sz <= zeros.length); | ||
zero = (memcmp(p, zeros.ptr, sz) == 0); | ||
zero = (memcmp(p, zeros.ptr, sz < targ_ldouble.sizeof ? sz : targ_ldouble.sizeof) == 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shows one of the current problems for cross-compiling with DMD - it currently assumes the target Any native arm64 DMD build will never be able to use a hardware x87 So this means that the native macOS arm64 DMD build here for CI uses a double-precision LDC has the same basic problem/limitation, mentioning this in https://wiki.dlang.org/Cross-compiling_with_LDC#Limitations. GDC uses a software Wrt. DMD, there might easily be more locations in the backend with assumptions that |
||
if (zero && config.target_cpu >= TARGET_PentiumPro) | ||
return 0xEE; // FLDZ is the only one with 1 micro-op | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
macos-14
onwards are native M1 runners. These macOS arm64 runners offer a builtin x86_64 emulator - as opposed to the Linux AArch64 GitHub Actions runners. This means we can still generate x86_64 code and run it directly on these runners.