Skip to content

Build angelscript arm64 calling-convention asm on macOS#140

Merged
rlcevg merged 1 commit into
rlcevg:barbarianfrom
tomjn:macos-arm64-angelscript-asm
Jun 22, 2026
Merged

Build angelscript arm64 calling-convention asm on macOS#140
rlcevg merged 1 commit into
rlcevg:barbarianfrom
tomjn:macos-arm64-angelscript-asm

Conversation

@tomjn

@tomjn tomjn commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Problem

Building the BARb Skirmish AI on macOS / Apple Silicon (arm64) fails at link:

Undefined symbols for architecture arm64:
  "_CallARM64", "_CallARM64Double", "_CallARM64Float", "_CallARM64Ret128",
  "_CallARM64RetInMemory", "_GetHFAReturnDouble", "_GetHFAReturnFloat"
    referenced from: CallSystemFunctionNative(...) in as_callfunc_arm64.cpp.o

On arm64, angelscript's as_config.h enables the native calling convention
(AS_ARM64), so as_callfunc_arm64.cpp references the CallARM64 / GetHFAReturn*
symbols. Those are defined in a hand-written assembly stub
(as_callfunc_arm64_xcode.S), but the Skirmish AI source glob only collects
C/C++ sources, so no .S is ever compiled and the symbols are undefined.

(This only affects arm64; on x86_64 angelscript uses inline-asm .cpp, which the
glob already picks up — so this never surfaced on the usual Linux/x86_64 builds.)

Fix

On APPLE AND arm64, enable_language(ASM) and add
src/lib/angelscript/source/as_callfunc_arm64_xcode.S to the sources.

The xcode variant is required (not _gcc.S) because Mach-O prefixes symbols
with a leading underscore (_CallARM64) regardless of compiler — it's an object
format concern, not a compiler one.

Verification

Built on macOS / Apple Silicon with Homebrew GCC 16: as_callfunc_arm64_xcode.S
compiles, SkirmishAI.dylib links with no undefined symbols, and the engine's
spring-headless links cleanly with the AIs enabled (-DAI_TYPES=NATIVE).


Assisted by Claude Code; verified by building on macOS.

On Apple Silicon (arm64) angelscript enables its native calling
convention (AS_ARM64), so CallSystemFunctionNative references CallARM64,
GetHFAReturn*, etc. Those symbols are defined in a hand-written assembly
stub, but the Skirmish AI source glob only collects C/C++ sources, so no
.S file is ever compiled and linking SkirmishAI fails with:

  Undefined symbols for architecture arm64:
    "_CallARM64", "_CallARM64Double", "_CallARM64Float",
    "_CallARM64Ret128", "_CallARM64RetInMemory",
    "_GetHFAReturnDouble", "_GetHFAReturnFloat"

Add the asm stub explicitly on Apple+arm64 and enable the ASM language.
The xcode variant is required (not the gcc one) because Mach-O prefixes
symbols with a leading underscore, independent of the compiler used.

Assisted by Claude Code; verified by building on macOS (Homebrew GCC 16,
Apple Silicon): SkirmishAI.dylib and spring-headless link cleanly.
@tomjn tomjn force-pushed the macos-arm64-angelscript-asm branch from 37184e9 to 8331880 Compare June 20, 2026 16:42
@rlcevg rlcevg merged commit eb650ec into rlcevg:barbarian Jun 22, 2026
@rlcevg

rlcevg commented Jun 22, 2026

Copy link
Copy Markdown
Owner

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants