Skip to content

Ported build system and source to macOS arm64#10

Open
peturingi wants to merge 1 commit intoopenwall:mainfrom
peturingi:main
Open

Ported build system and source to macOS arm64#10
peturingi wants to merge 1 commit intoopenwall:mainfrom
peturingi:main

Conversation

@peturingi
Copy link
Copy Markdown

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:

  • -fopenmp is not supported by Apple Clang. Used -Xpreprocessor -fopenmp with Homebrew libomp headers and library instead.
  • -lrt does not exist on macOS. librt provides clock_gettime() and POSIX timers on Linux; macOS includes these in libSystem.
  • -s (strip at link time) is obsolete on macOS ld.

Should you choose to accept this PR, please mind documenting the dependency on libomp for those who want to build on macOS.

  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.
Copilot AI review requested due to automatic review settings March 23, 2026 16:03
# SUCH DAMAGE.

CC = gcc
CC = cc
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: I did not guard this. Problem?

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 libomp for 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants