Skip to content

Commit 030059b

Browse files
Merge pull request #11 from kristjanvalur/master
Update pipeline
2 parents cbf4e14 + 53c598c commit 030059b

File tree

19 files changed

+196
-28
lines changed

19 files changed

+196
-28
lines changed

.github/copilot-instructions.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Copilot Instructions for stackman
2+
3+
## Overview
4+
Low-level C library for stack manipulation (continuations/co-routines). ~600 lines of C + assembly. Zero dependencies. Platforms: Linux (x86/x64/ARM), Windows (x86/x64/ARM). Toolchains: GCC, Clang, MSVC.
5+
6+
## Build Commands (FAST: <1 second)
7+
8+
**Always run in order:**
9+
```bash
10+
make clean # Clean build artifacts
11+
make all # Build library (0.1s) → lib/[ABI]/libstackman.a
12+
make test # Build + run 4 test suites (0.7s)
13+
make abiname # Print platform ABI (e.g., sysv_amd64)
14+
```
15+
16+
**Success output:** `*** All test suites passed ***`
17+
18+
**Cross-compile x86:** `make PLATFORMFLAGS=-m32 test`
19+
**Cross-compile ARM:** `make PLATFORM_PREFIX=arm-linux-gnueabi- EMULATOR=qemu-arm test`
20+
**Windows:** `msbuild vs2022\stackman.sln /p:Platform=x64` then `vs2022\x64\Debug\test.exe`
21+
22+
## Critical Build Notes
23+
24+
1. **Intel CET:** `-fcf-protection=none` flag REQUIRED (auto-added by disable_cet script). Stack switching incompatible with Shadow Stack.
25+
2. **Libraries ARE Committed:** `lib/**/*.a` and `lib/**/*.lib` are version controlled (unlike typical projects). CI rebuilds and commits them.
26+
3. **Expected Warning:** Linker warning "missing .note.GNU-stack section" in test_asm is NORMAL - ignore it.
27+
4. **Artifacts:** `*.o`, `bin/`, `tmp/` NOT committed. Libraries in `lib/[ABI]/` ARE committed.
28+
5. **Incremental OK:** After code changes, just `make test`. Only clean when switching platforms.
29+
30+
## Project Structure
31+
32+
**Key Directories:**
33+
- `stackman/` - Main source: `stackman.h` (API), `stackman_switch.h`, `stackman_impl.h`, `platforms/` (15+ platform files)
34+
- `tests/` - 4 test files: `test.c` (6 tests), `test_cc.cc`, `test_static.c`, `test_asm.c/.S`
35+
- `lib/[ABI]/` - Pre-built libraries (COMMITTED to git)
36+
- `vs2017/`, `vs2019/`, `vs2022/` - Visual Studio projects
37+
- `tools/` - `abiname.sh`, `strip-lib.py`
38+
39+
**Core API (2 functions only):**
40+
```c
41+
void *stackman_switch(stackman_cb_t callback, void *context); // Main stack switch
42+
void *stackman_call(stackman_cb_t callback, void *context, void *stack); // Call with different stack
43+
```
44+
45+
**Architecture:** `platforms/platform.h` detects OS/arch/compiler → includes appropriate `switch_[abi]_[compiler].h/S/asm`
46+
47+
## CI Validation (.github/workflows/buildcommit.yml)
48+
49+
**Triggers:** Push to master/dev, PRs to master
50+
51+
**Jobs:**
52+
1. **build-linux-gnu** (AMD64, i386, arm, aarch64) - installs cross-tools → `make all` → `make test` (qemu for ARM)
53+
2. **build-windows** (x86, x64, arm, arm64) - MSBuild → strip-lib.py → rebuild (MUST rebuild after strip!)
54+
3. **commit-artifacts** (push only) - downloads artifacts → commits libs → pushes
55+
56+
**Local validation:**
57+
```bash
58+
make clean && make test # Test native platform
59+
git status # Verify no bin/, tmp/, *.o tracked
60+
```
61+
62+
## Key Patterns & Workarounds
63+
64+
**Making Changes:**
65+
- Platform code: edit `stackman/platforms/switch_*.h` or `.S` - reference `switch_template.h`
66+
- Always run `make test` after changes (fast: 0.7s)
67+
- Test on actual hardware if modifying assembly (arch-specific!)
68+
69+
**Known Issues/Workarounds:**
70+
- **CET:** `-fcf-protection=none` REQUIRED (auto-added by disable_cet script)
71+
- **Inline asm:** May be inlined by optimizer → use separate .S files or volatile pointer (see stackman_impl.h)
72+
- **Stack align:** Use `STACKMAN_SP_ALIGN` macro
73+
74+
**Testing:** 4 test executables, 6 tests each (assertions fail hard). Success: "test_XX ok" + "*** All test suites passed ***"
75+
76+
**Include patterns:**
77+
- User code: `#include "stackman.h"`
78+
- Library impl: `#include "stackman_impl.h"` (once)
79+
80+
## Configuration Files
81+
- **Build:** Makefile (Linux), vs2022/*.vcxproj (Windows)
82+
- **CI:** .github/workflows/buildcommit.yml
83+
- **Linting:** None configured
84+
- **Testing:** `make test` target
85+
- **.gitignore:** Excludes *.o, bin/, tmp/ BUT includes lib/**/*.a, lib/**/*.lib
86+
87+
## Development Tips
88+
89+
1. **Trust these instructions first** - search only if info incomplete/incorrect
90+
2. **Build is FAST** - rebuild freely (clean+test <1s)
91+
3. **Test after every change** - `make test` is fast and comprehensive
92+
4. **Cross-compilation optional** - CI validates all platforms, native x64 sufficient for most changes
93+
5. **Binary files in git** - lib/**/*.a, lib/**/*.lib ARE tracked (expect binary diffs)
94+
6. **Zero dependencies** - don't add any
95+
7. **Minimal changes** - stable library, surgical edits only
96+
8. **Low-level code** - assembly is platform-specific, test on actual hardware

