From 659789f17c8cad81eac606d429a9a3f724bc0d2b Mon Sep 17 00:00:00 2001 From: Benjamin Demaille Date: Tue, 8 Sep 2026 11:23:57 +0200 Subject: [PATCH] Makefiles: only force -arch x86_64 on Intel macOS 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 --- external_libs/mvtnorm/Makefile | 5 ++++- external_libs/pgenlib/Makefile | 5 ++++- external_libs/qf/Makefile | 5 ++++- external_libs/quadpack/Makefile | 5 ++++- external_libs/remeta/Makefile | 5 ++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/external_libs/mvtnorm/Makefile b/external_libs/mvtnorm/Makefile index ac3d3893..29f883db 100644 --- a/external_libs/mvtnorm/Makefile +++ b/external_libs/mvtnorm/Makefile @@ -5,8 +5,11 @@ CC ?= gcc FC ?= gfortran UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) ifeq ($(UNAME_S),Darwin) - FLAG += -arch x86_64 + ifeq ($(UNAME_M),x86_64) + FLAG += -arch x86_64 + endif endif libMvtnorm.a: mvtnorm.o mvt.o randomF77.o diff --git a/external_libs/pgenlib/Makefile b/external_libs/pgenlib/Makefile index 262d920b..5ed281d8 100644 --- a/external_libs/pgenlib/Makefile +++ b/external_libs/pgenlib/Makefile @@ -7,8 +7,11 @@ CXXFLAGS = -O3 -Wall -std=c++11 CFLAGS = UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) ifeq ($(UNAME_S),Darwin) - CXXFLAGS += -arch x86_64 + ifeq ($(UNAME_M),x86_64) + CXXFLAGS += -arch x86_64 + endif endif OBJECTS = $(patsubst %.cc,%.o,$(wildcard ./include/*.cc)) $(patsubst %.cpp,%.o,$(wildcard *.cpp)) $(patsubst %.cc,%.o,$(wildcard *.cc)) diff --git a/external_libs/qf/Makefile b/external_libs/qf/Makefile index 3d0341ac..f139e65f 100644 --- a/external_libs/qf/Makefile +++ b/external_libs/qf/Makefile @@ -3,8 +3,11 @@ CXX ?= g++ CXXFLAGS = -O2 -DNDEBUG -fPIC UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) ifeq ($(UNAME_S),Darwin) - CXXFLAGS += -arch x86_64 + ifeq ($(UNAME_M),x86_64) + CXXFLAGS += -arch x86_64 + endif endif qf.a: qfc.o diff --git a/external_libs/quadpack/Makefile b/external_libs/quadpack/Makefile index e160de35..f70f0b1f 100644 --- a/external_libs/quadpack/Makefile +++ b/external_libs/quadpack/Makefile @@ -3,8 +3,11 @@ AR ?= ar FC ?= gfortran UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) ifeq ($(UNAME_S),Darwin) - FLAG += -arch x86_64 + ifeq ($(UNAME_M),x86_64) + FLAG += -arch x86_64 + endif endif OBJECTS = $(patsubst %.f,%.o,$(wildcard ./*.f)) diff --git a/external_libs/remeta/Makefile b/external_libs/remeta/Makefile index 543c5c7e..9d5f2aad 100644 --- a/external_libs/remeta/Makefile +++ b/external_libs/remeta/Makefile @@ -12,8 +12,11 @@ ifneq ($(strip $(HTSLIB_PATH)),) # defined externally endif UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) ifeq ($(UNAME_S),Darwin) - CXXFLAGS += -arch x86_64 + ifeq ($(UNAME_M),x86_64) + CXXFLAGS += -arch x86_64 + endif endif OBJECTS = bgz_writer.o regenie_ld_matrix_writer.o