Skip to content

Makefile: use -march=native on x86_64 Darwin#271

Open
hexxyan wants to merge 1 commit into
antirez:mainfrom
hexxyan:fix/makefile-x86-darwin-cpu
Open

Makefile: use -march=native on x86_64 Darwin#271
hexxyan wants to merge 1 commit into
antirez:mainfrom
hexxyan:fix/makefile-x86-darwin-cpu

Conversation

@hexxyan
Copy link
Copy Markdown
Contributor

@hexxyan hexxyan commented May 27, 2026

Summary

make cpu fails on x86_64 macOS because Apple Clang rejects -mcpu=native:

clang: error: unsupported option '-mcpu=' for target 'x86_64-apple-darwin25.4.0'

Fix: use -mcpu=native only on arm64 Darwin (Apple Silicon), fall back to -march=native on x86_64 Darwin. Linux behavior unchanged.

What Changed

Makefile (+5 lines)

Adds UNAME_M detection and a nested ifeq for Darwin:

  • Darwin arm64 → -mcpu=native (Apple Silicon, works)
  • Darwin x86_64 → -march=native (Intel Mac, works)
  • Linux → -march=native (unchanged)

Verification

Before (x86_64 macOS):

$ make cpu
clang: error: unsupported option '-mcpu=' for target 'x86_64-apple-darwin25.4.0'

After:

$ make clean && make cpu
# all targets build cleanly
$ ./ds4_test --server
server: OK

Apple Clang on x86_64 macOS rejects -mcpu=native with 'unsupported
option'. Use -mcpu=native only on arm64 (Apple Silicon), fall back to
-march=native on x86_64 Darwin. Linux unchanged.
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