Fix macOS arm64 (Apple Silicon) linker support#470
Open
metaneutrons wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the build/link logic to support successful linking on macOS arm64 (Apple Silicon) by adjusting architecture detection and Darwin-specific linker flags/behaviors.
Changes:
- Normalize
arm64toaarch64in the makefile’sTARGET_ARCHdetection before the 32-bit ARM normalization. - Update the Darwin linker invocation in
fbc.basto add-arch arm64for AArch64 and use modern-platform_version/-syslibrootbehavior (includingxcrunSDK detection on Darwin hosts), while avoiding GNU-ld-only flags/libs on Darwin. - Make cycle profiling compile on Darwin by disabling ELF section-boundary-symbol usage and emitting an empty report payload.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| makefile | Normalizes arm64 → aarch64 ahead of 32-bit ARM matching to select the correct target CPU family on macOS Apple Silicon. |
| src/compiler/fbc.bas | Adjusts Darwin link flags for arm64 and modern Apple ld usage (SDK/sysroot handling, platform version, and default libs). |
| src/rtlib/profile_cycles.c | Guards ELF __start/__stop usage on Darwin and provides a safe no-data fallback so it compiles on Mach-O. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix linking on macOS arm64 (Apple Silicon, M1/M2/M3/M4).
Changes (3 files, +47/-11)
makefile:
arm64(fromuname -m) toaarch64before the 32-bitarmv%catch-allsrc/compiler/fbc.bas:
line inputinhGet1stOutputLineFromCommand(handles spaces in SDK paths)-arch arm64forFB_CPUFAMILY_AARCH64on darwin-macosx_version_minwith-platform_version macos <min> <sdk>xcrun --show-sdk-version(fallback 14.0)xcrun --show-sdk-path(only on darwin host, respects user-sysroot, quoted with QUOTE)--sysroot=on darwin (Apple ld uses-syslibroot)--eh-frame-hdron darwin (unsupported by Apple ld)-lgccfrom darwin default libs (unavailable with Apple clang)src/rtlib/profile_cycles.c:
__start_/__stop_section boundary symbol declarations and usage with!defined(HOST_DARWIN)data=NULL, length=0fallback on darwin (cycle profiling compiles but produces no output)Testing
Successfully builds fbc and runtime library on macOS 15 (Sequoia) with Apple clang 21 on M4.
Notes
-profile cyclescompiles on darwin but produces no per-procedure data (Mach-O lacks ELF section boundary symbols)bootstrap/darwin-aarch64/(copy frombootstrap/linux-aarch64/+ fix clang computed goto)