Skip to content

Add macOS with Apple Silicon support - #5

Merged
kohbis merged 2 commits into
mitene:masterfrom
ainame:ai/apple-silicon
Jun 24, 2025
Merged

Add macOS with Apple Silicon support#5
kohbis merged 2 commits into
mitene:masterfrom
ainame:ai/apple-silicon

Conversation

@ainame

@ainame ainame commented Jun 18, 2025

Copy link
Copy Markdown

Background

I created this PR to this fork instead of upstream that's not likely to merge PRs like westonplatter#96, westonplatter#99 and westonplatter#100 and release a new version anytime soon.

I fixed extconf.rb as per the title for modern macOS support.

What's changed?

This PR has two parts -

  • Support include/lib paths for dependencies installed via Homebrew
  • Overwrite the latest config.sub/guess to have build tools recognise macOS with Apple Silicon (the ones bundled with pHash were created 2011 and M1 Mac didn't exist 😇)

Approach for config.sub/guess

When I was working on this fix, I didn't realise there is #2 got merged already. Because I still got the error like this below.

 checking for /etc/SuSErelease... no
 checking build system type... Invalid configuration `aarch64-apple-darwin24.5.0': machine `aarch64-apple' not recognized
 configure: error: /bin/sh ./config.sub aarch64-apple-darwin24.5.0 failed
 *** ../../../../ext/phashion_ext/extconf.rb failed ***
 Could not create Makefile due to some reason, probably lack of necessary
 libraries and/or headers.  Check the mkmf.log file for more details.  You may
 need configuration options.

This PR title says config.sub and guess were updated but it looks like only config.guess was updated.

% tar -xvf ext/phashion_ext/pHash-0.9.6.tar.gz
% ls -lah pHash-0.9.6/config*
 -rwxr-xr-x@ 1 satoshi.namai.01.ts  staff    50K  3 Jun  2024 pHash-0.9.6/config.guess # <= 3rd Jun 2024 (Updated)
 -rw-r--r--@ 1 satoshi.namai.01.ts  staff   3.4K 23 Apr  2013 pHash-0.9.6/config.h.in
 -rwxr-xr-x@ 1 satoshi.namai.01.ts  staff    33K  2 Aug  2011 pHash-0.9.6/config.sub. # <= 2nd Aug 2011 (Not Updated 🤔 )
 -rwxr-xr-x@ 1 satoshi.namai.01.ts  staff   583K 23 Apr  2013 pHash-0.9.6/configure
 -rw-r--r--@ 1 satoshi.namai.01.ts  staff   7.9K 23 Apr  2013 pHash-0.9.6/configure.ac

I went with different approach that we keep the original tar ball but overwrite config.sub/guess in extconf.rb. You can see the changes without tar -xvf and it will be easier to update pHash's version. Does this approach make sense? Let me know. I can change to the original approach squeezing config.sub/guess files to the tar ball.

Testing

  • rake compile, rake test passed on macOS 15.4 with M4 Max

@ainame
ainame force-pushed the ai/apple-silicon branch 3 times, most recently from a3a76b7 to 6cbaaa0 Compare June 18, 2025 16:16
@ainame
ainame marked this pull request as ready for review June 18, 2025 16:36
@ainame
ainame force-pushed the ai/apple-silicon branch from f7d7717 to 94ab0ca Compare June 18, 2025 17:02
@ainame

ainame commented Jun 19, 2025

Copy link
Copy Markdown
Author

Compared contents in pHash-0.9.6.tar.gz before and after. Only config.guess is reverted. Unused index.html?p=config.git was included previously as well.

% diff -qr pHash-0.9.6 pHash-0.9.6-before
Files pHash-0.9.6/config.guess and pHash-0.9.6-before/config.guess differ
Only in pHash-0.9.6-before: index.html?p=config.git

# https://github.com/westonplatter/phashion/pull/99
if mac_os_with_homebrew
prefix = `brew --prefix`.strip
sqlite_prefix = `brew --prefix sqlite3`.strip

@ainame ainame Jun 19, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sqlite3 in homebrew is "keg-only" formula meaning you can't find sliqte3ext.h at /opt/homebrew/include. Instead it only exists at /opt/homebrew/opt/sqlite/include.

@kohbis
kohbis merged commit e44c5cc into mitene:master Jun 24, 2025
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.

2 participants