Source: quickjs
Version: 2025.04.26-1
Tags: patch
User: [email protected]
Usertags: ftcbfs

quickjs fails to cross build from source, because it passes host
architecture compiler flags to the build architecture compiler. Before
we go deeper let me point out that the Debian (and GNU) terminology does
not line up with the terminology used by the upstream project. What
Debian calls "host", does not bear a name or prefix at the upstream
project and what Debian calls "build" is called "host" upstream.

While the upstream Makefile already distinguishes those two compiler
executables, it does not yet distinguish the compiler and linker flags
passed to either of them yet. Since Debian passes architecture-dependent
flags (e.g. for amd64 and arm64), this now fails. I propose adding new
variables (HOST_CFLAGS and HOST_LDFLAGS matching the upstream
terminology) and providing them from the packaging to achieve proper
separation.

Please find a patch attached for your convenience and consider
upstreaming the contained cross.patch file.

Helmut
diff -Nru quickjs-2025.04.26/debian/changelog 
quickjs-2025.04.26/debian/changelog
--- quickjs-2025.04.26/debian/changelog 2025-05-03 17:18:27.000000000 +0200
+++ quickjs-2025.04.26/debian/changelog 2026-01-12 11:51:58.000000000 +0100
@@ -1,3 +1,10 @@
+quickjs (2025.04.26-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: Don't pass host flags to a build compiler. (Closes: #-1)
+
+ -- Helmut Grohne <[email protected]>  Mon, 12 Jan 2026 11:51:58 +0100
+
 quickjs (2025.04.26-1) unstable; urgency=medium
 
   * new upstream version
diff -Nru quickjs-2025.04.26/debian/patches/cross.patch 
quickjs-2025.04.26/debian/patches/cross.patch
--- quickjs-2025.04.26/debian/patches/cross.patch       1970-01-01 
01:00:00.000000000 +0100
+++ quickjs-2025.04.26/debian/patches/cross.patch       2026-01-12 
11:51:58.000000000 +0100
@@ -0,0 +1,31 @@
+--- quickjs-2025.04.26.orig/Makefile
++++ quickjs-2025.04.26/Makefile
+@@ -187,6 +187,10 @@
+ LDEXPORT=-rdynamic
+ endif
+ 
++HOST_CFLAGS ?= $(CFLAGS)
++HOST_CFLAGS += $(DEFINES)
++HOST_LDFLAGS ?= $(LDFLAGS)
++
+ ifndef CONFIG_COSMO
+ ifndef CONFIG_DARWIN
+ CONFIG_SHARED_LIBS=y # building shared libraries is supported
+@@ -267,7 +271,7 @@
+ 
+ $(QJSC): $(OBJDIR)/qjsc.host.o \
+     $(patsubst %.o, %.host.o, $(QJS_LIB_OBJS))
+-      $(HOST_CC) $(LDFLAGS) -o $@ $^ $(HOST_LIBS)
++      $(HOST_CC) $(HOST_LDFLAGS) -o $@ $^ $(HOST_LIBS)
+ 
+ endif #CROSS_PREFIX
+ 
+@@ -322,7 +326,7 @@
+       $(CC) $(CFLAGS_OPT) -c -I. -o $@ $<
+ 
+ $(OBJDIR)/%.host.o: %.c | $(OBJDIR)
+-      $(HOST_CC) $(CFLAGS_OPT) -c -o $@ $<
++      $(HOST_CC) $(HOST_CFLAGS) -c -o $@ $<
+ 
+ $(OBJDIR)/%.pic.o: %.c | $(OBJDIR)
+       $(CC) $(CFLAGS_OPT) -fPIC -DJS_SHARED_LIBRARY -c -o $@ $<
diff -Nru quickjs-2025.04.26/debian/patches/series 
quickjs-2025.04.26/debian/patches/series
--- quickjs-2025.04.26/debian/patches/series    2025-05-03 17:18:27.000000000 
+0200
+++ quickjs-2025.04.26/debian/patches/series    2026-01-12 11:47:34.000000000 
+0100
@@ -1,2 +1,3 @@
 enable_multiarch_build
 fix_armel_build
+cross.patch
diff -Nru quickjs-2025.04.26/debian/rules quickjs-2025.04.26/debian/rules
--- quickjs-2025.04.26/debian/rules     2025-05-03 17:18:27.000000000 +0200
+++ quickjs-2025.04.26/debian/rules     2026-01-12 11:51:58.000000000 +0100
@@ -12,6 +12,8 @@
 
 # the Makefile uses the cross-prefix in a non-standard way, so "enforce" it:
 export CROSS_PREFIX=$(DEB_HOST_GNU_TYPE)-
+export HOST_LDFLAGS=$(LDFLAGS_FOR_BUILD)
+export HOST_CFLAGS=$(CFLAGS_FOR_BUILD)
 
 %:
        dh $@

Reply via email to