diff mbox series

[03/13] nodejs: remove v8-qemu-wrapper stuff

Message ID 20220809075704.86472-4-ardeleanalex@gmail.com
State Changes Requested
Headers show
Series package/nodejs: rework cross-building | expand

Commit Message

Alexandru Ardelean Aug. 9, 2022, 7:56 a.m. UTC
It's pretty broken, so we won't use it.

Even with this wrapper, I get:
```
debug-wasm-objects.tq src/wasm/wasm-objects.tq
/bin/sh: 1: ../../out/Release/torque: Exec format error
[324/2786] CXX obj/src/libnode.node_wasi.o
ninja: build stopped: subcommand failed.
make[2]: *** [Makefile:127: node] Error 1
```

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
---
 .../0001-add-qemu-wrapper-support.patch       | 88 -------------------
 package/nodejs/Config.in.host                 |  2 -
 package/nodejs/nodejs.mk                      | 32 -------
 package/nodejs/v8-qemu-wrapper.in             |  9 --
 4 files changed, 131 deletions(-)
 delete mode 100644 package/nodejs/0001-add-qemu-wrapper-support.patch
 delete mode 100644 package/nodejs/v8-qemu-wrapper.in

Comments

Thomas Petazzoni Aug. 9, 2022, 11:49 a.m. UTC | #1
Hello,

On Tue,  9 Aug 2022 10:56:54 +0300
Alexandru Ardelean <ardeleanalex@gmail.com> wrote:

> It's pretty broken, so we won't use it.
> 
> Even with this wrapper, I get:
> ```
> debug-wasm-objects.tq src/wasm/wasm-objects.tq
> /bin/sh: 1: ../../out/Release/torque: Exec format error
> [324/2786] CXX obj/src/libnode.node_wasi.o
> ninja: build stopped: subcommand failed.
> make[2]: *** [Makefile:127: node] Error 1

This is odd. Did you debug this a bit?

On my side, trying to build:

BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_AARCH64_GLIBC_STABLE=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_NODEJS=y
# BR2_TARGET_ROOTFS_TAR is not set

before applying your patch series, leads to a different error:

ninja: error: obj.host/tools/v8_gypfiles/run_torque.ninja:1271: multiple rules generate gen/torque-generated/bit-fields.h [-w dupbuild=err]

The issue was reported at https://github.com/nodejs/node/issues/37441 a
while ago, it is not fixed apparently.

Best regards,

Thomas
Alexandru Ardelean Aug. 9, 2022, 12:52 p.m. UTC | #2
On Tue, Aug 9, 2022 at 2:49 PM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello,
>
> On Tue,  9 Aug 2022 10:56:54 +0300
> Alexandru Ardelean <ardeleanalex@gmail.com> wrote:
>
> > It's pretty broken, so we won't use it.
> >
> > Even with this wrapper, I get:
> > ```
> > debug-wasm-objects.tq src/wasm/wasm-objects.tq
> > /bin/sh: 1: ../../out/Release/torque: Exec format error
> > [324/2786] CXX obj/src/libnode.node_wasi.o
> > ninja: build stopped: subcommand failed.
> > make[2]: *** [Makefile:127: node] Error 1
>
> This is odd. Did you debug this a bit?

not really, no
i can try again
but the error is so weird, that it discouraged me to check;

>
> On my side, trying to build:
>
> BR2_aarch64=y
> BR2_TOOLCHAIN_EXTERNAL=y
> BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
> BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_AARCH64_GLIBC_STABLE=y
> BR2_INIT_NONE=y
> BR2_SYSTEM_BIN_SH_NONE=y
> # BR2_PACKAGE_BUSYBOX is not set
> BR2_PACKAGE_NODEJS=y
> # BR2_TARGET_ROOTFS_TAR is not set
>
> before applying your patch series, leads to a different error:
>
> ninja: error: obj.host/tools/v8_gypfiles/run_torque.ninja:1271: multiple rules generate gen/torque-generated/bit-fields.h [-w dupbuild=err]

i think this is fixed in patch [4/13]:

https://patchwork.ozlabs.org/project/buildroot/patch/20220809075704.86472-5-ardeleanalex@gmail.com/

apologies if the patches are not quite in the proper order yet;
i can try to make the order better, so as to keep the principle that
each patch doesn't break stuff as much as possible;


>
> The issue was reported at https://github.com/nodejs/node/issues/37441 a
> while ago, it is not fixed apparently.
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, co-owner and CEO, Bootlin
> Embedded Linux and Kernel engineering and training
> https://bootlin.com
diff mbox series

