Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,65 @@ jobs:
tag: ${{ env.TOIT_VERSION }}
overwrite: true

test_cross:
runs-on: ${{ matrix.os }}
needs: [prereqs, combine]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- name: Set up constants
id: constants
shell: bash
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
echo "artifact=toit-linux-x64.tar.gz" >> $GITHUB_OUTPUT
echo "artifact_name=Linux-build-combined" >> $GITHUB_OUTPUT
elif [[ "$RUNNER_OS" == "macOS" ]]; then
echo "artifact=toit-macos.tar.gz" >> $GITHUB_OUTPUT
echo "artifact_name=macOS-build-unsigned-combined" >> $GITHUB_OUTPUT
elif [[ "$RUNNER_OS" == "Windows" ]]; then
echo "artifact=toit-windows.tar.gz" >> $GITHUB_OUTPUT
echo "artifact_name=Windows-build-unsigned-combined" >> $GITHUB_OUTPUT
else
echo "UNSUPPORTED RUNNER: $RUNNER_OS"
exit 1
fi

- uses: actions/download-artifact@v7
with:
name: ${{ steps.constants.outputs.artifact_name }}

- name: Unpack SDK
shell: bash
run: |
tar x -zf ${{ steps.constants.outputs.artifact }}

- name: Test cross compilation
shell: bash
run: |
echo 'main: print "hello world"' > hello.toit
for out_os in linux darwin windows; do
for out_arch in amd64 aarch64 arm arm64 riscv64; do
# The windows build of the compiler needs .exe
COMPILER="toit/bin/toit"
if [[ "$RUNNER_OS" == "Windows" ]]; then COMPILER="toit/bin/toit.exe"; fi

VESSEL_ARCH=$out_arch
if [[ "$out_os" == "darwin" && "$out_arch" == "amd64" ]]; then
# The compiler automatically uses the fat binary in aarch64 for amd64 darwin.
VESSEL_ARCH="aarch64"
fi

if [ -d "toit/lib/toit/vessels/$out_os/$VESSEL_ARCH" ]; then
echo "Cross-compiling for $out_os/$out_arch"
./$COMPILER compile --os=$out_os --arch=$out_arch -o hello_out hello.toit
fi
done
done

sign_windows:
runs-on: windows-latest
needs: [prereqs, combine]
Expand Down
4 changes: 4 additions & 0 deletions src/compiler/executable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ int create_executable(const char* out_path,
}
if (os != null) {
builder.join(os);
if (strcmp(os, "darwin") == 0 && strcmp(arch, "amd64") == 0) {
// We now have fat binaries that combine arm64 and x64.
arch = "aarch64";
}
}
if (arch != null) {
// If we have an arch, we should always have an os, but we
Expand Down
Loading