Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Unable to build 32bit executables on 5.x #1634

Closed
SagePacheco opened this issue May 18, 2022 · 8 comments
Closed

Unable to build 32bit executables on 5.x #1634

SagePacheco opened this issue May 18, 2022 · 8 comments

Comments

@SagePacheco
Copy link

What version of pkg are you using?

5.7.0 but applies to all 5.x

What version of Node.js are you using?

16.15.0 64 and 32bit

What operating system are you using?

Windows 10

What CPU architecture are you using?

x86_64

What Node versions, OSs and CPU architectures are you building for?

node16-win-x86

Describe the Bug

PKG 5.x seems to be choking on any attempt to build a 32bit executable.

Beginning snippet:
`

pkg-test@1.0.0 build
pkg .

pkg@5.7.0
Fetching base Node.js binaries to PKG_CACHE_PATH

Error! 404: Not Found
Not found in remote cache:
{"tag":"v3.4","name":"node-v16.15.0-win-x86"}
Building base binary from source:
built-v16.15.0-win-x86
Fetching Node.js source archive from nodejs.org...
Extracting Node.js source archive...
`

Then it goes into verbose debug mode where it starts listing directories (small chunk for an example):
`

benchmark/
benchmark/README.md
benchmark/_benchmark_progress.js
benchmark/_cli.R
benchmark/_cli.js
benchmark/_http-benchmarkers.js
benchmark/_test-double-benchmarker.js
`

Then after listing directories it ends with an error stack:
`

Applying patches
Error! Error: spawnSync patch ENOENT
at Object.spawnSync (node:internal/child_process:1111:20)
at spawnSync (node:child_process:814:24)
at
`

Expected Behavior

I have been able to successfully build my project on 4.5.1 with target node14-win-x86 (No available node version satisfies 'node16'), but would like to update to 5.x for compression and other benefits.

I can use 5.x to build my project for basically any node version at 64 bit. Would like to do the same for 32 bit.

To Reproduce

From my findings, trying to build any project using 5.x with a 32 bit target will fail.
Here are my package.json details for reference:

"scripts": { "build": "pkg ." }, "pkg": { "outputPath": "dist", "targets": [ "node16-win-x86" ] }, "dependencies": { "pkg": "5.7.0" },

@jesec
Copy link
Contributor

jesec commented May 31, 2022

This is expected behavior.

32-bit is no longer supported. Please upgrade to a supported architecture.

@jesec jesec closed this as completed May 31, 2022
@SagePacheco
Copy link
Author

Thanks for the reply, @jesec. Unfortunately due to legacy support requirements, I am stuck on that architecture for this particular application.
May I ask why support for 32 bit was dropped? Node still compiles binaries for both targets, so I am curious as to what the limitation is here. And if it is a limitation of the bytecode generation that PKG handles... would it be possible to update the fetcher to grab 32bit binaries and utilize the --no-bytecode flag?

@jesec
Copy link
Contributor

jesec commented Jun 1, 2022

Our energy would be better spent maintaining new architectures such as arm64, instead of a relic that should be dropped years ago. Unfortunately, it does take resources to maintain new architectures and platforms, so we have to make a choice here.

@jesec
Copy link
Contributor

jesec commented Jun 1, 2022

pkg requires patched Node.js binaries. You would have to compile your own. It is not possible to get around that.

@SagePacheco
Copy link
Author

Couldn't agree more on the leaving old architectures; wish I could for this particular thing I'm working on. Thanks for the explanation.
Say I (or my company) wanted to pursue compiling our own node patches... is that something we could do pretty trivially as long as we were willing to put the resources into it? Just want to get a gauge on how extensive changes typically are to a vanilla node binary to work with pkg.

@jesec
Copy link
Contributor

jesec commented Jun 1, 2022

Couldn't agree more on the leaving old architectures; wish I could for this particular thing I'm working on. Thanks for the explanation. Say I (or my company) wanted to pursue compiling our own node patches... is that something we could do pretty trivially as long as we were willing to put the resources into it? Just want to get a gauge on how extensive changes typically are to a vanilla node binary to work with pkg.

pkg-fetch contains everything you would need. It requires a few more dependencies (C++ compiler, patch, etc.) to compile the Node binary, and that's why you saw that error. Once you installed all the required dependencies, it should proceed.

Then, you may transfer the ~/.pkg-cache across machines to speed up the process next time.

@SagePacheco
Copy link
Author

Good to know! Thank you for the feedback, @jesec!

@amexn-me
Copy link

amexn-me commented Oct 5, 2023

Hi @SagePacheco ,
I'm also in need to support the x86 requirement for one of our clients. Were you able to get around that and make executables for 32bit windows arch?

Edit: I made myself one, please refer to see if it suits your requirements.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants