[Pkg-javascript-devel] Bug#996195: nodejs FTCBFS: uses build architecture build tools such as gcc or pkg-config

Helmut Grohne helmut at subdivi.de
Tue Oct 12 06:28:03 BST 2021


Source: nodejs
Version: 12.22.5~dfsg-6
Tags: patch
User: debian-cross at lists.debian.org
Usertags: ftcbfs

nodejs fails to cross build from source, because its configure.py
detects build architecture build tools such as gcc or pkg-config without
the relevant host architecture prefix. (Do note that I'm using the gnu
terminology also used in man dpkg-architecture here and that nodejs
seems to be using a confusing mix of terminology.) It seems that
configure.py expects that you export standard environment variables such
as CC or PKG_CONFIG. The attached patch implements that.

Unfortunately, it does not make nodejs cross buildable. A build then
fails running gen-regexp-special-case with an "Exec format error", which
typically means that the binary was compiled for the host architecture
but needed for the build architecture.

I researched this a bit and noticed that other cross distributions have
run into the same problem.
PtxDist: https://lore.ptxdist.org/ptxdist/20200113101809.3260-1-b.esser@pengutronix.de/
buildroot: https://github.com/buildroot/buildroot/blob/master/package/nodejs/nodejs.mk


In essence what they do is build nodejs twice. Once for the build
architecture. Then they steal the relevant tools from that build tree
and patch the build system to use those other tools. Likely Debian
should do the same (or upstream should gain a sane solution here). I
attempted doing this, but my native build for some reason didn't emit
gen-regexp-special-cases. At that point, I gave up on this.

While looking into this, I also noticed that you make the build
non-parallel when building for a 32bit architecture. Is the intention
really to make a cross build on amd64 for armhf non-parallel and leaving
a cross build from on say mips for riscv64 parallel? I guess that you do
mean the build architecture here.

Please consider applying the attached patch to fix the obvious. At that
point, please close the bug regardless of the other mentioned issues.

Helmut
-------------- next part --------------
diff --minimal -Nru nodejs-12.22.5~dfsg/debian/changelog nodejs-12.22.5~dfsg/debian/changelog
--- nodejs-12.22.5~dfsg/debian/changelog	2021-10-10 10:48:05.000000000 +0200
+++ nodejs-12.22.5~dfsg/debian/changelog	2021-10-11 10:03:16.000000000 +0200
@@ -1,3 +1,10 @@
+nodejs (12.22.5~dfsg-6.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Improve cross building: Use host tools. (Closes: #-1)
+
+ -- Helmut Grohne <helmut at subdivi.de>  Mon, 11 Oct 2021 10:03:16 +0200
+
 nodejs (12.22.5~dfsg-6) unstable; urgency=medium
 
   * Team upload
diff --minimal -Nru nodejs-12.22.5~dfsg/debian/rules nodejs-12.22.5~dfsg/debian/rules
--- nodejs-12.22.5~dfsg/debian/rules	2021-10-10 10:43:51.000000000 +0200
+++ nodejs-12.22.5~dfsg/debian/rules	2021-10-11 10:03:16.000000000 +0200
@@ -1,6 +1,8 @@
 #!/usr/bin/make -f
 
+include /usr/share/dpkg/architecture.mk
 include /usr/share/dpkg/pkg-info.mk
+include /usr/share/dpkg/buildtools.mk
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie
 
 # source equivalent of nodejs -e 'console.log(process.versions.modules)'
@@ -199,7 +201,7 @@
 	find debian/nodejs-doc/usr/share/doc/nodejs-doc -name *.json -delete || true
 
 override_dh_auto_configure:
-	./configure $(DEB_CONFIGURE_EXTRA_FLAGS)
+	CC=$(CC) CXX=$(CXX) PKG_CONFIG=$(PKG_CONFIG) ./configure $(DEB_CONFIGURE_EXTRA_FLAGS)
 
 override_dh_auto_build-arch:
 	mkdir -p $(NODE_TEST_DIR)


More information about the Pkg-javascript-devel mailing list