Skip to content

Android aarch64 SCons build uses llvm-as without target flags #1254

@alvoron

Description

@alvoron

The Android AArch64 build fails when assembling KleidiAI AArch64 .S files with SCons.
The SCons toolchain sets AS = <toolchain_prefix>as, which becomes llvm-as for NDK toolchains (because toolchain_prefix is set to .../bin/llvm-).
llvm-as is the LLVM IR assembler, not an AArch64 assembler, and it does not accept AArch64 mnemonics.

Even after setting AS = CC for Android, the assembler target flags are not propagated, so clang still defaults to the host target and fails to parse AArch64 instructions.

The issue was reproduced in OpenVINO CI: https://github.com/openvinotoolkit/openvino/actions/runs/21475861394/job/61860105092?pr=33871#step:14:7011

CI environment:

  • Android NDK r29 (clang toolchain)
  • AArch64 (arm64-v8.2-a), estate=64

Example failure (AArch64 Android, estate=64):

kai_matmul_clamp_f32_f32_f32p8x1biasf32_6x8x4_neon_mla_asm.S:52:22: error: expected ']' in brackets expression
    stp x20, x21, [sp, -144]!
                     ^

I fixed it by using CC as assembler and forwarding the target flags in SConstruct:

if env['os'] == 'windows':
    ...
elif env['os'] == 'android':
    env['AS'] = env['CC']
    env.Append(ASFLAGS = env['extra_cc_flags'])

This ensures clang assembles .S with the correct --target and prevents the AArch64 syntax errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions