diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 74c99390fa4d..2e18d62df346 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 + - 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 <= TARGET_PentiumPro) return 0xEE; // FLDZ is the only one with 1 micro-op diff --git a/compiler/src/dmd/lib/scanmach.d b/compiler/src/dmd/lib/scanmach.d index 0d0d5c28716f..ee0a7019cc3f 100644 --- a/compiler/src/dmd/lib/scanmach.d +++ b/compiler/src/dmd/lib/scanmach.d @@ -19,6 +19,7 @@ import dmd.location; //import core.sys.darwin.mach.loader; import dmd.backend.mach; import dmd.root.string : fTuple; +import dmd.target : target; nothrow: @@ -79,9 +80,10 @@ void scanMachObjModule(void delegate(const(char)[] name, int pickAny) nothrow pA header64 = cast(mach_header_64*)buf; if (buflen < mach_header_64.sizeof) return corrupt(__LINE__); - if (header64.cputype != CPU_TYPE_X86_64) + const expectedCPUType = target.isAArch64 ? CPU_TYPE_ARM64 : CPU_TYPE_X86_64; + if (header64.cputype != expectedCPUType) { - eSink.error(Loc.initial, "Mach-O object module `%s` has cputype = %d, should be %d", module_name, header64.cputype, CPU_TYPE_X86_64); + eSink.error(Loc.initial, "Mach-O object module `%s` has cputype = %d, should be %d", module_name, header64.cputype, expectedCPUType); return; } if (header64.filetype != MH_OBJECT) diff --git a/compiler/src/dmd/link.d b/compiler/src/dmd/link.d index a0850b829165..2402ed6682ab 100644 --- a/compiler/src/dmd/link.d +++ b/compiler/src/dmd/link.d @@ -443,10 +443,31 @@ public int runLINK(bool verbose, ErrorSink eSink) argv.push("-g"); if (target.isX86_64) argv.push("-m64"); - else + else if (target.isX86) argv.push("-m32"); version (OSX) { + // might need to set up Apple clang for cross-linking + if (target.os == Target.OS.OSX) + { + version (AArch64) + { + if (target.isX86_64) + { + argv.push("-arch"); + argv.push("x86_64"); + } + } + else + { + if (target.isAArch64) + { + argv.push("-arch"); + argv.push("arm64"); + } + } + } + /* Without this switch, ld generates messages of the form: * ld: warning: could not create compact unwind for __Dmain: offset of saved registers too far to encode * meaning they are further than 255 bytes from the frame register. diff --git a/compiler/src/dmd/target.d b/compiler/src/dmd/target.d index f52bcc57b8f2..61e4a44f9c0b 100644 --- a/compiler/src/dmd/target.d +++ b/compiler/src/dmd/target.d @@ -485,6 +485,22 @@ extern (C++) struct Target } } + // fix up RealProperties if the target real is x87, but host real_t isn't + if (realsize - realpad == 10 && RealProperties.mant_dig != 64) { + import dmd.root.ctfloat : CTFloat; + + bool isOutOfRange; + RealProperties.max = CTFloat.parse("0x1.fffffffffffffffep+16383", isOutOfRange); + RealProperties.min_normal = CTFloat.parse("0x1p-16382", isOutOfRange); + RealProperties.epsilon = CTFloat.parse("0x1p-63", isOutOfRange); + RealProperties.dig = 18; + RealProperties.mant_dig = 64; + RealProperties.max_exp = 16_384; + RealProperties.min_exp = -16_381; + RealProperties.max_10_exp = 4932; + RealProperties.min_10_exp = -4931; + } + c.initialize(params, this); cpp.initialize(params, this); objc.initialize(params, this);