Skip to content

Commit 40bd1b5

Browse files
committed
[try matching clang from GitHub on macOS arm64]
1 parent 579d3fe commit 40bd1b5

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

.github/actions/1-setup/action.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ runs:
4949
sudo ln -sf $tool-19 /usr/bin/$tool
5050
$tool --version
5151
done
52+
- name: 'macOS arm64: Install clang 19 from GitHub' # see mimalloc comment in ../3-build-native/action.yml
53+
if: runner.os == 'macOS' && inputs.arch == 'arm64'
54+
shell: bash
55+
run: |
56+
set -eux
57+
cd ..
58+
curl -fL --retry 3 --max-time 300 -o clang.tar.xz \
59+
https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.7/LLVM-19.1.7-macOS-ARM64.tar.xz
60+
mkdir clang
61+
tar -xf clang.tar.xz --strip 1 -C clang
62+
rm clang.tar.xz
63+
# prepend its bin/ dir to PATH for subsequent steps
64+
echo "$PWD/clang/bin" >> "$GITHUB_PATH"
5265
- name: 'Windows: Install clang v19.1.3 from GitHub'
5366
if: runner.os == 'Windows'
5467
shell: bash

.github/actions/3-build-native/action.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ runs:
2222
build_dir: build
2323
host_dc: ../bootstrap-ldc/bin/ldmd2
2424
specify_install_dir: true
25-
# FIXME: mimalloc on macOS is tricky - when mixing newer LLVM from bootstrap LDC with older LLVM from Xcode clang,
26-
# causing *sporadic* compiler crashes: `libc++abi: Pure virtual function called!`
27-
# on x86_64, this is 'fixed' by using LTO - on arm64, this doesn't suffice
25+
# NOTE:
26+
# mimalloc on macOS is tricky - when mixing newer LLVM from bootstrap LDC with older LLVM from Xcode clang,
27+
# causing *sporadic* compiler crashes: `libc++abi: Pure virtual function called!`
28+
# On x86_64, this is 'fixed' by using LTO (for both D and C++ parts of ldc2).
29+
# On arm64, we need a matching clang to enable C++ LTO anyway, due to `LLVM ERROR: Unsupported stack probing method` with Xcode clang.
2830
cmake_flags: >-
29-
${{ (runner.os != 'Windows' && !(runner.os == 'macOS' && inputs.arch == 'arm64')) && '-DALTERNATIVE_MALLOC_O="$PWD/../build-mimalloc/CMakeFiles/mimalloc-obj.dir/src/static.c.o"' || '' }}
31+
${{ runner.os != 'Windows' && '-DALTERNATIVE_MALLOC_O="$PWD/../build-mimalloc/CMakeFiles/mimalloc-obj.dir/src/static.c.o"' || '' }}
3032
${{ inputs.cmake_flags }}
3133
${{ inputs.with_pgo == 'true' && '-DDFLAGS_LDC=-fprofile-use=../pgo-ldc/merged.profdata' || '' }}
3234
build_targets: all ldc2-unittest all-test-runners

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ jobs:
8585
os: macos-14
8686
arch: arm64
8787
extra_cmake_flags: >-
88+
-DCMAKE_C_COMPILER=clang
89+
-DCMAKE_CXX_COMPILER=clang++
8890
-DD_COMPILER_FLAGS="-O -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -L-exported_symbol '-L__*' -L-w"
89-
# FIXME: cannot enable LTO for C++ parts too, due to: `LLVM ERROR: Unsupported stack probing method` when linking ldc2
90-
# (apparently from bitcode files compiled with older Xcode clang)
91-
# -DEXTRA_CXXFLAGS=-flto=full
91+
-DEXTRA_CXXFLAGS=-flto=full
9292
with_pgo: true
9393

9494
- job_name: Windows x64

0 commit comments

Comments
 (0)