Ported build system and source to macOS arm64#10
Open
peturingi wants to merge 1 commit intoopenwall:mainfrom
Open
Ported build system and source to macOS arm64#10peturingi wants to merge 1 commit intoopenwall:mainfrom
peturingi wants to merge 1 commit intoopenwall:mainfrom
Conversation
The upstream Makefile assumes Linux (GCC, -lrt, -fopenmp). On macOS
with Apple Clang, three issues prevent compilation:
1. -fopenmp is not supported by Apple Clang. Use -Xpreprocessor -fopenmp
with Homebrew libomp headers and library instead.
2. -lrt does not exist on macOS. librt provides clock_gettime() and
POSIX timers on Linux; macOS includes these in libSystem.
3. -s (strip at link time) is obsolete on macOS ld.
The Makefile now detects Darwin via uname -s and sets compiler/linker
flags accordingly. Linux flags are unchanged.
Additionally, userom.c calls sched_setscheduler() which does not exist
on macOS. Guarded with #ifndef __APPLE__ since it is only a non-essential
SCHED_RR optimization for benchmarking as root.
peturingi
commented
Mar 23, 2026
| # SUCH DAMAGE. | ||
|
|
||
| CC = gcc | ||
| CC = cc |
Author
There was a problem hiding this comment.
NOTE: I did not guard this. Problem?
There was a problem hiding this comment.
Pull request overview
Ports the build and benchmarking utilities to support macOS (Darwin) on arm64 by adjusting compiler/linker flags and guarding Linux-only scheduling optimizations.
Changes:
- Add a macOS-specific Makefile branch that uses Homebrew
libompfor OpenMP and removes Linux-only linker flags. - Guard the
sched_setscheduler()SCHED_RR benchmarking optimization to avoid building/calling it on Apple platforms.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
Makefile |
Adds Darwin detection and uses Homebrew libomp OpenMP flags; updates default compiler selection. |
userom.c |
Wraps sched_setscheduler() usage with #ifndef __APPLE__ to compile on macOS. |
💡 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.
Ported to macOS by solving the following problems:
Makefile assumed Linux (GCC, -lrt, -fopenmp). Modified to detects macOS (Darwin kernel) via uname -s then set compiler/linker flags accordingly. Linux flags are unchanged.
sched_setscheduler() does not exist on macOS. Guarded with
#ifndef __APPLE__since it is only a non-essential SCHED_RR optimization for benchmarking as root.Apple Clang has three issues that prevent compilation:
Should you choose to accept this PR, please mind documenting the dependency on libomp for those who want to build on macOS.