mapbox / mapbox/node-pre-gyp

The '--target_arch' parameter does not work

Open
#669 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.2k
Forks
271
Avg merge
23h 40m
Merged PRs (30d)
2

Description

building for macOS-arm64 but attempting to link with file built for macOS-x86_64

When I execute the following command:

```
npx node-pre-gyp configure --target_arch="x64"
```

You can see that the log output is still used `arm64`.
```
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.9
node-pre-gyp info using node@18.9.1 | darwin | arm64
gyp info it worked if it ends with ok
gyp info using node-gyp@9.1.0
gyp info using node@18.9.1 | 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 '/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',

```

Then it fails when I build:

```
npx node-pre-gyp build --target_arch=x64

CC(target) Release/obj.target/nothing/node_modules/node-addon-api/nothing.o
LIBTOOL-STATIC Release/nothing.a
warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
SOLINK_MODULE(target) Release/Pulsar.node
ld: archive has no table of contents file '../pkg/lib/libpulsarwithdeps.a' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/Pulsar.node] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/opt/homebrew/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:201: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

```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the reported node-pre-gyp configure and build commands on macOS, then trace how --target_arch reaches node-gyp and the linker. Done means the x64 target is honored throughout the logs and the build no longer attempts to link the arm64 archive.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.