Skip to content

Build failure on macOS 15.4 with Xcode 16.3#119

Merged
m4heshd merged 1 commit intom4heshd:masterfrom
eun-ice:master
May 13, 2025
Merged

Build failure on macOS 15.4 with Xcode 16.3#119
m4heshd merged 1 commit intom4heshd:masterfrom
eun-ice:master

Conversation

@eun-ice
Copy link
Copy Markdown
Contributor

@eun-ice eun-ice commented Apr 4, 2025

Thank you for this wonderful project.

Since updating to macOS 15.4 and Xcode 16.3 the build fails during the install phase with

error /Users/someone/Projects/typescript/1.5/development/cs-frontend/node_modules/better-sqlite3-multiple-ciphers: Command failed.
Exit code: 1
Command: prebuild-install || node-gyp rebuild --release
Arguments: 
Directory: /Users/someone/Projects/typescript/1.5/development/cs-frontend/node_modules/better-sqlite3-multiple-ciphers
Output:
/bin/sh: prebuild-install: command not found
gyp info it worked if it ends with ok
gyp info using node-gyp@11.2.0
gyp info using node@18.20.8 | darwin | arm64
gyp info find Python using Python version 3.10.16 found at "/opt/homebrew/opt/python@3.10/bin/python3.10"

gyp info spawn /opt/homebrew/opt/python@3.10/bin/python3.10
gyp info spawn args [
gyp info spawn args '/opt/homebrew/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/someone/Projects/typescript/1.5/development/cs-frontend/node_modules/better-sqlite3-multiple-ciphers/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/opt/homebrew/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/someone/Library/Caches/node-gyp/18.20.8/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/someone/Library/Caches/node-gyp/18.20.8',
gyp info spawn args '-Dnode_gyp_dir=/opt/homebrew/lib/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/Users/someone/Library/Caches/node-gyp/18.20.8/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/Users/someone/Projects/typescript/1.5/development/cs-frontend/node_modules/better-sqlite3-multiple-ciphers',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  TOUCH ba23eeee118cd63e16015df367567cb043fed872.intermediate
  ACTION deps_sqlite3_gyp_locate_sqlite3_target_copy_builtin_sqlite3 ba23eeee118cd63e16015df367567cb043fed872.intermediate
  TOUCH Release/obj.target/deps/locate_sqlite3.stamp
  CC(target) Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o
clang: error: unsupported option '-maes' for target 'arm64-apple-darwin24.4.0'
make: *** [Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o] Error 1
rm ba23eeee118cd63e16015df367567cb043fed872.intermediate
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.<anonymous> (/opt/homebrew/lib/node_modules/node-gyp/lib/build.js:219:23)
gyp ERR! System Darwin 24.4.0
gyp ERR! command "/opt/homebrew/Cellar/node@18/18.20.8/bin/node" "/opt/homebrew/lib/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /Users/someone/Projects/typescript/1.5/development/cs-frontend/node_modules/better-sqlite3-multiple-ciphers

My clang version is

$ clang --version
Apple clang version 17.0.0 (clang-1700.0.13.3)
Target: arm64-apple-darwin24.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Yes my node version is outdated, but upgrading didn't fix the issue.

My pull request fixes the build and doesn't seem to break windows and linux.

I do not know if this will introduce performance regressions, so this is by no means ready to be merged to upstream. I just wanted to share so it might save someone else some time.

@m4heshd
Copy link
Copy Markdown
Owner

m4heshd commented Apr 4, 2025

It's pretty odd that node-gyp isn't respecting the 'cflags!': ['-maes', '-msse4.2'] part of the gyp config specifically set for arm platforms. That configuration is the reason why it has successfully compiled on arm* archs so far. Must have something to do with the particular version of Xcode you're using, which might have introduced some incompatibilities. Or.. was Xcode simply ignoring the incompatible flags on aarch64 silently and not respecting the 'cflags!': ['-maes', '-msse4.2'] option all this time? 🤔 No idea.

The maes flag is required for Intel macs, but no idea how it managed to compile successfully on the tests. It's been half a decade, so I can't remember how exactly the build process failed.

gyp is one of the most messy and complicated build tools ever created. The infuriating part is, there's no proper documentation for it other than some old ones from Google. If I were to be honest, when it comes to gyp, I'm always wingin' it. That's why I could be wrong about all of this.

We'll sit on this update for a bit to see how node-gyp responds to this. Please do mention it here if you stumble upon any updates regarding this. It would help to mention this there, though. I can't debug personally since I have never ever used macs and most likely never will. 😅

@m4heshd m4heshd added the open-for-discussion 💬 This issue is being kept open for further discussions label Apr 4, 2025
@eun-ice
Copy link
Copy Markdown
Contributor Author

eun-ice commented Apr 5, 2025

I am glad to hear that it’s not only me who gets mightily confused and frustrated about those gyp builds. It feels like you have to do brain surgery, but with thick gloves, from the next room through a key hole.

Without your project I was unable to get SQLite to work with encryption, thank you again for this.

From what I gather clang on Mac arm never supported -maes and maybe just ignored it until the most recent update. We haven’t yet updated our CI servers, but they still build properly with the previous Xcode version (we build on macOS arm, macOS intel, Windows x64 and Linux x64)

After our current release cycle I will update our CI Macs and will get back to you on whether this change is still necessary and working.

Thank you. 🙏

@m4heshd
Copy link
Copy Markdown
Owner

m4heshd commented Apr 5, 2025

From what I gather clang on Mac arm never supported -maes and maybe just ignored it until the most recent update.

This is exactly why we have the 'cflags!': ['-maes', '-msse4.2'] option for the arm builds. You might not have noticed the exclamation symbol after the cflags option, which negates the given flags. So the following portion of the configuration SHOULD remove those flags from the global flags when the target platform is arm64/aarch64.

['target_arch=="arm64"', {
    'cflags!': ['-maes', '-msse4.2'],
}],
['target_arch=="arm"', {
    'cflags!': ['-maes', '-msse4.2'],
}],

I previously used -march=native' for the arm builds but had to remove that as well. Now, building without the native AES support.

Thank you. 🙏

My pleasure. 😊

@gebing
Copy link
Copy Markdown

gebing commented Apr 8, 2025

i had the same problem and waiting for PR

@eun-ice
Copy link
Copy Markdown
Contributor Author

eun-ice commented Apr 8, 2025

i had the same problem and waiting for PR

Did this one work for you too?

@gebing
Copy link
Copy Markdown

gebing commented Apr 9, 2025

yes

@m4heshd
Copy link
Copy Markdown
Owner

m4heshd commented Apr 9, 2025

Just realized why it compiles on all platforms all of a sudden without hardware support for AES. This commit has removed the necessity for native AES support, which removed the need for compiler flags. The change was included in v1.9.1. Somehow I missed it while merging the updates.

The build configuration needs a proper revamp with this. I'll get to it as soon as I have some free time.

@m4heshd m4heshd merged commit 7de4aa8 into m4heshd:master May 13, 2025
17 checks passed
@eun-ice
Copy link
Copy Markdown
Contributor Author

eun-ice commented Jun 24, 2025

Thank you for merging this, we switched back to upstream (11.10.0) and it looks like everything is fine on all our target platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-for-discussion 💬 This issue is being kept open for further discussions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants