-
Notifications
You must be signed in to change notification settings - Fork 1
✨ feat(ci): Add macOS build support in GitHub Actions workflow #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b7df79f
b2d7a15
3f047cc
29081fc
1f84038
4936494
6226768
e01ec5b
263989f
376de6e
0d2f167
45e01a3
9476043
d7a1ed0
da57067
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,7 +20,7 @@ jobs: | |||||
| name: Check for GitLeaks | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - {uses: actions/checkout@v4, with: {fetch-depth: 0}} | ||||||
| - {uses: actions/checkout@v6, with: {fetch-depth: 0}} | ||||||
| - uses: gacts/gitleaks@v1 | ||||||
|
|
||||||
| build: | ||||||
|
|
@@ -32,6 +32,23 @@ jobs: | |||||
| - run: make | ||||||
| - run: make test | ||||||
|
|
||||||
| build-macos: | ||||||
| name: Build for macOS (${{ matrix.arch }}) | ||||||
| runs-on: ${{ matrix.runner }} | ||||||
| strategy: | ||||||
| fail-fast: false | ||||||
| matrix: | ||||||
| include: | ||||||
| - {arch: x86_64, runner: macos-13} # Intel runner | ||||||
| - {arch: arm64, runner: macos-14} # Apple Silicon runner | ||||||
| steps: | ||||||
| - uses: actions/checkout@v6 | ||||||
| - run: make CC=clang C_LDFLAGS_EXTRA="-arch ${{ matrix.arch }}" | ||||||
|
||||||
| - run: make CC=clang C_LDFLAGS_EXTRA="-arch ${{ matrix.arch }}" | |
| - run: make CC=clang CFLAGS="-arch ${{ matrix.arch }}" C_LDFLAGS_EXTRA="-arch ${{ matrix.arch }}" |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The macOS build job doesn't run the test suite (make test), unlike the Linux build job which runs both make and make test. To ensure consistent quality across platforms, consider adding - run: make test after the build step to verify the binaries work correctly on macOS.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,12 +7,21 @@ C_SIZE_FLAGS = -Os -ffunction-sections -fdata-sections -fmerge-all-constants | |||||
| C_SECURITY_FLAGS = -fstack-protector-strong -D_FORTIFY_SOURCE=2 | ||||||
| C_WARNING_FLAGS = -Wall -Wextra -Werror -Wpedantic -Wformat=2 -Wformat-security -Wnull-dereference \ | ||||||
| -Wstack-protector -Wstrict-overflow=3 -Wwrite-strings -Wconversion -Wshadow | ||||||
| C_STRIP_FLAGS = -s -fno-asynchronous-unwind-tables -fno-ident -Wl,--build-id=none -Wl,--hash-style=gnu | ||||||
| C_LDFLAGS = -static -Wl,--gc-sections -Wl,--as-needed -Wl,-O1 -Wl,--strip-all | ||||||
| CFLAGS = -std=c99 -D_POSIX_C_SOURCE=200809L | ||||||
| CFLAGS += $(C_SIZE_FLAGS) $(C_SECURITY_FLAGS) $(C_WARNING_FLAGS) $(C_STRIP_FLAGS) $(C_LDFLAGS) | ||||||
| STRIP_FLAGS = -s -R .comment -R .gnu.version -R .note -R .note.ABI-tag -R .note.gnu.build-id -R .gnu.hash \ | ||||||
| -R .eh_frame -R .eh_frame_hdr | ||||||
| C_STRIP_FLAGS = -fno-asynchronous-unwind-tables -fno-ident | ||||||
| C_LDFLAGS_EXTRA ?= -static | ||||||
| C_LDFLAGS = -Wl,--gc-sections -Wl,--as-needed -Wl,-O1 \ | ||||||
| -Wl,--build-id=none -Wl,--hash-style=gnu $(C_LDFLAGS_EXTRA) | ||||||
| STRIP_FLAGS = -s -R .comment -R .gnu.version -R .note -R .note.ABI-tag \ | ||||||
| -R .note.gnu.build-id -R .gnu.hash -R .eh_frame -R .eh_frame_hdr | ||||||
|
|
||||||
| ifeq ($(shell uname -s),Darwin) # macOS linker flags (https://github.com/tarampampam/microcheck/issues/11) | ||||||
| C_LDFLAGS = -Wl,-dead_strip | ||||||
|
||||||
| C_LDFLAGS = -Wl,-dead_strip | |
| C_LDFLAGS = -Wl,-dead_strip $(C_LDFLAGS_EXTRA) |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -60,7 +60,8 @@ So, think of this as an alternative to: | |||||||
|
|
||||||||
| * **Statically linked**: Works in minimal containers (e.g., `scratch`, `distroless`) | ||||||||
| * **Pretty fast**: Written in pure `C`, compiled with `musl` | ||||||||
| * **Multi-arch and cross-compiled** (x86_64, ARM, etc.) | ||||||||
| * **Multi-arch and cross-compiled** (x86_64, ARM, etc.), even for macOS you may find precompiled binaries in | ||||||||
| the releases | ||||||||
|
Comment on lines
+63
to
+64
|
||||||||
| * **Multi-arch and cross-compiled** (x86_64, ARM, etc.), even for macOS you may find precompiled binaries in | |
| the releases | |
| * **Multi-arch and cross-compiled** (x86_64, ARM, etc.); macOS precompiled binaries are available in the releases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as in tests.yml: The
-archflag is being passed only as a linker flag (C_LDFLAGS_EXTRA), but it also needs to be passed during the compilation phase. Additionally, the macOS-specificC_LDFLAGSoverride on line 18 of the Makefile doesn't include$(C_LDFLAGS_EXTRA), so the linker won't receive the-archflag either.