From cb46744cb89b5dcc3e5ddc35877b2ef814c64da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 21 Mar 2023 12:43:08 +0200 Subject: [PATCH] launcher: use `-mcpu=baseline` This log message has been seen in a Github Actions worker: running <...>/c++ failed: signal: illegal instruction (core dumped) I conclude that the launcher was compiled on a newer CPU than used on the worker at the time. Reported-by: mp@edgeless.systems Fixes #22 --- ci/launcher | 7 ++++++- toolchain/defs.bzl | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ci/launcher b/ci/launcher index d35696a..325739b 100755 --- a/ci/launcher +++ b/ci/launcher @@ -16,7 +16,12 @@ for target in \ x86_64-macos-none \ x86_64-windows-gnu do - $ZIG build-exe -fno-emit-bin -target $target toolchain/launcher.zig + if [[ $target == aarch64-macos-none ]]; then + mcpu=apple_a14 + else + mcpu=baseline + fi + $ZIG build-exe -fno-emit-bin -target $target -mcpu=$mcpu toolchain/launcher.zig done echo "--- zig fmt --check toolchain/launcher.zig" diff --git a/toolchain/defs.bzl b/toolchain/defs.bzl index 80be3fd..72a41d9 100644 --- a/toolchain/defs.bzl +++ b/toolchain/defs.bzl @@ -38,6 +38,14 @@ _HOST_PLATFORM_EXT = { "windows-x86_64": "zip", } +_MCPU = { + "linux-aarch64": "baseline", + "linux-x86_64": "baseline", + "macos-aarch64": "apple_a14", + "macos-x86_64": "baseline", + "windows-x86_64": "baseline", +} + _compile_failed = """ Compilation of launcher.zig failed: command={compile_cmd} @@ -164,6 +172,7 @@ def _zig_repository_impl(repository_ctx): compile_cmd = [ _paths_join("..", "zig"), "build-exe", + "-mcpu={}".format(_MCPU[host_platform]), "-OReleaseSafe", "launcher.zig", ] + (["-static"] if os == "linux" else [])