.github/workflows/buildcommit.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,15 @@ jobs:
5555
build-windows:
5656
runs-on: windows-latest
5757
strategy:
58-
fail-fast: true
5958
matrix:
60-
platform: [x86, x64, arm, arm64]
59+
platform: [x86, x64, arm64]
6160
include:
6261
- platform: x86
6362
folder: Win32
6463
native: yes
6564
- platform: x64
6665
folder: x64
6766
native: yes
68-
- platform: arm
69-
folder: arm
7067
- platform: arm64
7168
folder: arm64
7269

CHANGELOG.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.0.0] - 2025-11-16
9+
10+
### Added
11+
- Version macros in `stackman.h`: `STACKMAN_VERSION_MAJOR`, `STACKMAN_VERSION_MINOR`, `STACKMAN_VERSION_PATCH`, `STACKMAN_VERSION`, `STACKMAN_VERSION_NUMBER`
12+
- Automated release workflow for tagged versions
13+
14+
### Changed
15+
- Updated GitHub Actions to v4 (from v2)
16+
- README updated with complete platform list, CI information, and release documentation
17+
18+
### Removed
19+
- **BREAKING**: Dropped Windows ARM32 (win_arm) support
20+
- Microsoft Windows SDK 10.0.26100.0+ no longer supports 32-bit ARM development
21+
- Last SDK version supporting ARM32 was Windows SDK 10.0.22621 (Windows 11 SDK, version 22H2)
22+
- ARM32 Windows devices (Windows RT) are obsolete
23+
- ARM64 Windows remains fully supported
24+
25+
### Fixed
26+
- Fixed typos in documentation and source files
27+
- Corrected "callee-stored" → "callee-saved" terminology
28+
29+
## [0.1] - 2020-05-18
30+
31+
### Added
32+
- Core stack manipulation API: `stackman_switch()` and `stackman_call()`
33+
- Support for 8 platforms:
34+
- Linux: sysv_amd64, sysv_i386, arm32 (AAPCS), aarch64 (AAPCS64)
35+
- Windows: win_x86, win_x64, win_arm (32-bit ARM), win_arm64
36+
- Compiler support: GCC, Clang, MSVC (VS2017, VS2019, VS2022)
37+
- Pre-built libraries for all supported platforms
38+
- Inline assembly and separate assembly file options
39+
- Cross-compilation support for Linux (x86, ARM32, ARM64)
40+
- QEMU-based testing for ARM platforms in CI
41+
- Comprehensive test suite (test.c, test_cc.cc, test_static.c, test_asm.c)
42+
- GitHub Actions CI for automated building and testing
43+
- Visual Studio project files (VS2017, VS2019, VS2022)
44+
45+
[1.0.0]: https://github.com/stackless-dev/stackman/releases/tag/v1.0.0
46+
[0.1]: https://github.com/stackless-dev/stackman/releases/tag/v0.1

