Skip to content

Static Linux SDK 6.4.2: AArch64 binaries crash with SIGILL on ARMv8.0 due to mimalloc LSE instructions #94322

Closed

Description

@wlstnals4028

Description

The Swift 6.4.2 Static Linux SDK (swift-6.4.2-RELEASE_static-linux-0.1.0) produces AArch64 static executables that crash with SIGILL (Illegal instruction) on ARMv8.0 CPUs, such as the Cortex-A53 used by some OpenWrt devices.

Even a minimal print("Hello World") program fails to execute.

The same executable runs successfully under QEMU with -cpu max, but crashes with -cpu cortex-a53.

Specifying -target-cpu cortex-a53 during compilation does not resolve the issue.

GDB confirms that the crash occurs in mimalloc, which is statically linked into the executable through the SDK's libc.a.

The failing instruction is ldaddal, an ARMv8.1-A LSE atomic instruction that is not supported by ARMv8.0 CPUs.

This appears to be the same underlying issue previously reported in swiftlang/swift-docker#604, originally affecting the Swift 6.4.0 Static Linux SDK. I can confirm that the issue is also reproducible with the 6.4.2 release.

Reproduction

Create a minimal Swift program:

print("Hello World")

Save it as hello.swift.

Using the Swift 6.4.2 Static Linux SDK, compile it for AArch64 musl with Cortex-A53 as the target CPU.

In my installation, the SDK sysroot is located under the installed artifact bundle's musl-1.2.5.sdk/aarch64 directory.

SDK=$(find "$HOME/.swiftpm/swift-sdks" \
    -type d \
    -path '*/musl-1.2.5.sdk/aarch64' \
    -print -quit)

RES="$SDK/usr/lib/swift_static"

swiftc hello.swift -O \
    -target aarch64-swift-linux-musl \
    -target-cpu cortex-a53 \
    -sdk "$SDK" \
    -sysroot "$SDK" \
    -resource-dir "$RES" \
    -static-executable \
    -o hello

Test the resulting executable using QEMU:

$ qemu-aarch64 -cpu cortex-a53 ./hello
qemu: uncaught target signal 4 (Illegal instruction) - core dumped
Illegal instruction

$ qemu-aarch64 -cpu max ./hello
Hello World

The executable also crashes with Illegal instruction when run directly on an OpenWrt device using a Cortex-A53 CPU.

I investigated the crash using QEMU's GDB remote debugging support:

qemu-aarch64 -cpu cortex-a53 -g 1234 ./hello

In another terminal:

(gdb) target remote :1234
(gdb) continue

Program received signal SIGILL, Illegal instruction.

0x000000000076d75c in mi_out_buf_flush (...)
at /home/build-user/source/mimalloc/src/options.c:352

Inspecting the instruction at the program counter:

(gdb) x/i $pc

=> 0x76d75c <_mi_options_init+24>: ldaddal x8, x8, [x9]

This confirms that the executable attempts to execute an ARMv8.1-A LSE instruction on an ARMv8.0 CPU.

Expected behavior

AArch64 static executables built with the Swift Static Linux SDK should run on ARMv8.0 CPUs unless a newer architecture is explicitly required.

Specifying -target-cpu cortex-a53 should not result in an executable that unconditionally executes ARMv8.1-A instructions from precompiled SDK libraries.

The SDK's bundled mimalloc should either use an ARMv8.0-compatible baseline or provide runtime CPU feature detection before using LSE atomics.

Environment

Build environment:

OS: Linux (Asahi Linux kernel)

Architecture: AArch64

$ uname -a
Linux test 7.3.3-asahi-1-cy8aer1 #121 SMP PREEMPT Sun Nov 8 14:45:48 CET 2026 aarch64 GNU/Linux

Swift:

$ swift --version
Swift version 6.4.2 (swift-6.4.2-RELEASE)
Target: aarch64-unknown-linux-gnu

Clang:

$ clang --version
clang version 21.0.0 (https://github.com/swiftlang/llvm-project.git fb5f84d903a3b4e7aea15cd5666598a46f56c833)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /root/.local/share/swiftly/toolchains/6.4.2/usr/bin

Static Linux SDK: swift-6.4.2-RELEASE_static-linux-0.1.0

Target triple: aarch64-swift-linux-musl

Musl version: 1.2.5

Build configuration: -O -target-cpu cortex-a53 -static-executable

Target environment:

OS: OpenWrt

Architecture: AArch64

CPU: ARM Cortex-A53 (ARMv8.0-A)

$ uname -m
aarch64

$ cat /proc/cpuinfo
processor       : 0
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 1
Features        : fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

The target CPU does not support ARMv8.1-A LSE atomic instructions.

Debugging environment:

GDB: 16.3

QEMU: qemu-aarch64 (cortex-a53 and max CPU configurations)

Additional information

The underlying mimalloc configuration issue was previously investigated in:

That report identifies mimalloc's architecture-specific optimization setting as the cause. Mimalloc 2.2.x enables ARMv8.1-A optimizations by default on AArch64, introducing LSE instructions into the precompiled mimalloc.o included in the SDK's libc.a.

I was able to reproduce the issue and verify a working fix with the Swift 6.4.2 Static Linux SDK.

I rebuilt mimalloc 2.2.4 with the following options:

-DMI_LIBC_MUSL=ON
-DMI_NO_OPT_ARCH=ON
-DCMAKE_C_FLAGS="-march=armv8-a"

I then replaced the original mimalloc.o in the SDK's AArch64 libc.a with the rebuilt object and regenerated the archive index.

ar r "$SDK/usr/lib/libc.a" mimalloc.o
ranlib "$SDK/usr/lib/libc.a"

After recompiling the same Swift program using the modified SDK:

$ qemu-aarch64 -cpu cortex-a53 ./hello
Hello World

A separate Swift program that retrieves the current user's information also executes successfully on the actual OpenWrt Cortex-A53 device:

root@OpenWrt:~# ./main
사용자: root
UID: 0
GID: 0
홈 디렉터리: /root
셸: /bin/ash

This confirms that replacing the SDK's mimalloc object with an ARMv8.0-compatible build resolves the observed crash, without modifying the Swift source code or rebuilding the entire Swift toolchain.

Related reports and work:

It appears that the prebuilt Static Linux SDK distributed with Swift 6.4.2 still includes a mimalloc object that uses ARMv8.1-A instructions unconditionally.

Would it be possible to build the bundled mimalloc with MI_NO_OPT_ARCH=ON, or otherwise ensure ARMv8.0 compatibility for the default AArch64 Static Linux SDK?

Activity

  1. added theissue type on Nov 14, 2026
  2. wlstnals4028 commented on Nov 14, 2026

    @wlstnals4028
    Author

    I found that this issue has already been fixed by swiftlang/swift-docker#611, which was merged on November 9.

    The fix is not included in the released Swift 6.4.2 Static Linux SDK, which explains why I was still able to reproduce the crash.

    I'll close this issue as fixed upstream. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage neededThis issue needs more specific labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions