[Pkg-javascript-devel] Bug#1057298: nodejs: improve passing of --dest-* options for cross builds

Helmut Grohne helmut at subdivi.de
Sat Dec 2 21:05:28 GMT 2023


Source: nodejs
Version: 18.19.0+dfsg-3
Tags: patch
User: debian-cross at lists.debian.org
Usertags: ftcbfs

Hi,

I can see that quite some effort went into cross build support for
nodejs. Thank you. Unfortunately, it doesn't quite just work.

For one thing, doing a cross build without --dest-os or --dest-cpu is
doomed to fail in surprising ways. Hence, the build should fail when
they are missing (for cross builds only). Then the computation of their
values is subtly wrong:
 * There is no Debian architecture named aarch64.
 * Prefer matching of DEB_HOST_ARCH_CPU over DEB_HOST_ARCH to avoid
   repeating cases for different kernels.
 * Increase coverage for loong64, ppc64el and s390.
 * Simplify matching when DEB_HOST_ARCH_CPU is what --dest-cpu wants.

This moves quite some cases further, but in the end it does not make
nodejs cross buildable for any architecture I tried. The issues are
strange and I have no solutions at this time. While this bug is about
passing of --dest-os and --dest-cpu and I ask you to close it when
addressing that aspect, I'll also go into some detail on what goes wrong
next:

 * arm64: Somehow manages to pass arm64-specific compiler options to a
   build architecture compiler. Not sure how they escaped.
 * armel/armhf: Very strange failure about missing header
   "bits/libc-header-start.h".
 * s390x: deps/v8/src/execution/s390/simulator-s390.cc uses bare isnan
   and signbit. gcc suggests you may want to be using std::isnan and
   std::signbit here. Not sure why this works in native builds.

The s390x one looks fixable at least. In any case, I'm attaching a patch
for the debian/rules aspects that I understand well and hope you agree
with it.

Helmut
-------------- next part --------------
diff --minimal -Nru nodejs-18.19.0+dfsg/debian/changelog nodejs-18.19.0+dfsg/debian/changelog
--- nodejs-18.19.0+dfsg/debian/changelog	2023-12-02 02:12:25.000000000 +0100
+++ nodejs-18.19.0+dfsg/debian/changelog	2023-12-02 19:10:51.000000000 +0100
@@ -1,3 +1,10 @@
+nodejs (18.19.0+dfsg-3.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Improve passing of --dest-* options. (Closes: #-1)
+
+ -- Helmut Grohne <helmut at subdivi.de>  Sat, 02 Dec 2023 19:10:51 +0100
+
 nodejs (18.19.0+dfsg-3) unstable; urgency=medium
 
   * patch: drop fixed openssl test patch
diff --minimal -Nru nodejs-18.19.0+dfsg/debian/rules nodejs-18.19.0+dfsg/debian/rules
--- nodejs-18.19.0+dfsg/debian/rules	2023-11-30 16:59:46.000000000 +0100
+++ nodejs-18.19.0+dfsg/debian/rules	2023-12-02 19:10:51.000000000 +0100
@@ -50,23 +50,13 @@
 # map HOST ARCH AND OS, and if unknown let upstream guess
 
 destCpu =
-destCpu := $(or $(destCpu),$(if $(filter i386,$(DEB_HOST_ARCH)),ia32))
-destCpu := $(or $(destCpu),$(if $(filter x32,$(DEB_HOST_ARCH)),x32))
-destCpu := $(or $(destCpu),$(if $(filter kfreebsd-i386,$(DEB_HOST_ARCH)),ia32))
-destCpu := $(or $(destCpu),$(if $(filter hurd-i386,$(DEB_HOST_ARCH)),ia32))
-destCpu := $(or $(destCpu),$(if $(filter amd64,$(DEB_HOST_ARCH)),x64))
-destCpu := $(or $(destCpu),$(if $(filter kfreebsd-amd64,$(DEB_HOST_ARCH)),x64))
-destCpu := $(or $(destCpu),$(if $(filter armel,$(DEB_HOST_ARCH)),arm))
-destCpu := $(or $(destCpu),$(if $(filter armhf,$(DEB_HOST_ARCH)),arm))
-destCpu := $(or $(destCpu),$(if $(filter aarch64,$(DEB_HOST_ARCH)),arm64))
-destCpu := $(or $(destCpu),$(if $(filter mipsel,$(DEB_HOST_ARCH)),mipsel))
-destCpu := $(or $(destCpu),$(if $(filter mips64el,$(DEB_HOST_ARCH)),mips64el))
-destCpu := $(or $(destCpu),$(if $(filter mips64r6el,$(DEB_HOST_ARCH)),mips64el))
-destCpu := $(or $(destCpu),$(if $(filter mips,$(DEB_HOST_ARCH)),mips))
-destCpu := $(or $(destCpu),$(if $(filter powerpc,$(DEB_HOST_ARCH)),ppc))
-destCpu := $(or $(destCpu),$(if $(filter ppc64,$(DEB_HOST_ARCH)),ppc64))
-destCpu := $(or $(destCpu),$(if $(filter riscv64,$(DEB_HOST_ARCH)),riscv64))
-destCpu := $(or $(destCpu),$(if $(filter s390x,$(DEB_HOST_ARCH)),s390x))
+destCpu := $(or $(destCpu),$(if $(filter i386,$(DEB_HOST_ARCH_CPU)),ia32))
+destCpu := $(or $(destCpu),$(if $(filter amd64_32,$(DEB_HOST_ARCH_CPU)_$(DEB_HOST_ARCH_BITS)),x32))
+destCpu := $(or $(destCpu),$(if $(filter amd64,$(DEB_HOST_ARCH_CPU)),x64))
+destCpu := $(or $(destCpu),$(if $(filter mips64r6el,$(DEB_HOST_ARCH_CPU)),mips64el))
+destCpu := $(or $(destCpu),$(if $(filter powerpc,$(DEB_HOST_ARCH_CPU)),ppc))
+destCpu := $(or $(destCpu),$(if $(filter ppc64el,$(DEB_HOST_ARCH_CPU)),ppc64))
+destCpu := $(or $(destCpu),$(filter arm arm64 loong64 mipsel mips64el mips ppc64 riscv64 s390 s390x,$(DEB_HOST_ARCH_CPU)))
 
 # solaris freebsd openbsd linux
 destOs =
@@ -75,12 +65,20 @@
 
 ifneq (, $(destOs))
 DEB_CONFIGURE_EXTRA_FLAGS += --dest-os=$(destOs)
+else
+ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+$(error "unknown --dest-os for cross compiling nodejs to $(DEB_HOST_ARCH)")
+endif
 endif
 ifeq (unsupported, $(destCpu))
 $(error "nodejs cannot run on $(DEB_HOST_ARCH), please consult maintainers")
 endif
 ifneq (, $(destCpu))
 DEB_CONFIGURE_EXTRA_FLAGS += --dest-cpu=$(destCpu)
+else
+ifneq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
+$(error "unknown --dest-cpu for cross compiling nodejs to $(DEB_HOST_ARCH)")
+endif
 endif
 
 ifeq (freebsd, $(destOs))


More information about the Pkg-javascript-devel mailing list