supranational / blst

Multilingual BLS12-381 signature library
Apache License 2.0
471 stars 177 forks source link

Installation fails on macOS Monterey 12.5 (Apple M1 Max) #127

Closed faustbrian closed 2 years ago

faustbrian commented 2 years ago

Hey, I'm trying to install https://github.com/ChainSafe/blst-ts/issues/70 on macOS Monterey 12.5 which depends on https://github.com/supranational/blst to compare performance to https://github.com/herumi/bls but am running into an issue with building it. Python 3.10 and Node v18.8.0 (arm64) are used. CPU is Apple M1 Max if it matters.

~/Work/bls-test
❯ pnpm i @chainsafe/blst
Packages: +96
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst: Running install script, failed in 4s
.../node_modules/@chainsafe/blst install$ node dist/scripts/install.js
│ Retrieving BLST native bindings...
│ Error: Error importing BLST native bindings: 404 Not Found
│     at Object.downloadReleaseAsset (/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/dist/scripts/downloadReleaseAsset.js:20:15)
│     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
│     at async Object.downloadBindings (/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/dist/scripts/downloadBindings.js:9:5)
│     at async install (/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/dist/scripts/install.js:34:9)
│ Building BLST native bindings from source...
│ BLST_WRAP_CPP_PREBUILD /Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/prebuild/blst_wrap.cpp exists, SWIG will be skipped
│ Launching node-gyp {
│   nodeJsExec: '/Users/brianfaust/Library/Application Support/fnm/node-versions/v18.7.0/installation/bin/node',
│   nodeGypExec: '/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/bin/node-gyp.js',
│   cwd: '/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/blst/bindings/node.js',
│   BLST_WRAP_CPP_PREBUILD: '/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/prebuild/blst_wrap.cpp'
│ }
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@8.4.1
│ gyp info using node@18.7.0 | darwin | arm64
│ gyp info find Python using Python version 3.10.6 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   '/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/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/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/blst/bindings/node.js/build/config.gypi',
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/Users/brianfaust/Library/Caches/node-gyp/18.7.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/brianfaust/Library/Caches/node-gyp/18.7.0',
│ gyp info spawn args   '-Dnode_gyp_dir=/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp',
│ gyp info spawn args   '-Dnode_lib_file=/Users/brianfaust/Library/Caches/node-gyp/18.7.0/<(target_arch)/node.lib',
│ gyp info spawn args   '-Dmodule_root_dir=/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/blst/bindings/node.js',
│ 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' ]
│ make: Entering directory '/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/blst/bindings/node.js/build'
│   ACTION binding_gyp_blst_target_blst_wrap Release/obj.target/blst/geni/blst_wrap.cpp
│ Copying and using '/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/prebuild/blst_wrap.cpp'
│   CXX(target) Release/obj.target/blst/geni/blst_wrap.o
│   CC(target) Release/obj.target/blst/../../src/server.o
│   CC(target) Release/obj.target/blst/../../build/assembly.o
│ ../../../build/mach-o/add_mod_384-armv8.S:964:13: error: invalid operand for instruction
│  dup v1.2d, v0.2d[1]
│             ^
│ ../../../build/mach-o/add_mod_384-armv8.S:966:10: error: invalid operand for instruction
│  mov x1, v0.2d[0]
│          ^
│ ../../../build/mach-o/add_mod_384-armv8.S:993:13: error: invalid operand for instruction
│  dup v1.2d, v0.2d[1]
│             ^
│ ../../../build/mach-o/add_mod_384-armv8.S:995:10: error: invalid operand for instruction
│  mov x1, v0.2d[0]
│          ^
│ make: *** [blst.target.mk:173: Release/obj.target/blst/../../build/assembly.o] Error 1
│ make: Leaving directory '/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/blst/bindings/node.js/build'
│ gyp ERR! build error
│ gyp ERR! stack Error: `make` failed with exit code: 2
│ gyp ERR! stack     at ChildProcess.onExit (/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/lib/build.js:194:23)
│ gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
│ gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
│ gyp ERR! System Darwin 21.6.0
│ gyp ERR! command "/Users/brianfaust/Library/Application Support/fnm/node-versions/v18.7.0/installation/bin/node" "/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
│ gyp ERR! cwd /Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/blst/bindings/node.js
│ gyp ERR! node -v v18.7.0
│ gyp ERR! node-gyp -v v8.4.1
│ gyp ERR! not ok
│ Error: Error building BLST native bindings: Command failed: /Users/brianfaust/Library/Application Support/fnm/node-versions/v18.7.0/installation/bin/node /Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/bin/node-gyp.js rebuild
│ gyp info it worked if it ends with ok
│ gyp info using node-gyp@8.4.1
│ gyp info using node@18.7.0 | darwin | arm64
│ gyp info find Python using Python version 3.10.6 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   '/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/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/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/blst/bindings/node.js/build/config.gypi',
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/addon.gypi',
│ gyp info spawn args   '-I',
│ gyp info spawn args   '/Users/brianfaust/Library/Caches/node-gyp/18.7.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/brianfaust/Library/Caches/node-gyp/18.7.0',
│ gyp info spawn args   '-Dnode_gyp_dir=/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp',
│ gyp info spawn args   '-Dnode_lib_file=/Users/brianfaust/Library/Caches/node-gyp/18.7.0/<(target_arch)/node.lib',
│ gyp info spawn args   '-Dmodule_root_dir=/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/blst/bindings/node.js',
│ 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' ]
│ ../../../build/mach-o/add_mod_384-armv8.S:964:13: error: invalid operand for instruction
│  dup v1.2d, v0.2d[1]
│             ^
│ ../../../build/mach-o/add_mod_384-armv8.S:966:10: error: invalid operand for instruction
│  mov x1, v0.2d[0]
│          ^
│ ../../../build/mach-o/add_mod_384-armv8.S:993:13: error: invalid operand for instruction
│  dup v1.2d, v0.2d[1]
│             ^
│ ../../../build/mach-o/add_mod_384-armv8.S:995:10: error: invalid operand for instruction
│  mov x1, v0.2d[0]
│          ^
│ make: *** [blst.target.mk:173: Release/obj.target/blst/../../build/assembly.o] Error 1
│ gyp ERR! build error
│ gyp ERR! stack Error: `make` failed with exit code: 2
│ gyp ERR! stack     at ChildProcess.onExit (/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/lib/build.js:194:23)
│ gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
│ gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:291:12)
│ gyp ERR! System Darwin 21.6.0
│ gyp ERR! command "/Users/brianfaust/Library/Application Support/fnm/node-versions/v18.7.0/installation/bin/node" "/Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
│ gyp ERR! cwd /Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/blst/bindings/node.js
│ gyp ERR! node -v v18.7.0
│ gyp ERR! node-gyp -v v8.4.1
│ gyp ERR! not ok
│     at ChildProcess.exithandler (node:child_process:410:12)
│     at ChildProcess.emit (node:events:513:28)
│     at maybeClose (node:internal/child_process:1091:16)
│     at Socket.<anonymous> (node:internal/child_process:449:11)
│     at Socket.emit (node:events:513:28)
│     at Pipe.<anonymous> (node:net:757:14) {
│   code: 1,
│   killed: false,
│   signal: null,
│   cmd: '/Users/brianfaust/Library/Application Support/fnm/node-versions/v18.7.0/installation/bin/node /Users/brianfaust/Work/bls-test/node_modules/.pnpm/node-gyp@8.4.1/node_modules/node-gyp/bin/node-gyp.js rebuild'
│ }
│ Error: Error downloading and building BLST native bindings. No fallback
│     at install (/Users/brianfaust/Work/bls-test/node_modules/.pnpm/@chainsafe+blst@0.2.5/node_modules/@chainsafe/blst/dist/scripts/install.js:61:11)
└─ Failed in 4s
Progress: resolved 96, reused 96, downloaded 0, added 0, done
 ELIFECYCLE  Command failed with exit code 1.

Original Issue: https://github.com/ChainSafe/blst-ts/issues/70#issuecomment-1234197194

dot-asm commented 2 years ago

Should be resolved in 3900e30a092a4a9432fc37909ab37633e5e81fec. I've verified that the Apple assembler manages to compile it and that binary code for the affected instructions is equivalent to one generated by Linux assembler, but do double-check on actual hardware.

Just in case for reference. The problem was that Apple assembler is not as syntax- tolerant as GNU assembler, and as result the most recent assembly additions turned out to be problematic for the former.

faustbrian commented 2 years ago

Thanks for the quick fix! Will give this a try when I'm back at my machine.

faustbrian commented 2 years ago

@dot-asm seems to work on my MacBook. Thanks! Will close here and go back to the original issue.

dot-asm commented 2 years ago

And as an additional confirmation I've managed to execute the Rust test suite on iPad. It exercises the same compiler toolchain that is used to build the blst itself, and the same assembly code. Thanks for the report.