Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions .github/workflows/buildcommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,34 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ env.abiname }}
path: lib/${{ env.abiname }}/libstackman.a
path: lib/${{ env.abiname }}/libstackman.a

build-macos:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-15-intel, macos-latest]
include:
- os: macos-15-intel
abi: darwin_x86_64
- os: macos-latest
abi: darwin_arm64

steps:
- uses: actions/checkout@v4

- name: Build library
run: make all

- name: Run tests
run: make test

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.abi }}
path: lib/${{ matrix.abi }}/libstackman.a

build-windows:
runs-on: windows-latest
Expand Down Expand Up @@ -89,7 +116,7 @@ jobs:

commit-artifacts:
runs-on: ubuntu-latest
needs: [build-linux-gnu, build-windows]
needs: [build-linux-gnu, build-macos, build-windows]
if: false # Disabled - libraries no longer committed to repository
steps:
- uses: actions/checkout@v4
Expand All @@ -108,7 +135,7 @@ jobs:

create-release:
runs-on: ubuntu-latest
needs: [build-linux-gnu, build-windows]
needs: [build-linux-gnu, build-macos, build-windows]
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
Expand All @@ -129,6 +156,8 @@ jobs:
cp -r artifacts/sysv_i386 release/lib/
cp -r artifacts/arm32 release/lib/
cp -r artifacts/aarch64 release/lib/
cp -r artifacts/darwin_x86_64 release/lib/
cp -r artifacts/darwin_arm64 release/lib/
cp -r artifacts/win_x86 release/lib/
cp -r artifacts/win_x64 release/lib/
cp -r artifacts/win_arm64 release/lib/
Expand Down Expand Up @@ -168,6 +197,8 @@ jobs:
sysv_i386/ - Linux x86 (32-bit)
arm32/ - Linux ARM (32-bit, AAPCS)
aarch64/ - Linux ARM64 (AAPCS64)
darwin_x86_64/ - macOS x86_64 (Intel)
darwin_arm64/ - macOS ARM64 (Apple Silicon)
win_x86/ - Windows x86 (32-bit)
win_x64/ - Windows x64
win_arm64/ - Windows ARM64
Expand Down
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,37 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added
- macOS platform support
- `darwin_x86_64` - macOS on Intel (x86_64)
- `darwin_arm64` - macOS on Apple Silicon (ARM64)
- Platform detection for macOS in `platforms/platform.h` using `__APPLE__` and `__aarch64__` macros
- Mach-O assembly compatibility for both x86_64 and ARM64
- Conditional assembly macros for ELF vs Mach-O object formats
- Disabled CFI directives on macOS (different semantics than Linux)
- Symbol name mangling with leading underscore for Mach-O
- macOS build jobs in CI workflow (macos-15-intel and macos-latest runners)
- macOS libraries included in release archives

### Changed
- Assembly files (`switch_x86_64_gcc.S`, `switch_aarch64_gcc.S`) now support both Linux (ELF) and macOS (Mach-O)
- `Makefile` detects Darwin and disables `-static` flag (not supported on macOS)
- `tools/abiname.sh` improved to handle stale temp files on macOS
- Release archives now contain 9 platform libraries (was 7)

## [1.0.1] - 2025-11-16

