Source: arj
Version: 3.10.22-27
Tags: patch
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

arj fails to cross build from source, because it passes host
architecture (e.g. arm64) compiler flags (e.g.
-mbranch-protection=standard) to the build architecture (e.g. amd64)
compiler and that doesn't work. I'm attaching a patch for your
convenience the separates CPPFLAGS and CFLAGS into the _FOR_BUILD
variants as is done for the compiler itself already.

Helmut
diff --minimal -Nru arj-3.10.22/debian/changelog arj-3.10.22/debian/changelog
--- arj-3.10.22/debian/changelog        2024-03-12 05:46:21.000000000 +0100
+++ arj-3.10.22/debian/changelog        2024-10-01 19:17:04.000000000 +0200
@@ -1,3 +1,10 @@
+arj (3.10.22-27.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Fix FTCBFS: Properly separate compiler flags for build and host. (Closes: 
#-1)
+
+ -- Helmut Grohne <hel...@subdivi.de>  Tue, 01 Oct 2024 19:17:04 +0200
+
 arj (3.10.22-27) unstable; urgency=medium
 
   * Wrap fields in debian/tests/control.
diff --minimal -Nru arj-3.10.22/debian/patches/cross.patch 
arj-3.10.22/debian/patches/cross.patch
--- arj-3.10.22/debian/patches/cross.patch      1970-01-01 01:00:00.000000000 
+0100
+++ arj-3.10.22/debian/patches/cross.patch      2024-10-01 19:17:04.000000000 
+0200
@@ -0,0 +1,117 @@
+--- arj-3.10.22.orig/gnu/makefile.in
++++ arj-3.10.22/gnu/makefile.in
+@@ -43,6 +43,8 @@
+ 
+ ALL_CFLAGS = -DLOCALE=LANG_$(LOCALE) -DLOCALE_DESC="\"$(LOCALE)\"" \
+            -DPKGLIBDIR="\"$(pkglibdir)\"" @OS_DEF@
++ALL_CFLAGS_FOR_BUILD = -DLOCALE=LANG_$(LOCALE) -DLOCALE_DESC="\"$(LOCALE)\"" \
++           -DPKGLIBDIR="\"$(pkglibdir)\"" @OS_DEF_FOR_BUILD@
+ 
+ ifndef COMMERCIAL
+ PACKAGE = s
+@@ -67,6 +69,7 @@
+ ARJ_TIMESTAMP = $(shell TZ=UTC0 date -d '@$(SOURCE_DATE_EPOCH)' '+%Y%m%d%H%S')
+ 
+ ALL_CFLAGS += @CPPFLAGS@ $(CPPFLAGS) @CFLAGS@ $(CFLAGS)
++ALL_CFLAGS_FOR_BUILD += $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
+ 
+ # Build Installation paths
+ 
+@@ -98,8 +101,11 @@
+ REQUIRES_DEF = @REQUIRES_DEF@
+ 
+ COPT = -c -I@OUT_DIR@ -I$(BASEDIR) -I$(SRC_DIR) $(ALL_CFLAGS)
++COPT_FOR_BUILD = -c -I@OUT_DIR@ -I$(BASEDIR) -I$(SRC_DIR) 
$(ALL_CFLAGS_FOR_BUILD)
+ STD_COPT = -DARJUTIL $(COPT)
++STD_COPT_FOR_BUILD = -DARJUTIL $(COPT_FOR_BUILD)
+ ARJ_COPT = -DSFL=4 $(COPT)
++ARJ_COPT_FOR_BUILD = -DSFL=4 $(COPT_FOR_BUILD)
+ ARJSFXV_COPT = -DSFL=3 $(COPT)
+ ARJSFX_COPT = -DSFL=2 $(COPT)
+ ARJSFXJR_COPT = -DSFL=1 $(COPT)
+@@ -116,7 +122,7 @@
+ 
+ ifdef CROSS_BUILDING
+ $(ARJ_FOR_BUILD_DIR)/%.o: $(BASEDIR)/%.c
+-      $(CC_FOR_BUILD) $(COPT) -o$@ $<
++      $(CC_FOR_BUILD) $(COPT_FOR_BUILD) -o$@ $<
+ endif
+ 
+ $(ARJSFX_DIR)/%.o: $(BASEDIR)/%.c
+@@ -144,14 +150,14 @@
+       $(CC) $(COPT) -o$@ $<
+ 
+ $(TOOLS_DIR)/%.o: $(SRC_DIR)/%.c
+-      $(CC_FOR_BUILD) $(STD_COPT) -o$@ $<
++      $(CC_FOR_BUILD) $(STD_COPT_FOR_BUILD) -o$@ $<
+ 
+ $(ARJ_DIR)/%.o: $(SRC_DIR)/%.c
+       $(CC) $(ARJ_COPT) -o$@ $<
+ 
+ ifdef CROSS_BUILDING
+ $(ARJ_FOR_BUILD_DIR)/%.o: $(SRC_DIR)/%.c
+-      $(CC_FOR_BUILD) $(ARJ_COPT) -o$@ $<
++      $(CC_FOR_BUILD) $(ARJ_COPT_FOR_BUILD) -o$@ $<
+ endif
+ 
+ $(ARJSFXV_DIR)/%.o: $(SRC_DIR)/%.c
+@@ -243,19 +249,19 @@
+               filemode.o packager.o arjdata.o)
+ 
+ $(TOOLS_DIR)/msgbind$x: $(MSGBIND_OBJS)
+-      $(CC_FOR_BUILD) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(MSGBIND_OBJS) $(LIBS)
++      $(CC_FOR_BUILD) $(ALL_CFLAGS_FOR_BUILD) $(LDFLAGS) -o $@ 
$(MSGBIND_OBJS) $(LIBS)
+ 
+ $(TOOLS_DIR)/make_key$x: $(MAKE_KEY_OBJS)
+-      $(CC_FOR_BUILD) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(MAKE_KEY_OBJS) $(LIBS)
++      $(CC_FOR_BUILD) $(ALL_CFLAGS_FOR_BUILD) $(LDFLAGS) -o $@ 
$(MAKE_KEY_OBJS) $(LIBS)
+ 
+ $(TOOLS_DIR)/postproc$x: $(POSTPROC_OBJS)
+-      $(CC_FOR_BUILD) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(POSTPROC_OBJS) $(LIBS)
++      $(CC_FOR_BUILD) $(ALL_CFLAGS_FOR_BUILD) $(LDFLAGS) -o $@ 
$(POSTPROC_OBJS) $(LIBS)
+ 
+ $(TOOLS_DIR)/join$x: $(JOIN_OBJS)
+-      $(CC_FOR_BUILD) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JOIN_OBJS) $(LIBS)
++      $(CC_FOR_BUILD) $(ALL_CFLAGS_FOR_BUILD) $(LDFLAGS) -o $@ $(JOIN_OBJS) 
$(LIBS)
+ 
+ $(TOOLS_DIR)/packager$x: $(PACKAGER_OBJS)
+-      $(CC_FOR_BUILD) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(PACKAGER_OBJS) $(LIBS)
++      $(CC_FOR_BUILD) $(ALL_CFLAGS_FOR_BUILD) $(LDFLAGS) -o $@ 
$(PACKAGER_OBJS) $(LIBS)
+ 
+ # And this one explicitly specifies that chk_fmsg depends on individual files
+ $(ARJ_DIR)/chk_fmsg.o: $(SRC_DIR)/chk_fmsg.c $(BASEDIR)/fmsg_arj.c
+@@ -372,7 +378,7 @@
+ ARJ_FOR_BUILD_DEP = $(ARJ_FOR_BUILD_PROG)
+ 
+ $(ARJ_FOR_BUILD_DIR)/arj$x: $(ARJ_FOR_BUILD_OBJS)
+-      $(CC_FOR_BUILD) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(ARJ_FOR_BUILD_OBJS) 
$(LIBS) $(DYN_LIBS)
++      $(CC_FOR_BUILD) $(ALL_CFLAGS_FOR_BUILD) $(LDFLAGS) -o $@ 
$(ARJ_FOR_BUILD_OBJS) $(LIBS) $(DYN_LIBS)
+ else
+ ARJ_FOR_BUILD_PROG = $(ARJ_DIR)/arj$x
+ endif
+--- arj-3.10.22.orig/gnu/configure.in
++++ arj-3.10.22/gnu/configure.in
+@@ -97,6 +97,15 @@
+       ;;
+ esac
+ 
++OS_DEF_FOR_BUILD="-D_UNIX"
++case $build_os in
++gnu*|linux*|*bsd*|interix3*|*qnx*|*solaris*)
++      ;;
++os2*)
++      OS_DEF_FOR_BUILD="-D_OS2"
++      ;;
++esac
++
+ case $host_cpu in
+ alpha*)
+       AC_DEFINE(ALIGN_POINTERS, 1, [Define if pointers need to be aligned])
+@@ -198,6 +207,7 @@
+ AC_SUBST(REQUIRES_DEF)
+ AC_SUBST(OS_ID)
+ AC_SUBST(OS_DEF)
++AC_SUBST(OS_DEF_FOR_BUILD)
+ AC_SUBST(LIBS)
+ AC_SUBST(DYN_LIBS)
+ AC_SUBST(LD_STRIP)
diff --minimal -Nru arj-3.10.22/debian/patches/series 
arj-3.10.22/debian/patches/series
--- arj-3.10.22/debian/patches/series   2024-03-12 05:38:26.000000000 +0100
+++ arj-3.10.22/debian/patches/series   2024-10-01 19:08:03.000000000 +0200
@@ -22,3 +22,4 @@
 fix-time_t-usage.patch
 gnu_build_fix_autoreconf.patch
 fix-implicit-func.patch
+cross.patch
diff --minimal -Nru arj-3.10.22/debian/rules arj-3.10.22/debian/rules
--- arj-3.10.22/debian/rules    2024-03-11 14:07:34.000000000 +0100
+++ arj-3.10.22/debian/rules    2024-10-01 19:17:04.000000000 +0200
@@ -5,7 +5,9 @@
 
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all abi=+lfs
 export DEB_CPPFLAGS_MAINT_APPEND = -D_GNU_SOURCE=1
+export DEB_CPPFLAGS_FOR_BUILD_MAINT_APPEND = -D_GNU_SOURCE=1
 export DEB_CFLAGS_MAINT_APPEND = -Wall
+export DEB_CFLAGS_FOR_BUILD_MAINT_APPEND = -Wall
 
 include /usr/share/dpkg/default.mk
 

Reply via email to