Patch

diff --git a/package/nodejs/0001-add-qemu-wrapper-support.patch b/package/nodejs/0001-add-qemu-wrapper-support.patch
deleted file mode 100644
index 1368ca5a38..0000000000
--- a/package/nodejs/0001-add-qemu-wrapper-support.patch
+++ /dev/null
@@ -1,88 +0,0 @@ 
-From fa09fa3ad6a21ae0b35fb860f76d1762e5f29972 Mon Sep 17 00:00:00 2001
-From: Adam Duskett <aduskett@gmail.com>
-Date: Mon, 27 Sep 2021 12:55:09 -0700
-Subject: [PATCH] add qemu-wrapper support
-
-V8's JIT infrastructure requires binaries such as mksnapshot and mkpeephole to
-be run in the host during the build. However, these binaries must have the
-same bit-width as the target (e.g. a x86_64 host targeting ARMv6 needs to
-produce a 32-bit binary). To work around this issue, cross-compile the
-binaries for the target and run them on the host with QEMU, much like
-gobject-introspection.
-
-However, for the host-variant we do not want to use a
-qemu-wrapper, so add @MAYBE_WRAPPER@ to the needed files and sed the path to
-the qemu-wrapper on target builds, and remove @MAYBE_WRAPPER@ entirely on
-host-builds.
-
-Signed-off-by: Adam Duskett <aduskett@gmail.com>
----
- node.gyp                 | 4 ++--
- tools/v8_gypfiles/v8.gyp | 8 ++++----
- 2 files changed, 6 insertions(+), 6 deletions(-)
-
-diff --git a/node.gyp b/node.gyp
-index 8ba0dfeb..c77f6f7d 100644
---- a/node.gyp
-+++ b/node.gyp
-@@ -491,7 +491,7 @@
-               'action_name': 'run_mkcodecache',
-               'process_outputs_as_sources': 1,
-               'inputs': [
--                '<(mkcodecache_exec)',
-+                @MAYBE_WRAPPER@ '<(mkcodecache_exec)',
-               ],
-               'outputs': [
-                 '<(SHARED_INTERMEDIATE_DIR)/node_code_cache.cc',
-@@ -516,7 +516,7 @@
-               'action_name': 'node_mksnapshot',
-               'process_outputs_as_sources': 1,
-               'inputs': [
--                '<(node_mksnapshot_exec)',
-+                @MAYBE_WRAPPER@ '<(node_mksnapshot_exec)',
-               ],
-               'outputs': [
-                 '<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc',
-diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp
-index 48ec392b..f9bb0fbe 100644
---- a/tools/v8_gypfiles/v8.gyp
-+++ b/tools/v8_gypfiles/v8.gyp
-@@ -220,7 +220,7 @@
-         {
-           'action_name': 'run_torque_action',
-           'inputs': [  # Order matters.
--            '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)torque<(EXECUTABLE_SUFFIX)',
-+            @MAYBE_WRAPPER@ '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)torque<(EXECUTABLE_SUFFIX)',
-             '<@(torque_files)',
-           ],
-           'outputs': [
-@@ -351,7 +351,7 @@
-         {
-           'action_name': 'generate_bytecode_builtins_list_action',
-           'inputs': [
--            '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)bytecode_builtins_list_generator<(EXECUTABLE_SUFFIX)',
-+            @MAYBE_WRAPPER@ '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)bytecode_builtins_list_generator<(EXECUTABLE_SUFFIX)',
-           ],
-           'outputs': [
-             '<(generate_bytecode_builtins_list_output)',
-@@ -533,7 +533,7 @@
-             ],
-           },
-           'inputs': [
--            '<(mksnapshot_exec)',
-+            @MAYBE_WRAPPER@ '<(mksnapshot_exec)',
-           ],
-           'outputs': [
-             '<(INTERMEDIATE_DIR)/snapshot.cc',
-@@ -1448,7 +1448,7 @@
-         {
-           'action_name': 'run_gen-regexp-special-case_action',
-           'inputs': [
--            '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)gen-regexp-special-case<(EXECUTABLE_SUFFIX)',
-+            @MAYBE_WRAPPER@ '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)gen-regexp-special-case<(EXECUTABLE_SUFFIX)',
-           ],
-           'outputs': [
-             '<(SHARED_INTERMEDIATE_DIR)/src/regexp/special-case.cc',
---
-2.31.1
-
diff --git a/package/nodejs/Config.in.host b/package/nodejs/Config.in.host
index 4ceaf0c73e..d023ffc36d 100644
--- a/package/nodejs/Config.in.host
+++ b/package/nodejs/Config.in.host
@@ -5,8 +5,6 @@  config BR2_PACKAGE_HOST_NODEJS
 	select BR2_PACKAGE_HOST_PYTHON3
 	select BR2_PACKAGE_HOST_PYTHON3_BZIP2
 	select BR2_PACKAGE_HOST_PYTHON3_SSL
-	select BR2_PACKAGE_HOST_QEMU
-	select BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE
 	help
 	  Event-driven I/O server-side JavaScript environment based on
 	  V8.
diff --git a/package/nodejs/nodejs.mk b/package/nodejs/nodejs.mk
index 3154dcd7ec..a8229eb4b1 100644
--- a/package/nodejs/nodejs.mk
+++ b/package/nodejs/nodejs.mk
@@ -12,7 +12,6 @@  NODEJS_DEPENDENCIES = \
 	host-ninja \
 	host-pkgconf \
 	host-python3 \
-	host-qemu \
 	c-ares \
 	libuv \
 	nghttp2 \
@@ -174,37 +173,6 @@  ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
 NODEJS_LDFLAGS += -latomic
 endif
 
-# V8's JIT infrastructure requires binaries such as mksnapshot and
-# mkpeephole to be run in the host during the build. However, these
-# binaries must have the same bit-width as the target (e.g. a x86_64
-# host targeting ARMv6 needs to produce a 32-bit binary). To work around this
-# issue, cross-compile the binaries for the target and run them on the
-# host with QEMU, much like gobject-introspection.
-define NODEJS_INSTALL_V8_QEMU_WRAPPER
-	$(INSTALL) -D -m 755 $(NODEJS_PKGDIR)/v8-qemu-wrapper.in \
-		$(@D)/out/Release/v8-qemu-wrapper
-	$(SED) "s%@QEMU_USER@%$(QEMU_USER)%g" \
-		$(@D)/out/Release/v8-qemu-wrapper
-	$(SED) "s%@TOOLCHAIN_HEADERS_VERSION@%$(BR2_TOOLCHAIN_HEADERS_AT_LEAST)%g" \
-		$(@D)/out/Release/v8-qemu-wrapper
-	$(SED) "s%@QEMU_USERMODE_ARGS@%$(call qstrip,$(BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS))%g" \
-		$(@D)/out/Release/v8-qemu-wrapper
-endef
-NODEJS_PRE_CONFIGURE_HOOKS += NODEJS_INSTALL_V8_QEMU_WRAPPER
-
-define NODEJS_WRAPPER_FIXUP
-	$(SED) "s%@MAYBE_WRAPPER@%'<(PRODUCT_DIR)/v8-qemu-wrapper',%g" $(@D)/node.gyp
-	$(SED) "s%@MAYBE_WRAPPER@%'<(PRODUCT_DIR)/v8-qemu-wrapper',%g" $(@D)/tools/v8_gypfiles/v8.gyp
-endef
-NODEJS_PRE_CONFIGURE_HOOKS += NODEJS_WRAPPER_FIXUP
-
-# Do not run the qemu-wrapper for the host build.
-define HOST_NODEJS_WRAPPER_FIXUP
-	$(SED) "s%@MAYBE_WRAPPER@%%g" $(@D)/node.gyp
-	$(SED) "s%@MAYBE_WRAPPER@%%g" $(@D)/tools/v8_gypfiles/v8.gyp
-endef
-HOST_NODEJS_PRE_CONFIGURE_HOOKS += HOST_NODEJS_WRAPPER_FIXUP
-
 define NODEJS_CONFIGURE_CMDS
 	(cd $(@D); \
 		$(TARGET_CONFIGURE_OPTS) \
diff --git a/package/nodejs/v8-qemu-wrapper.in b/package/nodejs/v8-qemu-wrapper.in
deleted file mode 100644
index e1083f47f7..0000000000
--- a/package/nodejs/v8-qemu-wrapper.in
+++ /dev/null
@@ -1,9 +0,0 @@ 
-#!/usr/bin/env sh
-
-# Pass -r to qemu-user as to trick glibc into not errorings out if the host kernel
-# is older than the target kernel.
-exec @QEMU_USER@ -r @TOOLCHAIN_HEADERS_VERSION@ \
-    @QEMU_USERMODE_ARGS@ \
-   -L "${STAGING_DIR}/" \
-    "$@"
-