Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
Build a universal binary to support M1 (Apple silicon) (#181)
Browse files Browse the repository at this point in the history
On mac, the prebuilt binary (as well as the binary built by
`npm i --build-from-source`) is now a universal binary that's
suitable for both x86_64 (as before) and arm64 (new).

Also adds 'rocksdb/util/crc32c_arm64.cc' to the includes,
needed for arm64 architectures in general.
  • Loading branch information
Nazgolze authored Sep 28, 2021
1 parent a1066ca commit 0bda9ba
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ jobs:
include:
- os: ubuntu-latest
build-group: linux-x64
- os: macos-latest
build-group: darwin-x64
# At the time of writing macos-latest is mac 10; we need 11 to build a universal binary.
- os: macos-11
build-group: darwin-x64+arm64
- os: windows-latest
build-group: win32-x64
runs-on: ${{ matrix.os }}
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# At the time of writing macos-latest is mac 10; we need 11 to build a universal binary.
os: [ubuntu-latest, macos-11, windows-latest]
node: [10, 12, 14]
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} / Node ${{ matrix.node }}
Expand Down
8 changes: 7 additions & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@
'-mmacosx-version-min=10.8'
, '-std=c++11'
, '-stdlib=libc++'
, '-arch x86_64'
, '-arch arm64'
]
, 'OTHER_LDFLAGS': [
'-stdlib=libc++'
, '-arch x86_64'
, '-arch arm64'
]
, 'OTHER_LDFLAGS': ['-stdlib=libc++']
, 'GCC_ENABLE_CPP_RTTI': 'YES'
, 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
, 'MACOSX_DEPLOYMENT_TARGET': '10.8'
Expand Down
3 changes: 3 additions & 0 deletions deps/rocksdb/rocksdb.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@
, '-stdlib=libc++'
, '-fno-omit-frame-pointer'
, '-momit-leaf-frame-pointer'
, '-arch x86_64'
, '-arch arm64'
]
# , 'OTHER_LDFLAGS': ['-stdlib=libc++']
, 'GCC_ENABLE_CPP_RTTI': 'YES'
Expand Down Expand Up @@ -376,6 +378,7 @@
, 'rocksdb/util/compression_context_cache.cc'
, 'rocksdb/util/concurrent_task_limiter_impl.cc'
, 'rocksdb/util/crc32c.cc'
, 'rocksdb/util/crc32c_arm64.cc'
, 'rocksdb/util/dynamic_bloom.cc'
, 'rocksdb/util/hash.cc'
, 'rocksdb/util/murmurhash.cc'
Expand Down
4 changes: 4 additions & 0 deletions deps/snappy/snappy.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
'-Wno-sign-compare'
, '-Wno-unused-function'
]
, 'OTHER_CFLAGS': [
'-arch x86_64'
, '-arch arm64'
]
}
}]
]
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"rebuild": "npm run install --build-from-source",
"prebuild": "prebuildify -t 8.14.0 --napi --strip",
"prebuild-linux-x64": "prebuildify-cross -i centos7-devtoolset7 -i alpine -t 8.14.0 --napi --strip",
"prebuild-darwin-x64": "prebuildify -t 8.14.0 --napi --strip",
"prebuild-darwin-x64+arm64": "prebuildify -t 8.14.0 --napi --strip --arch x64+arm64",
"prebuild-win32-x64": "prebuildify -t 8.14.0 --napi --strip",
"download-prebuilds": "prebuildify-ci download",
"hallmark": "hallmark --fix",
Expand All @@ -24,7 +24,7 @@
"dependencies": {
"abstract-leveldown": "^7.0.0",
"napi-macros": "^2.0.0",
"node-gyp-build": "^4.2.3"
"node-gyp-build": "^4.3.0"
},
"devDependencies": {
"async-each": "^1.0.3",
Expand All @@ -40,7 +40,7 @@
"mkfiletree": "^2.0.0",
"node-gyp": "^7.1.2",
"nyc": "^15.0.0",
"prebuildify": "^4.1.1",
"prebuildify": "^4.2.1",
"prebuildify-ci": "^1.0.4",
"prebuildify-cross": "^4.0.1",
"readfiletree": "^1.0.0",
Expand Down

0 comments on commit 0bda9ba

Please sign in to comment.