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

Failed to make bytecode for arm64 on Linux x86 #95

Open
robvanderleek opened this issue Sep 27, 2024 · 5 comments
Open

Failed to make bytecode for arm64 on Linux x86 #95

robvanderleek opened this issue Sep 27, 2024 · 5 comments

Comments

@robvanderleek
Copy link

What version of pkg are you using?

5.15.0

What version of Node.js are you using?

21.2.0

What operating system are you using?

Ubuntu

What CPU architecture are you using?

x86_64

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

node20-linuxstatic-arm64

Describe the Bug

Building a static binary for Linux ARM64 failes on Linux x86. For example, this command:

npx pkg -o index -t node20-linuxstatic-arm64 index.js

Generates the following error:

> [email protected]
> Warning Failed to make bytecode node20-arm64 for file /snapshot/yao-pkg-linuxstatic-arm64-bug/index.js

Adding the --debug flag to the build shows:

/home/rob/.pkg-cache/v3.5/fetched-v20.17.0-linuxstatic-arm64: 1: Syntax error: "(" unexpected
/home/rob/.pkg-cache/v3.5/fetched-v20.17.0-linuxstatic-arm64: 1: Syntax error: "(" unexpected
> Warning Failed to make bytecode node20-arm64 for file /snapshot/yao-pkg-linuxstatic-arm64-bug/index.js

I am able to generate an ARM64 static Linux binary on macOS.

Expected Behavior

A static Linux ARM64 is generated without warnings.

To Reproduce

I created a minimal example repository that demonstrates the problem:

git clone [email protected]:robvanderleek/yao-pkg-linuxstatic-arm64-bug.git
cd yao-pkg-linuxstatic-arm64-bug/
npm install
npx pkg -o index -t node20-linuxstatic-arm64 index.js

Not that:

npx pkg -o index -t node20-linuxstatic-x64 index.js

does not generate the warning.

@robertsLando
Copy link
Member

robertsLando commented Sep 30, 2024

@robvanderleek Could you tell me if it's woking with past versions of pkg or other nodejs versions like 18/16? I just want to understand where the issue could be

It should come from:

`Failed to make bytecode ${fabricator.nodeRange}-${fabricator.arch} for file ${snap} error (${error.message})`,

Could you debug it?

@robvanderleek
Copy link
Author

Hi @robertsLando

See below how it fails for ARM64 with nodejs 20/18/16 versions, but works for x86 with nodejs 20/18/16.

I've tried pkg versions 5.15.0, 5.12.0, and 5.10.0, all failing.

I think it's host platform related, since building for arm64 fails on Linux Ubuntu 24, but succeeds on macOS.

rob:~/projects/yao-pkg-linuxstatic-arm64-bug$ npx pkg -o index -t node20-linuxstatic-arm64 index.js
> [email protected]
(node:19081) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> Fetching base Node.js binaries to PKG_CACHE_PATH
  fetched-v20.17.0-linuxstatic-arm64  [====================] 100%

> Warning Failed to make bytecode node20-arm64 for file /snapshot/yao-pkg-linuxstatic-arm64-bug/index.js
rob:~/projects/yao-pkg-linuxstatic-arm64-bug$ npx pkg -o index -t node18-linuxstatic-arm64 index.js
> [email protected]
(node:19116) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> Fetching base Node.js binaries to PKG_CACHE_PATH
  fetched-v18.20.4-linuxstatic-arm64  [====================] 100%

> Warning Failed to make bytecode node18-arm64 for file /snapshot/yao-pkg-linuxstatic-arm64-bug/index.js
rob:~/projects/yao-pkg-linuxstatic-arm64-bug$ npx pkg -o index -t node16-linuxstatic-arm64 index.js
> [email protected]
(node:19151) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> Fetching base Node.js binaries to PKG_CACHE_PATH
  fetched-v16.20.2-linuxstatic-arm64  [====================] 100%

> Warning Failed to make bytecode node16-arm64 for file /snapshot/yao-pkg-linuxstatic-arm64-bug/index.js error (write EPIPE)
rob:~/projects/yao-pkg-linuxstatic-arm64-bug$ npx pkg -o index -t node20-linuxstatic-x64 index.js
> [email protected]
(node:19186) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> Fetching base Node.js binaries to PKG_CACHE_PATH
  fetched-v20.17.0-linuxstatic-x64    [====================] 100%

  fetched-v20.17.0-linux-x64          [====================] 100%
rob:~/projects/yao-pkg-linuxstatic-arm64-bug$ npx pkg -o index -t node18-linuxstatic-x64 index.js
> [email protected]
(node:19224) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> Fetching base Node.js binaries to PKG_CACHE_PATH
  fetched-v18.20.4-linuxstatic-x64    [====================] 100%

  fetched-v18.20.4-linux-x64          [====================] 100%
rob:~/projects/yao-pkg-linuxstatic-arm64-bug$ npx pkg -o index -t node16-linuxstatic-x64 index.js
> [email protected]
(node:19261) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
> Fetching base Node.js binaries to PKG_CACHE_PATH
  fetched-v16.20.2-linuxstatic-x64    [====================] 100%

  fetched-v16.20.2-linux-x64          [====================] 100%

@robertsLando
Copy link
Member

@robvanderleek I actually have no time to look at this issue but I suggest to try debug it to see if you are able to find the root cause of the issue, aboce I linked you the code that makes the bytecode, try to put some breakpoints there to see what's the line that triggers that issue

@thisjt
Copy link

thisjt commented Sep 30, 2024

I'm able to replicate the issue in WSL (Ubuntu). This might be useful, I think.

image

I still have no idea where this Syntax error: "(" unexpected is coming from, as on my debug I think this is run asynchronously somewhere.

@robertsLando
Copy link
Member

robertsLando commented Oct 1, 2024

That comes from fabricator fabricate method that spaws the script you find on top to create the bytecode of the file

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

No branches or pull requests

3 participants