Skip to content

Fix Apple Silicon builds: header ordering, SIMD guard, and qd toolchain#36

Open
Mohit-Lakra wants to merge 1 commit into
GeomScale:developfrom
Mohit-Lakra:develop
Open

Fix Apple Silicon builds: header ordering, SIMD guard, and qd toolchain#36
Mohit-Lakra wants to merge 1 commit into
GeomScale:developfrom
Mohit-Lakra:develop

Conversation

@Mohit-Lakra
Copy link
Copy Markdown

@Mohit-Lakra Mohit-Lakra commented Feb 10, 2026

Fixes #35

This PR fixes the Apple Silicon / ARM build breakages reported in #35.

lp_solve header ordering: we now make sure the bundled lp_solve headers are picked up before any system include dirs (via src/external/lpSolve/src/Makefile and the calling src/Makevars). This avoids cases where Homebrew’s lp_types.h is found first and LPSREAL ends up missing.

PackedCSparse intrinsics: src/external/PackedCSparse/FloatArray.h only pulls in <immintrin.h> when building for AVX2 on x86, so ARM builds stay on the existing scalar path and don’t trip over x86-only headers.

qd build/toolchain consistency: the vendored qd build now compiles .cc sources with $(CXX) and the C++ flags forwarded from src/Makevars (and runs ranlib on libqd.a where needed). This avoids ABI/arch mismatches when R uses different CC/CXX settings.

After these changes, R CMD INSTALL . completes successfully on Apple Silicon (tested with Homebrew R 4.5), and there’s no behavior change expected on x86.

@Mohit-Lakra
Copy link
Copy Markdown
Author

Hi @vissarion
When you have a moment, could you please review this and share your feedback? I’d also appreciate your perspective on whether the scope looks appropriate for merging.

Thank you.

Build bundled qd with the C++ toolchain

Small format fix

Forward RANLIB to qd make
@arnavsharma990
Copy link
Copy Markdown

hey @Mohit-Lakra Great fix for the arm64 build issue
The SIMD guard addition looks clean.

Just wondering are there any remaining AVX-specific code paths that might need guarding beyond the header include?

@Mohit-Lakra
Copy link
Copy Markdown
Author

Hey @arnavsharma990 thanks!
At this point, I don’t think there are any other AVX-specific paths that need extra guarding. The intrinsic code was already wrapped in #ifdef __AVX2__ , so ARM never touches it. The only thing that was leaking into arm64 builds was the unconditional <immintrin.h> include.

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.

R CMD INSTALL fails on Apple Silicon due to lp_solve headers and x86- only intrinsics

2 participants