### Changed
- Disabled automatic library commits to repository
- Pre-built libraries now available exclusively via [GitHub Releases](https://github.com/stackless-dev/stackman/releases)
- Added `lib/README.md` documenting deprecation timeline

### Deprecated
- `lib/` directory in repository - will be removed in v2.0.0
- Committing binary library files to git (causes bloat and merge conflicts)

## [1.0.0] - 2025-11-16

### Added
Expand Down
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ clean:

DEBUG = #-DDEBUG_DUMP

# macOS doesn't support static linking
STATIC_FLAG := -static
ifeq ($(shell uname -s),Darwin)
STATIC_FLAG :=
endif

.PHONY: test tests

test: tests
Expand All @@ -66,13 +72,13 @@ tests: bin/test_asm
tests: LDLIBS := -lstackman

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

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

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

bin/test_asm: tests/test_asm.o tests/test_asm_s.o
$(CC) $(LDFLAGS) -static -o $@ $^ ${DEBUG}
$(CC) $(LDFLAGS) $(STATIC_FLAG) -o $@ $^ ${DEBUG}
42 changes: 29 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# stackman

**Version 1.0.0**
**Version 1.0.1**

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

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

- win_x86 (32 bits)
- win_x64
- win_arm64 (64 bit ARM)
- sysv_i386 (linux)
- sysv_amd64 (linux)
- AAPCS (32 bit arm - linux)
- AAPCS64 (64 bit arm - linux)
- **Linux (System V ABI)**
- sysv_i386 (32-bit x86)
- sysv_amd64 (64-bit x86_64)
- arm32 (32-bit ARM, AAPCS)
- aarch64 (64-bit ARM, AAPCS64)
- **macOS (Darwin)**
- darwin_x86_64 (Intel)
- darwin_arm64 (Apple Silicon)
- **Windows**
- win_x86 (32-bit)
- win_x64 (64-bit)
- win_arm64 (64-bit ARM)

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

Expand Down Expand Up @@ -154,9 +159,10 @@ There are two basic ways to add the library to your project: Using a static libr

### static library (preferred)

- Link with the `libstackman.a` or `stackman.lib` libraries provided for your platform in the `lib/` directory.
- Pre-built libraries are available for all supported platforms (8 ABIs total).
- Libraries are automatically rebuilt by CI and committed to the repository for easy integration.
- Download pre-built libraries from the [Releases page](https://github.com/kristjanvalur/stackman/releases) for your platform
- Alternatively, link with the `libstackman.a` or `stackman.lib` libraries in the `lib/` directory if you've cloned the repository
- Pre-built libraries are available for all supported platforms (9 ABIs total: 4 Linux, 2 macOS, 3 Windows)
- Libraries are automatically rebuilt by CI and committed to the repository for easy integration

### inlined code

Expand All @@ -170,9 +176,19 @@ over separate assembly language source.
## Continuous Integration

The project uses GitHub Actions to automatically:
- Build libraries for all 8 supported platforms (Linux: AMD64, i386, ARM32, ARM64; Windows: x86, x64, ARM, ARM64)
- Build libraries for all 9 supported platforms (Linux: AMD64, i386, ARM32, ARM64; macOS: x86_64, ARM64; Windows: x86, x64, ARM64)
- Run test suites on all platforms (using QEMU emulation for ARM on Linux)
- Commit updated libraries back to the repository on successful builds
- Commit updated libraries back to the repository on successful builds (for development branches)
- Create GitHub Releases with downloadable libraries when version tags are pushed

### Releases

Tagged versions (e.g., `v1.0.0`) automatically trigger:
- Build of all platforms
- Creation of a GitHub Release
- Upload of individual library files and a combined archive containing all platforms + headers

Download stable releases from: https://github.com/kristjanvalur/stackman/releases

See `.github/workflows/buildcommit.yml` for the complete CI configuration.

Expand Down
16 changes: 16 additions & 0 deletions stackman/platforms/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@
#if defined(__amd64__)
#include "switch_x86_64_gcc.h" /* gcc on amd64 */
#define _STACKMAN_PLATFORM x86_64_clang
#ifdef __APPLE__
#define _STACKMAN_ABI darwin_x86_64
#else
#define _STACKMAN_ABI sysv_amd64
#endif
#elif defined(__i386__)
#include "switch_x86_gcc.h" /* gcc on X86 */
#define _STACKMAN_PLATFORM x86_clang
Expand All @@ -65,16 +69,24 @@
#elif defined(__ARM_ARCH_ISA_A64)
#include "switch_aarch64_gcc.h" /* gcc using arm aarch64*/
#define _STACKMAN_PLATFORM aarch64_clang
#ifdef __APPLE__
#define _STACKMAN_ABI darwin_arm64
#else
#define _STACKMAN_ABI aarch64
#endif
#endif
#endif /* __clang__ */

#if defined(__GNUC__) && !defined(__clang__)
/* real gcc */
#if defined(__amd64__)
#include "switch_x86_64_gcc.h" /* gcc on amd64 */
#define _STACKMAN_PLATFORM x86_64_gcc
#ifdef __APPLE__
#define _STACKMAN_ABI darwin_x86_64
#else
#define _STACKMAN_ABI sysv_amd64
#endif
#elif defined(__i386__)
#include "switch_x86_gcc.h" /* gcc on X86 */
#define _STACKMAN_PLATFORM x86_gcc
Expand All @@ -86,8 +98,12 @@
#elif defined(__ARM_ARCH_ISA_A64)
#include "switch_aarch64_gcc.h" /* gcc using arm aarch64*/
#define _STACKMAN_PLATFORM aarch64_gcc
#ifdef __APPLE__
#define _STACKMAN_ABI darwin_arm64
#else
#define _STACKMAN_ABI aarch64
#endif
#endif
#endif /* __GNUC__ */

/* set STACKMAN_PLATFORM and optionally report */
Expand Down
Loading