aspect-build / aspect-build/rules_js

[Bug]: js_binary launcher script not portable from host to exec platform

Open
#1,168 7 comments 5 reactions 0 assignees View on GitHub
bug need: investigation
Dominant language
Starlark
Stars
378
Forks
183
Avg merge
1d 9h
Merged PRs (30d)
32

Description

### What happened?

When RBE is used for cross-compilation, the host platform may be different from the exec platform.

In my case I have a linux_x86 host platform, so the launcher created by `ctx.actions.expand_template` here https://github.com/aspect-build/rules_js/blob/92a36f314b7841475e12a68dcd018c088f373bc2/js/private/js_binary.bzl#L481-L486
will create a file with a node path pointing to the host-resolved toolchain, with linux_x86 arch.

Now, I enable RBE and the `exec` platform is linux_arm64`. The launcher script is copied to the remote and tries to spawn node for the wrong arch, which of course fails with executable format error `cannot execute binary file ...nodejs_linux_amd64...`

### Version

Bazel 6.2.1, latest of rules_js

### How to reproduce

```shell
Tricky since you need an RBE setup with alternate architecture.
```

### Any other information?

_No response_

Contributor guide

Open the contributing guide

Research direction

Read js/private/js_binary.bzl at lines 481-486, then investigate the launcher generated by ctx.actions.expand_template under an RBE setup with different host and exec architectures. Done means the launcher selects a node executable suitable for the exec platform and no longer fails with an executable format error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.