Uh oh!
There was an error while loading. Please reload this page.
Remove hard coded arch from macos build - #167
Conversation
| 'OTHER_CFLAGS': ['-arch arm64'], | ||
| 'OTHER_LDFLAGS': ['-arch arm64'] |
There was a problem hiding this comment.
These are needed for prebuilt binaries to support both Intel and Apple Silicon when building on Intel. Without these the binary will only work on the platform where it is built.
There was a problem hiding this comment.
Is that being achieved? On my arm64 mac it just adds the -arch arm64 flag twice. Also I was under the impression a dual arch exec requires two passes of cc with each arch specifier and then you combine them with lipo.
There was a problem hiding this comment.
Is that being achieved?
Yes, see
cc -o Release/obj.target/bufferutil/src/bufferutil.o ../src/bufferutil.c '-DNODE_GYP_MODULE_NAME=bufferutil' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_FILE_OFFSET_BITS=64' '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-DBUILDING_NODE_EXTENSION' -I/Users/luigi/Library/Caches/node-gyp/25.2.1/include/node -I/Users/luigi/Library/Caches/node-gyp/25.2.1/src -I/Users/luigi/Library/Caches/node-gyp/25.2.1/deps/openssl/config -I/Users/luigi/Library/Caches/node-gyp/25.2.1/deps/openssl/openssl/include -I/Users/luigi/Library/Caches/node-gyp/25.2.1/deps/uv/include -I/Users/luigi/Library/Caches/node-gyp/25.2.1/deps/zlib -I/Users/luigi/Library/Caches/node-gyp/25.2.1/deps/v8/include -O3 -gdwarf-2 -fno-strict-aliasing -mmacosx-version-min=10.7 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -arch arm64 -MMD -MF ./Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw -c
c++ -bundle -arch arm64 -undefined dynamic_lookup -Wl,-search_paths_first -mmacosx-version-min=10.7 -arch x86_64 -L./Release -stdlib=libc++ -o Release/bufferutil.node Release/obj.target/bufferutil/src/bufferutil.o
See also 3af3375.
There was a problem hiding this comment.
I don't see how that can be true on an arm mac. See the transcript below from a clean master build. It just adds -arch arm64 twice. The entire reason for my issue/pr in the first place is that the current binding.gyp isn't compatible with electron-builder which requires that each node-gyp output is a single arch. This is gracefully handled by all my other native requirements such as better-sqlite3.
If you are still unconvinced that the binding.gyp in bufferutil has issues, then I don't know how else to communicate this issue and you should close this.
:; git rev-parse HEAD
1b9081dd93ad7e133d48a74603de2c176727300e
:; git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
:; uname -a
Darwin jmlaptop 24.6.0 Darwin Kernel Version 24.6.0: Wed Oct 15 21:12:06 PDT 2025; root:xnu-11417.140.69.703.14~1/RELEASE_ARM64_T6000 arm64
:; cc --version
Apple clang version 17.0.0 (clang-1700.4.4.1)
Target: arm64-apple-darwin24.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
:; npm install --build-from-source --verbose
npm verbose cli /opt/homebrew/Cellar/node/24.10.0/bin/node /opt/homebrew/bin/npm
npm info using npm@11.6.0
npm info using node@v24.10.0
npm warn Unknown cli config "--build-from-source". This will stop working in the next major version of npm.
npm verbose title npm install
npm verbose argv "install""--build-from-source""--loglevel""verbose"
npm verbose logfile logs-max:10 dir:/Users/mayfield/.npm/_logs/2025-12-09T20_45_47_590Z-
npm verbose logfile /Users/mayfield/.npm/_logs/2025-12-09T20_45_47_590Z-debug-0.log
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 512ms
> bufferutil@4.0.9 install
> node-gyp-build
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli '/opt/homebrew/Cellar/node/24.10.0/bin/node',
gyp verb cli '/Users/mayfield/project/bufferutil/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild'
gyp verb cli ]
gyp info using node-gyp@11.5.0
gyp info using node@24.10.0 | darwin | arm64
gyp verb clean removing "build" directory
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking if"python3" can be used
gyp verb find Python - executing "python3" to get executable path
gyp verb find Python - executable path is "/opt/homebrew/opt/python@3.14/bin/python3.14"
gyp verb find Python - executing "/opt/homebrew/opt/python@3.14/bin/python3.14" to get version
gyp verb find Python - version is "3.14.0"
gyp info find Python using Python version 3.14.0 found at "/opt/homebrew/opt/python@3.14/bin/python3.14"
gyp verb get node dir no --target version specified, falling back to host node version: 24.10.0
gyp verb install input version string "24.10.0"
gyp verb install installing version: 24.10.0
gyp verb install --ensure was passed, so won't reinstall if already installedgyp verb install version is already installed, need to check "installVersion"gyp verb got "installVersion" 11gyp verb needs "installVersion" 11gyp verb install version is goodgyp verb get node dir target node version installed: 24.10.0gyp verb build dir attempting to create "build" dir: /Users/mayfield/project/bufferutil/buildgyp verb build dir "build" dir needed to be created? Yesgyp verb build/config.gypi creating config filegyp verb build/config.gypi writing out config file: /Users/mayfield/project/bufferutil/build/config.gypigyp verb config.gypi checking for gypi file: /Users/mayfield/project/bufferutil/config.gypigyp verb common.gypi checking for gypi file: /Users/mayfield/project/bufferutil/common.gypigyp verb gyp gyp format was not specified; forcing "make"gyp info spawn /opt/homebrew/opt/python@3.14/bin/python3.14gyp info spawn args [gyp info spawn args '/Users/mayfield/project/bufferutil/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/mayfield/project/bufferutil/build/config.gypi',gyp info spawn args '-I',gyp info spawn args '/Users/mayfield/project/bufferutil/node_modules/node-gyp/addon.gypi',gyp info spawn args '-I',gyp info spawn args '/Users/mayfield/Library/Caches/node-gyp/24.10.0/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/mayfield/Library/Caches/node-gyp/24.10.0',gyp info spawn args '-Dnode_gyp_dir=/Users/mayfield/project/bufferutil/node_modules/node-gyp',gyp info spawn args '-Dnode_lib_file=/Users/mayfield/Library/Caches/node-gyp/24.10.0/<(target_arch)/node.lib',gyp info spawn args '-Dmodule_root_dir=/Users/mayfield/project/bufferutil',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 verb build type Releasegyp verb architecture arm64gyp verb node dev dir /Users/mayfield/Library/Caches/node-gyp/24.10.0gyp verb python /opt/homebrew/opt/python@3.14/bin/python3.14gyp verb `which` succeeded for `make` /usr/bin/makegyp verb bin symlinks created symlink to "/opt/homebrew/opt/python@3.14/bin/python3.14" in "/Users/mayfield/project/bufferutil/build/node_gyp_bins" and added to PATHgyp info spawn makegyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ] cc -o Release/obj.target/bufferutil/src/bufferutil.o ../src/bufferutil.c '-DNODE_GYP_MODULE_NAME=bufferutil''-DUSING_UV_SHARED=1''-DUSING_V8_SHARED=1''-DV8_DEPRECATION_WARNINGS=1''-D_GLIBCXX_USE_CXX11_ABI=1''-D_FILE_OFFSET_BITS=64''-D_DARWIN_USE_64_BIT_INODE=1''-D_LARGEFILE_SOURCE''-DBUILDING_NODE_EXTENSION' -I/Users/mayfield/Library/Caches/node-gyp/24.10.0/include/node -I/Users/mayfield/Library/Caches/node-gyp/24.10.0/src -I/Users/mayfield/Library/Caches/node-gyp/24.10.0/deps/openssl/config -I/Users/mayfield/Library/Caches/node-gyp/24.10.0/deps/openssl/openssl/include -I/Users/mayfield/Library/Caches/node-gyp/24.10.0/deps/uv/include -I/Users/mayfield/Library/Caches/node-gyp/24.10.0/deps/zlib -I/Users/mayfield/Library/Caches/node-gyp/24.10.0/deps/v8/include -O3 -gdwarf-2 -fno-strict-aliasing -mmacosx-version-min=10.7 -arch arm64 -Wall -Wendif-labels -W -Wno-unused-parameter -arch arm64 -MMD -MF ./Release/.deps/Release/obj.target/bufferutil/src/bufferutil.o.d.raw -c c++ -bundle -arch arm64 -undefined dynamic_lookup -Wl,-search_paths_first -mmacosx-version-min=10.7 -arch arm64 -L./Release -stdlib=libc++ -o Release/bufferutil.node Release/obj.target/bufferutil/src/bufferutil.o gyp info ok up to date, audited 169 packages in 1s36 packages are looking for funding run `npm fund` for detailsfound 0 vulnerabilitiesnpm verbose cwd /Users/mayfield/project/bufferutilnpm verbose os Darwin 24.6.0npm verbose node v24.10.0npm verbose npm v11.6.0npm verbose exit 0npm info ok:; lipo -archs ./build/Release/bufferutil.node arm64There was a problem hiding this comment.
I don't see how that can be true on an arm mac.
It is not on arm mac, it was never wanted. It was designed to build a universal binary on mac Intel and an arm only on mac arm. It works as intended.
It just adds
-arch arm64twice.
Yes, which is basically a noop.
The entire reason for my issue/pr in the first place is that the current binding.gyp isn't compatible with electron-builder which requires that each node-gyp output is a single arch.
Is there a reason for rebuilding? Is it not possible to use the prebuilt universal binary? We can move forward with this PR but you also need to update the CI configuration in order to produce two prebuilt binaries: one for Intel and one for ARM.
Uh oh!
There was an error while loading. Please reload this page.
Fix#166