Skip to content

macOS build compatibility for client tools#196

Open
wkoszek wants to merge 1 commit into
SchedMD:masterfrom
wkoszek:macos-build-compat
Open

macOS build compatibility for client tools#196
wkoszek wants to merge 1 commit into
SchedMD:masterfrom
wkoszek:macos-build-compat

Conversation

@wkoszek
Copy link
Copy Markdown

@wkoszek wkoszek commented Mar 23, 2026

Summary

I'm making an exploratory change here -- with the changes in the PR, I can successfully build slurm binaries. The idea here is that my main Macbook would be a submitter of jobs to the cluster. The changes are mostly around non-standard functions that only exist in Linux. I wonder if there'd be interest in moving to more standard APIs or actually accepting some of this compatibility code? If so, I'd be happy to look into changes one by one (so far: pipe2/accept4 seem like they could just work, also SOL_TCP -> IPPROTO_TCP would be no-op change with more compatibility too).

Description

Enable building Slurm client tools (squeue, sbatch, srun, sinfo, salloc, sacct, scancel, scontrol) on macOS/Darwin without munge.

Tested on macOS 15 (Sequoia) / Apple Silicon (aarch64) with:

mkdir b && cd b
CPPFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib" \
  ../configure --with-munge=no
make

Changes

  • src/common/xsched.h: add cpu_set_t typedef and CPU_SET* macros for macOS
  • src/common/xsched.c: stub sched_setaffinity/getaffinity and CPU_COUNT_S for macOS
  • src/common/macros.h: add macOS shims for pipe2, accept4, fexecve, setresuid/setresgid, SOCK_CLOEXEC, POSIX real-time timers (timer_create/timer_settime/timer_delete), and struct itimerspec
  • src/common/net.c: define SOL_TCP as IPPROTO_TCP; guard cr_pid (FreeBSD-only field in struct xucred) for macOS
  • src/common/slurm_resolv.c: include arpa/nameser_compat.h for C_IN/T_SRV on macOS
  • src/plugins/data_parser/v0.0.{42-45}/parsers.c: define SIGRTMAX fallback (no RT signals on macOS)
  • auxdir/slurm.m4: fix -Wl,-rpath= to -Wl,-rpath, for Apple ld64
  • configure.ac: add DARWIN automake conditional
  • make_ref.include: use clang .incbin assembler for binary embedding on macOS instead of GNU ld --format=binary
  • src/slurmd/slurmd/Makefile.am: guard -Wl,--no-as-needed (GNU ld only)
  • src/salloc/signals.c, src/srun/signals.c: replace eventfd() with pipe pair on macOS
  • src/srun/srun_job.c, cgroup plugin headers: guard <sys/eventfd.h> include on macOS

Test plan

  • Build succeeds on macOS with --with-munge=no
  • All client binaries link and load (squeue --version, etc.)
  • Existing Linux CI passes unaffected

🤖 Generated with Claude Code

@wkoszek wkoszek force-pushed the macos-build-compat branch from 518c037 to 979c7c7 Compare March 23, 2026 06:34
Enable building Slurm client tools (squeue, sbatch, srun, sinfo,
salloc, sacct, scancel, scontrol) on macOS/Darwin without munge.

Changes:
- xsched.h: add cpu_set_t typedef and CPU_SET* macros for macOS
- xsched.c: stub sched_setaffinity/getaffinity and CPU_COUNT_S for macOS
- macros.h: add macOS shims for pipe2, accept4, fexecve, setresuid/gid,
  SOCK_CLOEXEC, POSIX real-time timers (timer_create/settime/delete),
  and struct itimerspec
- net.c: define SOL_TCP as IPPROTO_TCP; guard cr_pid (FreeBSD-only
  field in struct xucred) for macOS
- slurm_resolv.c: include arpa/nameser_compat.h for C_IN/T_SRV on macOS
- data_parser/*/parsers.c: define SIGRTMAX fallback (no RT signals on macOS)
- auxdir/slurm.m4: fix -Wl,-rpath= to -Wl,-rpath, for Apple ld64
- configure.ac: add DARWIN automake conditional
- configure: regenerated
- make_ref.include: use clang .incbin asm for binary embedding on macOS
  instead of GNU ld --format=binary
- slurmd/Makefile.am: guard -Wl,--no-as-needed (GNU ld only)
- salloc/signals.c, srun/signals.c: replace eventfd() with pipe pair on macOS
- srun/srun_job.c, cgroup files: guard sys/eventfd.h include on macOS

Build with:
  mkdir b && cd b
  CPPFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib" \
    ../configure --with-munge=no
  make

Signed-off-by: Adam Koszek <adam@koszek.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@wkoszek wkoszek force-pushed the macos-build-compat branch from 979c7c7 to 7f6146b Compare March 23, 2026 06:44
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.

1 participant