Skip to content

Commit 1d94125

Browse files
Macos support (#12)
* Add macOS platform support (darwin_x86_64 and darwin_arm64) - Add platform detection for macOS in platform.h using __APPLE__ - Create separate macos.yml workflow for testing both x86_64 and ARM64 - Use darwin_x86_64 and darwin_arm64 ABI names for macOS libraries - Reuse existing AAPCS64/System V assembly implementations * Update to non-deprecated macOS runners (macos-15-intel and macos-latest) * Make ARM64 and x86_64 assembly compatible with macOS Mach-O format - Add conditional macros for Mach-O vs ELF directives - macOS requires leading underscore for C symbols (_stackman_switch) - Replace .type, .size, .section directives with macros that expand appropriately - Fixes build errors on macOS runners * Disable CFI directives on macOS - macOS assembler has different CFI semantics causing errors - Add CFI_* macros that expand to nothing on macOS - CFI directives are for debugging/unwinding, not critical for functionality - Fixes 'invalid CFI advance_loc expression' errors * Fix mktemp issue on macOS in abiname.sh - Clean up stale temp files before creating new ones - Prevents 'File exists' error from mktemp on macOS * Disable static linking on macOS - macOS doesn't support -static flag (no crt0.o available) - Detect Darwin and skip -static flag - Tests will link dynamically on macOS, statically on Linux * Add missing CFI_DEF_CFA_REGISTER macro for x86_64 - Fix .cfi_def_cfa_register directive on macOS - Properly define macro to expand to nothing on Apple platforms * Add macOS builds to main workflow - Added build-macos job with darwin_x86_64 and darwin_arm64 - Included macOS artifacts in release archives - Now builds 9 platforms total (4 Linux, 2 macOS, 3 Windows) * Remove separate macOS workflow (now integrated into main workflow) * Add changelog entry for macOS platform support * Update README with macOS platform support - Updated version to 1.0.1 - Added macOS platforms (darwin_x86_64, darwin_arm64) to supported platforms list - Reorganized platform list by OS for clarity - Updated platform counts (9 ABIs total)
1 parent 251e3c5 commit 1d94125

File tree

8 files changed

+275
-121
lines changed

8 files changed

+275
-121
lines changed

.github/workflows/buildcommit.yml

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,34 @@ jobs:
5252
uses: actions/upload-artifact@v4
5353
with:
5454
name: ${{ env.abiname }}
55-
path: lib/${{ env.abiname }}/libstackman.a
55+
path: lib/${{ env.abiname }}/libstackman.a
56+
57+
build-macos:
58+
runs-on: ${{ matrix.os }}
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
os: [macos-15-intel, macos-latest]
63+
include:
64+
- os: macos-15-intel
65+
abi: darwin_x86_64
66+
- os: macos-latest
67+
abi: darwin_arm64
68+
69+
steps:
70+
- uses: actions/checkout@v4
71+
72+
- name: Build library
73+
run: make all
74+
75+
- name: Run tests
76+
run: make test
77+
78+
- name: Upload artifacts
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: ${{ matrix.abi }}
82+
path: lib/${{ matrix.abi }}/libstackman.a
5683

5784
build-windows:
5885
runs-on: windows-latest
@@ -89,7 +116,7 @@ jobs:
89116

90117
commit-artifacts:
91118
runs-on: ubuntu-latest
92-
needs: [build-linux-gnu, build-windows]
119+
needs: [build-linux-gnu, build-macos, build-windows]
93120
if: false # Disabled - libraries no longer committed to repository
94121
steps:
95122
- uses: actions/checkout@v4
@@ -108,7 +135,7 @@ jobs:
108135
109136
create-release:
110137
runs-on: ubuntu-latest
111-
needs: [build-linux-gnu, build-windows]
138+
needs: [build-linux-gnu, build-macos, build-windows]
112139
if: startsWith(github.ref, 'refs/tags/v')
113140
permissions:
114141
contents: write
@@ -129,6 +156,8 @@ jobs:
129156
cp -r artifacts/sysv_i386 release/lib/
130157
cp -r artifacts/arm32 release/lib/
131158
cp -r artifacts/aarch64 release/lib/
159+
cp -r artifacts/darwin_x86_64 release/lib/
160+
cp -r artifacts/darwin_arm64 release/lib/
132161
cp -r artifacts/win_x86 release/lib/
133162
cp -r artifacts/win_x64 release/lib/
134163
cp -r artifacts/win_arm64 release/lib/
@@ -168,6 +197,8 @@ jobs:
168197
sysv_i386/ - Linux x86 (32-bit)
169198
arm32/ - Linux ARM (32-bit, AAPCS)
170199
aarch64/ - Linux ARM64 (AAPCS64)
200+
darwin_x86_64/ - macOS x86_64 (Intel)
201+
darwin_arm64/ - macOS ARM64 (Apple Silicon)
171202
win_x86/ - Windows x86 (32-bit)
172203
win_x64/ - Windows x64
173204
win_arm64/ - Windows ARM64

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,37 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
- macOS platform support
12+
- `darwin_x86_64` - macOS on Intel (x86_64)
13+
- `darwin_arm64` - macOS on Apple Silicon (ARM64)
14+
- Platform detection for macOS in `platforms/platform.h` using `__APPLE__` and `__aarch64__` macros
15+
- Mach-O assembly compatibility for both x86_64 and ARM64
16+
- Conditional assembly macros for ELF vs Mach-O object formats
17+
- Disabled CFI directives on macOS (different semantics than Linux)
18+
- Symbol name mangling with leading underscore for Mach-O
19+
- macOS build jobs in CI workflow (macos-15-intel and macos-latest runners)
20+
- macOS libraries included in release archives
21+
22+
### Changed
23+
- Assembly files (`switch_x86_64_gcc.S`, `switch_aarch64_gcc.S`) now support both Linux (ELF) and macOS (Mach-O)
24+
- `Makefile` detects Darwin and disables `-static` flag (not supported on macOS)
25+
- `tools/abiname.sh` improved to handle stale temp files on macOS
26+
- Release archives now contain 9 platform libraries (was 7)
27+
28+
## [1.0.1] - 2025-11-16
29+
30+
### Changed
31+
- Disabled automatic library commits to repository
32+
- Pre-built libraries now available exclusively via [GitHub Releases](https://github.com/stackless-dev/stackman/releases)
33+
- Added `lib/README.md` documenting deprecation timeline
34+
35+
### Deprecated
36+
- `lib/` directory in repository - will be removed in v2.0.0
37+
- Committing binary library files to git (causes bloat and merge conflicts)
38+
839
## [1.0.0] - 2025-11-16
940

1041
### Added

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ clean:
5050

5151
DEBUG = #-DDEBUG_DUMP
5252

53+
# macOS doesn't support static linking
54+
STATIC_FLAG := -static
55+
ifeq ($(shell uname -s),Darwin)
56+
STATIC_FLAG :=
57+
endif
58+
5359
.PHONY: test tests
5460

5561
test: tests
@@ -66,13 +72,13 @@ tests: bin/test_asm
6672
tests: LDLIBS := -lstackman
6773

6874
bin/test: tests/test.o $(LIB)/libstackman.a
69-
$(CC) $(LDFLAGS) -static -o $@ $< ${DEBUG} $(LDLIBS)
75+
$(CC) $(LDFLAGS) $(STATIC_FLAG) -o $@ $< ${DEBUG} $(LDLIBS)
7076

7177
bin/test_cc: tests/test_cc.o $(LIB)/libstackman.a
72-
$(CXX) $(LDFLAGS) -static -o $@ $< ${DEBUG} $(LDLIBS)
78+
$(CXX) $(LDFLAGS) $(STATIC_FLAG) -o $@ $< ${DEBUG} $(LDLIBS)
7379

7480
bin/test_static: tests/test_static.o
75-
$(CC) $(LDFLAGS) -static -o $@ $^ ${DEBUG}
81+
$(CC) $(LDFLAGS) $(STATIC_FLAG) -o $@ $^ ${DEBUG}
7682

7783
bin/test_asm: tests/test_asm.o tests/test_asm_s.o
78-
$(CC) $(LDFLAGS) -static -o $@ $^ ${DEBUG}
84+
$(CC) $(LDFLAGS) $(STATIC_FLAG) -o $@ $^ ${DEBUG}

README.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# stackman
44

5-
**Version 1.0.0**
5+
**Version 1.0.1**
66

77
Simple low-level stack manipulation API and implementation for common platforms
88

@@ -75,13 +75,18 @@ The current code is distilled out of other work, with the aim of simplifying and
7575
standardizing the api. A number of ABI specifications is supported, meaning architecture and
7676
calling convention, plus archive format:
7777

78-
- win_x86 (32 bits)
79-
- win_x64
80-
- win_arm64 (64 bit ARM)
81-
- sysv_i386 (linux)
82-
- sysv_amd64 (linux)
83-
- AAPCS (32 bit arm - linux)
84-
- AAPCS64 (64 bit arm - linux)
78+
- **Linux (System V ABI)**
79+
- sysv_i386 (32-bit x86)
80+
- sysv_amd64 (64-bit x86_64)
81+
- arm32 (32-bit ARM, AAPCS)
82+
- aarch64 (64-bit ARM, AAPCS64)
83+
- **macOS (Darwin)**
84+
- darwin_x86_64 (Intel)
85+
- darwin_arm64 (Apple Silicon)
86+
- **Windows**
87+
- win_x86 (32-bit)
88+
- win_x64 (64-bit)
89+
- win_arm64 (64-bit ARM)
8590

8691
All platforms are automatically built and tested by GitHub Actions CI on every commit.
8792

@@ -154,9 +159,10 @@ There are two basic ways to add the library to your project: Using a static libr
154159
155160
### static library (preferred)
156161
157-
- Link with the `libstackman.a` or `stackman.lib` libraries provided for your platform in the `lib/` directory.
158-
- Pre-built libraries are available for all supported platforms (8 ABIs total).
159-
- Libraries are automatically rebuilt by CI and committed to the repository for easy integration.
162+
- Download pre-built libraries from the [Releases page](https://github.com/kristjanvalur/stackman/releases) for your platform
163+
- Alternatively, link with the `libstackman.a` or `stackman.lib` libraries in the `lib/` directory if you've cloned the repository
164+
- Pre-built libraries are available for all supported platforms (9 ABIs total: 4 Linux, 2 macOS, 3 Windows)
165+
- Libraries are automatically rebuilt by CI and committed to the repository for easy integration
160166
161167
### inlined code
162168
@@ -170,9 +176,19 @@ over separate assembly language source.
170176
## Continuous Integration
171177
172178
The project uses GitHub Actions to automatically:
173-
- Build libraries for all 8 supported platforms (Linux: AMD64, i386, ARM32, ARM64; Windows: x86, x64, ARM, ARM64)
179+
- Build libraries for all 9 supported platforms (Linux: AMD64, i386, ARM32, ARM64; macOS: x86_64, ARM64; Windows: x86, x64, ARM64)
174180
- Run test suites on all platforms (using QEMU emulation for ARM on Linux)
175-
- Commit updated libraries back to the repository on successful builds
181+
- Commit updated libraries back to the repository on successful builds (for development branches)
182+
- Create GitHub Releases with downloadable libraries when version tags are pushed
183+
184+
### Releases
185+
186+
Tagged versions (e.g., `v1.0.0`) automatically trigger:
187+
- Build of all platforms
188+
- Creation of a GitHub Release
189+
- Upload of individual library files and a combined archive containing all platforms + headers
190+
191+
Download stable releases from: https://github.com/kristjanvalur/stackman/releases
176192
177193
See `.github/workflows/buildcommit.yml` for the complete CI configuration.
178194

stackman/platforms/platform.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@
5353
#if defined(__amd64__)
5454
#include "switch_x86_64_gcc.h" /* gcc on amd64 */
5555
#define _STACKMAN_PLATFORM x86_64_clang
56+
#ifdef __APPLE__
57+
#define _STACKMAN_ABI darwin_x86_64
58+
#else
5659
#define _STACKMAN_ABI sysv_amd64
60+
#endif
5761
#elif defined(__i386__)
5862
#include "switch_x86_gcc.h" /* gcc on X86 */
5963
#define _STACKMAN_PLATFORM x86_clang
@@ -65,16 +69,24 @@
6569
#elif defined(__ARM_ARCH_ISA_A64)
6670
#include "switch_aarch64_gcc.h" /* gcc using arm aarch64*/
6771
#define _STACKMAN_PLATFORM aarch64_clang
72+
#ifdef __APPLE__
73+
#define _STACKMAN_ABI darwin_arm64
74+
#else
6875
#define _STACKMAN_ABI aarch64
6976
#endif
77+
#endif
7078
#endif /* __clang__ */
7179

7280
#if defined(__GNUC__) && !defined(__clang__)
7381
/* real gcc */
7482
#if defined(__amd64__)
7583
#include "switch_x86_64_gcc.h" /* gcc on amd64 */
7684
#define _STACKMAN_PLATFORM x86_64_gcc
85+
#ifdef __APPLE__
86+
#define _STACKMAN_ABI darwin_x86_64
87+
#else
7788
#define _STACKMAN_ABI sysv_amd64
89+
#endif
7890
#elif defined(__i386__)
7991
#include "switch_x86_gcc.h" /* gcc on X86 */
8092
#define _STACKMAN_PLATFORM x86_gcc
@@ -86,8 +98,12 @@
8698
#elif defined(__ARM_ARCH_ISA_A64)
8799
#include "switch_aarch64_gcc.h" /* gcc using arm aarch64*/
88100
#define _STACKMAN_PLATFORM aarch64_gcc
101+
#ifdef __APPLE__
102+
#define _STACKMAN_ABI darwin_arm64
103+
#else
89104
#define _STACKMAN_ABI aarch64
90105
#endif
106+
#endif
91107
#endif /* __GNUC__ */
92108

93109
/* set STACKMAN_PLATFORM and optionally report */

0 commit comments

Comments
 (0)