Closed aminya closed 1 year ago
there is a check that aborts the extension right now if you are not on x86_64: https://github.com/dlang-community/setup-dlang/blob/v1/src/main.ts#L10
We don't have any devices outside the GitHub Actions runners, so we only have x86 runners and can't really test if the extension works on other architectures.
I am trying to cross-compile for Arm64 Mac. Ldc supports this if the correct environment variables are set.
Here is an example: https://github.com/aminya/minijson/pull/23/files#diff-3ab46ee209a127470fce3c2cf106b1a1dbadbb929a4b5b13656a4bc4ce19c0b8R73
- name: Setup Mac Arm64
shell: bash
if: contains(matrix.os, 'macos-11')
run: |
ARCH="arm64"
echo "ARCH=$ARCH" >> $GITHUB_ENV
echo "triple=$ARCH-apple-macos" >> $GITHUB_ENV
echo "DFLAGS='-mtriple=$triple -Xcc=target -Xcc=$ARCH-apple-macos'" >> $GITHUB_ENV
echo "CPPFLAGS=$CPPFLAGS -arch $ARCH" >> $GITHUB_ENV
echo "CFLAGS=$CFLAGS -arch $ARCH" >> $GITHUB_ENV
echo "LDFLAGS=$LDFLAGS -arch $ARCH" >> $GITHUB_ENV
cross compiling to arm should be possible, though I haven't tried before.
It might be possible to run and include the output of the ldc-build-runtime tool in setup-dlang: https://wiki.dlang.org/Building_LDC_runtime_libraries
I am able to setup LDC for cross-compilation
- name: Setup Mac Arm64
shell: bash
if: contains(matrix.os, 'macos-11')
run: |
ARCH="arm64"
echo "ARCH=$ARCH" >> $GITHUB_ENV
echo "triple=$ARCH-apple-macos" >> $GITHUB_ENV
echo "DFLAGS='-mtriple=$triple -Xcc=target -Xcc=$ARCH-apple-macos'" >> $GITHUB_ENV
echo "CPPFLAGS=$CPPFLAGS -arch $ARCH" >> $GITHUB_ENV
echo "CFLAGS=$CFLAGS -arch $ARCH" >> $GITHUB_ENV
echo "LDFLAGS=$LDFLAGS -arch $ARCH" >> $GITHUB_ENV
# Manually install ldc
# Due to https://github.com/dlang-community/setup-dlang/issues/51
curl -LJO https://github.com/ldc-developers/ldc/releases/download/v1.28.0/ldc2-1.28.0-osx-$ARCH.tar.xz
tar -xf ldc2-1.28.0-osx-$ARCH.tar.xz
rm ldc2-1.28.0-osx-$ARCH.tar.xz
LDC_PATH="~/ldc"
mkdir -p $LDC_PATH
mv ldc2-1.28.0-osx-$ARCH $LDC_PATH
# Activate ldc
echo "LIBRARY_PATH=$LDC_PATH/lib${LIBRARY_PATH:+:}${LIBRARY_PATH:-}" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$LDC_PATH/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH:-}" >> $GITHUB_ENV
echo "PATH=$LDC_PATH/bin${PATH:+:}${PATH:-}" >> $GITHUB_ENV
echo "DMD=ldmd2" >> $GITHUB_ENV
echo "DC=ldc2" >> $GITHUB_ENV
However, it seems that dub support for arm64 is also missing. I might have to compile directly in this case. https://github.com/aminya/minijson/pull/23 https://github.com/aminya/minijson/runs/4667583537?check_suite_focus=true#step:10:25
cross compiling to arm should work like this now:
dub build --arch=arm64-apple-macos --build=release
Does setup-dlang support ldc for Mac ARM?