README.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
# stackman
44

5+
**Version 1.0.0**
6+
57
Simple low-level stack manipulation API and implementation for common platforms
68

79
## Purpose
@@ -75,17 +77,19 @@ calling convention, plus archive format:
7577

7678
- win_x86 (32 bits)
7779
- win_x64
78-
- win_ARM64 (experimental)
80+
- win_arm64 (64 bit ARM)
7981
- sysv_i386 (linux)
8082
- sysv_amd64 (linux)
81-
- AAPCS (32 bit arm)
82-
- AAPCS64 (64 bit arm)
83+
- AAPCS (32 bit arm - linux)
84+
- AAPCS64 (64 bit arm - linux)
85+
86+
All platforms are automatically built and tested by GitHub Actions CI on every commit.
8387

8488
### Supported toolchains:
8589

8690
- Gnu C
8791
- clang
88-
- Microsoft Visual Studio
92+
- Microsoft Visual Studio (VS2017, VS2019, VS2022)
8993

9094
Other platforms can be easily adapted from both existing implementations for other
9195
projects as well as from example code provided.
@@ -150,21 +154,33 @@ There are two basic ways to add the library to your project: Using a static libr
150154
151155
### static library (preferred)
152156
153-
- You link with the `libstackman.a` or `stackman.lib` libraries provided for your platform.
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.
154160
155161
### inlined code
156162
157-
- You inlude `stackman_impl.h` in one of your .c source files to provide inline assembly.
158-
- You include `stackman_impl.h` in an assembly (.S) file in your project to include assembly code.
159-
- (windows) You include `stackman_s.asm` in an assemby (.asm) file in your project.
160-
In the case of inlined code, it can be specified to prefer in-line assembly and static linkage
161-
over separate assembly language source.
163+
- Include `stackman_impl.h` in one of your .c source files to provide inline assembly.
164+
- Include `stackman_impl.h` in an assembly (.S) file in your project to include assembly code.
165+
- (Windows) Include `stackman_s.asm` in an assembly (.asm) file in your project.
166+
167+
In the case of inlined code, it can be specified to prefer in-line assembly and static linkage
168+
over separate assembly language source.
169+
170+
## Continuous Integration
171+
172+
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)
174+
- Run test suites on all platforms (using QEMU emulation for ARM on Linux)
175+
- Commit updated libraries back to the repository on successful builds
176+
177+
See `.github/workflows/buildcommit.yml` for the complete CI configuration.
162178
163179
## Development
164180
165181
### Adding new platforms
166182
167-
1. Modify `platform.h` to identif the platform environment. Define an ABI name and
183+
1. Modify `platform.h` to identify the platform environment. Define an ABI name and
168184
include custom header files.
169185
2. Use the `switch_template.h` to help build a `switch_ABI.h` file for your ABI.
170186
3. Provide an assembler version, `switch_ABI.S` by compiling the `gen_asm.c` file for your platform.

lib/aarch64/libstackman.a

0 Bytes
Binary file not shown.

lib/arm32/libstackman.a

24 Bytes
Binary file not shown.

lib/sysv_amd64/libstackman.a

0 Bytes
Binary file not shown.

lib/sysv_i386/libstackman.a

0 Bytes
Binary file not shown.

lib/win_arm/stackman.lib

0 Bytes
Binary file not shown.

lib/win_arm64/stackman.lib

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)