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

Use arch instead of target_arch #311

Merged
merged 2 commits into from
Feb 1, 2024
Merged

Conversation

gergof
Copy link
Contributor

@gergof gergof commented Oct 12, 2023

When building for a different architecture using node-gyp, the arch option should be used. Using target_arch populates the variable usable in the binding.gyp file, but node-gyp will still do a build with the system's architecture.

@lovell
Copy link
Member

lovell commented Oct 12, 2023

Thanks for the PR. There's some logic in node-gyp that suggests target_arch is the expected name.

https://github.com/nodejs/node-gyp/blob/b3d41aeb737ddd54cc292f363abc561dcc0a614e/lib/build.js#L59

There's also a known bug in node-gyp relating to this - see nodejs/node-gyp#2865 - if that bug was fixed, would this change still be necessary?

@gergof
Copy link
Contributor Author

gergof commented Oct 12, 2023

I think it still would be necessary.
The target_arch variable is overwritten here: https://github.com/nodejs/node-gyp/blob/b3d41aeb737ddd54cc292f363abc561dcc0a614e/lib/create-config-gypi.js#L69

The documentation is also suggesting using --arch: https://github.com/nodejs/node-gyp/tree/b3d41aeb737ddd54cc292f363abc561dcc0a614e#command-options

This was probably not the case before, but since updating prebuild to version 12, even though target_arch is set to x64, the flags passed to the compiler state that the build arch should be arm64. With this change it works as expected without any side effects.

@vweevers
Copy link
Member

vweevers commented Oct 12, 2023

See also prebuild/prebuildify#53 and prebuild/prebuildify#52 (comment)

Copy link
Member

@lovell lovell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please can you update the failing "gyp is invoked with correct arguments" tests.

@gergof gergof requested a review from lovell October 20, 2023 08:25
@gergof
Copy link
Contributor Author

gergof commented Oct 23, 2023

I've made the changes, the tests are passing now.

Copy link
Member

@lovell lovell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, LGTM

@lovell lovell merged commit f8d82a1 into prebuild:master Feb 1, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants