[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1116445: darknet FTCBFS: Multiple reasons



Source: darknet
Version: 0.0.0+git20180914.61c9d02e-3
Tags: patch
User: debian-cross@lists.debian.org
Usertags: ftcbfs
X-Debbugs-Cc: debian-cross@lists.debian.org, paulliu@debian.org

Dear Maintainer,

darknet fails to cross-build because

1. It has a builddep on python3 which seems to be used in clean rule. Since there
is no arch dependent behavior, it can be annotated with :native.

2. The patch in 0004-Enable-C-11-for-OpenCV-4 was hard-coding CPP=g++ -std=c++11
Instead this should be moved into a separate variable (CXXFLAGS or CPPFLAGS) instead
of modifying compiler variable.

It also uses CPP for g++ but it really should be CXX instead.

3. It hard-codes a bunch of things, CC, AR, pkg-config and so on which inturn do
not use the arch triplet prefixed paths that are passed during cross compilation.

I've fixed this in the patch attached with the mail. Please consider applying.

Thanks
Nilesh
From 263d9f0e4b68c81caa249d06dbe04546d97113c7 Mon Sep 17 00:00:00 2001
From: Nilesh Patra <nilesh@debian.org>
Date: Sat, 27 Sep 2025 17:00:14 +0530
Subject: [PATCH] cross

---
 debian/control                                |  2 +-
 .../0004-Enable-C-11-for-OpenCV-4.patch       | 29 +++++++-------
 debian/patches/cross.patch                    | 38 +++++++++++++++++++
 debian/patches/series                         |  1 +
 4 files changed, 56 insertions(+), 14 deletions(-)
 create mode 100644 debian/patches/cross.patch

diff --git a/debian/control b/debian/control
index 68e1040..fc8a6b7 100644
--- a/debian/control
+++ b/debian/control
@@ -6,7 +6,7 @@ Build-Depends: debhelper (>= 11),
                docbook-xsl,
                libopencv-dev (>= 4),
                pkgconf,
-               python3,
+               python3:native,
                xsltproc
 Standards-Version: 4.2.1
 Homepage: https://pjreddie.com/darknet/
diff --git a/debian/patches/0004-Enable-C-11-for-OpenCV-4.patch b/debian/patches/0004-Enable-C-11-for-OpenCV-4.patch
index dead7b0..8b6920c 100644
--- a/debian/patches/0004-Enable-C-11-for-OpenCV-4.patch
+++ b/debian/patches/0004-Enable-C-11-for-OpenCV-4.patch
@@ -7,19 +7,22 @@ Subject: [PATCH 4/5] Enable C++11 for OpenCV 4
  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
-diff --git a/Makefile b/Makefile
-index c148d4b..fa6edd5 100644
 --- a/Makefile
 +++ b/Makefile
-@@ -20,7 +20,7 @@ EXEC=darknet
- OBJDIR=./obj/
+@@ -28,6 +28,7 @@
+ LDFLAGS= -lm -pthread 
+ COMMON= -Iinclude/ -Isrc/
+ CFLAGS=-Wall -Wno-unused-result -Wno-unknown-pragmas -Wfatal-errors -fPIC
++CPPFLAGS=-std=c++11
  
- CC=gcc
--CPP=g++
-+CPP=g++ -std=c++11
- NVCC=nvcc 
- AR=ar
- ARFLAGS=rcs
--- 
-2.23.0
-
+ ifeq ($(OPENMP), 1) 
+ CFLAGS+= -fopenmp
+@@ -83,7 +84,7 @@
+ 	$(CC) $(CFLAGS) -shared $^ -o $@ $(LDFLAGS)
+ 
+ $(OBJDIR)%.o: %.cpp $(DEPS)
+-	$(CPP) $(COMMON) $(CFLAGS) -c $< -o $@
++	$(CPP) $(CPPFLAGS) $(COMMON) $(CFLAGS) -c $< -o $@
+ 
+ $(OBJDIR)%.o: %.c $(DEPS)
+ 	$(CC) $(COMMON) $(CFLAGS) -c $< -o $@
diff --git a/debian/patches/cross.patch b/debian/patches/cross.patch
new file mode 100644
index 0000000..437a45c
--- /dev/null
+++ b/debian/patches/cross.patch
@@ -0,0 +1,38 @@
+--- a/Makefile
++++ b/Makefile
+@@ -19,10 +19,11 @@
+ EXEC=darknet
+ OBJDIR=./obj/
+ 
+-CC=gcc
+-CPP=g++
+-NVCC=nvcc 
+-AR=ar
++CC?=gcc
++CXX?=g++
++NVCC?=nvcc 
++AR?=ar
++PKG_CONFIG?=pkg-config
+ ARFLAGS=rcs
+ OPTS=-Ofast
+ LDFLAGS= -lm -pthread 
+@@ -43,8 +44,8 @@
+ ifeq ($(OPENCV), 1) 
+ COMMON+= -DOPENCV
+ CFLAGS+= -DOPENCV
+-LDFLAGS+= `pkg-config --libs opencv 2> /dev/null || pkg-config --libs opencv4` -lstdc++
+-COMMON+= `pkg-config --cflags opencv 2> /dev/null || pkg-config --cflags opencv4`
++LDFLAGS+= `$(PKG_CONFIG) --libs opencv 2> /dev/null || $(PKG_CONFIG) --libs opencv4` -lstdc++
++COMMON+= `$(PKG_CONFIG) --cflags opencv 2> /dev/null || $(PKG_CONFIG) --cflags opencv4`
+ endif
+ 
+ ifeq ($(GPU), 1) 
+@@ -84,7 +85,7 @@
+ 	$(CC) $(CFLAGS) -shared $^ -o $@ $(LDFLAGS)
+ 
+ $(OBJDIR)%.o: %.cpp $(DEPS)
+-	$(CPP) $(CPPFLAGS) $(COMMON) $(CFLAGS) -c $< -o $@
++	$(CXX) $(CPPFLAGS) $(COMMON) $(CFLAGS) -c $< -o $@
+ 
+ $(OBJDIR)%.o: %.c $(DEPS)
+ 	$(CC) $(COMMON) $(CFLAGS) -c $< -o $@
diff --git a/debian/patches/series b/debian/patches/series
index 5e25855..cbcf81c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@
 0004-Enable-C-11-for-OpenCV-4.patch
 0005-Fix-1421-use-after-free.patch
 0006-port-to-python3.13.patch
+cross.patch
-- 
2.50.1


Reply to: