Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass --arch to node-gyp instead of --target-arch #53

Merged
merged 1 commit into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Options can be provided via (in order of precedence) the programmatic API, the C

\* A target takes the form of `(runtime@)?version`, where `runtime` defaults to `'node'`. For example: `-t 8.14.0 -t electron@3.0.0`. At least one of `--target`, `--all` or `--napi` must be specified.

\*\* The `arch` option is passed to [`node-gyp`][node-gyp] as `--target-arch`. Target architecture and platform (what you're building _for_) default to the host platform and architecture (what you're building _on_). They can be overridden for cross-compilation, in which case you'll likely also want to override the strip binary. The platform and architecture dictate the output folder. For example on Linux x64 prebuilds end up in `prebuilds/linux-x64`.
\*\* The `arch` option is passed to [`node-gyp`][node-gyp] as `--arch`. Target architecture and platform (what you're building _for_) default to the host platform and architecture (what you're building _on_). They can be overridden for cross-compilation, in which case you'll likely also want to override the strip binary. The platform and architecture dictate the output folder (to be found by `node-gyp-build` at runtime). For example on Linux x64 prebuilds end up in `prebuilds/linux-x64`. The `arch` option can also be a multi-arch value separated by `+` (for example `x64+arm64` for a [universal binary](https://en.wikipedia.org/wiki/Universal_binary)) mainly to dictate the output folder; only the first architecture is passed on to `node-gyp`.

\*\*\* The filenames of prebuilds are composed of _tags_ which by default include runtime and either `napi` or `abi<version>`. For example: `electron.abi40.node`. To make more specific prebuilds (for `node-gyp-build` to select) you can add additional tags. Values for these tags are auto-detected. For example, `--napi --tag-uv --tag-armv` could result in a build called `node.napi.uv1.armv8.node` if the host machine has an ARM architecture. When cross-compiling you can override values either through the relevant option (`--tag-armv --armv 7`) or the tag (`--tag-armv 7`) as a shortcut. They're separate because you may want to build a certain version without tagging the prebuild as such, assuming that the prebuild is forward compatible.

Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ function build (target, runtime, opts, cb) {
args.push('--devdir=' + path.join(cache, runtime))

if (opts.arch) {
args.push('--target_arch=' + opts.arch)
// Only pass the first architecture because node-gyp doesn't understand
// our multi-arch tuples (for example "x64+arm64"). In any case addon
// authors must modify their binding.gyp for multi-arch scenarios,
// because neither node-gyp nor prebuildify have builtin support.
args.push('--arch=' + opts.arch.split('+')[0])
}

if (runtime === 'electron') {
Expand Down