Skip to content

Only force -arch x86_64 on Intel macOS - #694

Merged
joellembatchou merged 1 commit into
rgcgithub:masterfrom
BenjaminDEMAILLE:macos-arm64-arch-flag
Sep 8, 2026
Merged

joellembatchou merged 1 commit into
rgcgithub:masterfrom
BenjaminDEMAILLE:macos-arm64-arch-flag

Conversation

@BenjaminDEMAILLE

@BenjaminDEMAILLE BenjaminDEMAILLE commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #695

Problem

The external_libs Makefiles append -arch x86_64 on any Darwin host:

UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
 CXXFLAGS += -arch x86_64
endif

On Apple Silicon the helper libraries are therefore cross-compiled for x86_64 while src/ is compiled for arm64, and the final link fails:

ld: warning: ignoring file external_libs/qf/qf.a, building for macOS-arm64
    but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
  "_qf", referenced from:
      get_davies_pv(double const&, Eigen::Ref<...>, bool const&) in SKAT.cpp.o
ld: symbol(s) not found for architecture arm64

This affects mvtnorm, pgenlib, qf, quadpack and remeta, so an arm64 macOS build of v4.1.3 cannot complete without editing the Makefiles.

Fix

Guard the flag with uname -m. Intel macOS builds are unchanged; arm64 builds now keep the host architecture. The flag is redundant on Intel too (the compiler already targets the host), but keeping it preserves the existing behaviour for anyone relying on it.

Testing

macOS 26.6 on arm64 (Apple Silicon), Homebrew clang, gfortran from GCC 15, BGEN v1.1.7:

BGEN_PATH=... HAS_BOOST_IOSTREAM=1 cmake -S . -B build && cmake --build build
file build/regenie
  build/regenie: Mach-O 64-bit executable arm64
build/regenie --version
  v4.1.3.gz

Step 1 on the bundled example data completes normally:

regenie --step 1 --bed example/example --covarFile example/covariates.txt \
        --phenoFile example/phenotype_bin.txt --bsize 100 --bt --lowmem --out fit
  0.99  : Rsq = 0.448642, MSE = 0.0981588, -logLik/N = 0.318482
  List of blup files written to: [fit_pred.list]

This came up while packaging regenie for Homebrew, where builds run natively on arm64 runners.

🤖 Generated with Claude Code

The external_libs Makefiles append `-arch x86_64` on any Darwin host. On
Apple Silicon this cross-compiles the helper libraries for the wrong
architecture, and the final link fails:

    ld: warning: ignoring file external_libs/qf/qf.a, building for
        macOS-arm64 but attempting to link with file built for macOS-x86_64
    Undefined symbols for architecture arm64: "_qf", referenced from:
        get_davies_pv(...) in SKAT.cpp.o

Guard the flag with `uname -m` so native arm64 builds keep the host
architecture, while Intel macOS builds are unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@joellembatchou
joellembatchou merged commit 7c2b153 into rgcgithub:master Sep 8, 2026
1 check passed
@joellembatchou

Copy link
Copy Markdown
Collaborator

Good catch thanks!

@BenjaminDEMAILLE
BenjaminDEMAILLE deleted the macos-arm64-arch-flag branch September 8, 2026 13:22
@BenjaminDEMAILLE

Copy link
Copy Markdown
Contributor Author

One question while this is open: once it is merged, do you have a rough timeline for the next tagged release?

I ask because Homebrew builds from release tarballs rather than from a branch, so the fix only reaches users there when it is in a tag. Until then the formula has to carry the equivalent one-line patch itself, which reviewers understandably ask about: Homebrew/homebrew-core#302933

No pressure on the timing, I just want to know whether to keep the local patch or wait for the tag.

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.

Build fails on Apple Silicon: external_libs force -arch x86_64 on all macOS hosts

2 participants