Skip to contentSkip to conversation

package/suricata: fix build on m68k

PATCH New Fabrice Fontaine 2 participants 6 messages Apr 24, 2019 – May 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 package/suricata: fix build on m68k

Fixes:
- http://autobuild.buildroot.org/results/ed923bcc1454ce90444b8dac7c064b5f4ea4a0a5

---
 .../0001-fix-build-on-m68k-with-uclibc.patch  | 48 +++++++++++++++++++
 package/suricata/suricata.mk                  |  2 +
 2 files changed, 50 insertions(+)
 create mode 100644 package/suricata/0001-fix-build-on-m68k-with-uclibc.patch
package/suricata/0001-fix-build-on-m68k-with-uclibc.patch new file +48 -0
new file mode 100644
index 0000000000..09b4b70588
@@ -0,0 +1,48 @@
+From 58750008dd562c08642bed1bb3194cb87e301570 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <[email protected]>
+Date: Wed, 24 Apr 2019 19:14:29 +0200
+Subject: [PATCH] fix build on m68k with uclibc
+
+uclibc on m68k defines _POSIX_SPIN_LOCKS but does not define
+pthread_spin_unlock so check for this function before using
+pthread_spin_xxx functions
+
+Fixes:
+ - http://autobuild.buildroot.org/results/ed923bcc1454ce90444b8dac7c064b5f4ea4a0a5
+
+Signed-off-by: Fabrice Fontaine <[email protected]>
+[Upstream status: https://github.com/OISF/suricata/pull/3816]
+---
+ configure.ac  | 2 ++
+ src/threads.h | 2 +-
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index a6669ec47..ee59c9d8e 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -889,6 +889,8 @@
+         exit 1
+     fi
+ 
++    AC_CHECK_FUNCS([pthread_spin_unlock])
++
+   # libjansson
+     AC_ARG_WITH(libjansson_includes,
+             [  --with-libjansson-includes=DIR  libjansson include directory],
+diff --git a/src/threads.h b/src/threads.h
+index 4e6f61134..4eb1a7360 100644
+--- a/src/threads.h
++++ b/src/threads.h
+@@ -155,7 +155,7 @@ enum {
+ #define SCCtrlCondDestroy pthread_cond_destroy
+ 
+ /* spinlocks */
+-#if ((_POSIX_SPIN_LOCKS - 200112L) < 0L) || defined HELGRIND
++#if ((_POSIX_SPIN_LOCKS - 200112L) < 0L) || defined HELGRIND || !defined(HAVE_PTHREAD_SPIN_UNLOCK)
+ #define SCSpinlock                              SCMutex
+ #define SCSpinLock(spin)                        SCMutexLock((spin))
+ #define SCSpinTrylock(spin)                     SCMutexTrylock((spin))
+-- 
+2.20.1
+
package/suricata/suricata.mk +2 -0
index e5884cdfe4..0491fad6d5 100644
@@ -8,6 +8,8 @@ SURICATA_VERSION = 4.1.3
 SURICATA_SITE = https://www.openinfosecfoundation.org/download
 SURICATA_LICENSE = GPL-2.0
 SURICATA_LICENSE_FILES = COPYING LICENSE
+# We're patching configure.ac
+SURICATA_AUTORECONF = YES
 
 SURICATA_DEPENDENCIES = \
 	host-pkgconf \
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/3 package/suricata: fix pcap static build

Fixes:
- no autobuilder failures yet

---
 ...figure.ac-fix-static-build-with-pcap.patch | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 package/suricata/0002-configure.ac-fix-static-build-with-pcap.patch
package/suricata/0002-configure.ac-fix-static-build-with-pcap.patch new file +29 -0
new file mode 100644
index 0000000000..3312550620
@@ -0,0 +1,29 @@
+From 2660123b0c16d7f6a49747711be676c4119561c9 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <[email protected]>
+Date: Wed, 24 Apr 2019 20:35:20 +0200
+Subject: [PATCH] configure.ac: fix static build with pcap
+
+pcap can depends on nl-3 so use pkg-config to find these dependencies
+otherwise all AC_CHECK_LIB calls will fail when building statically
+
+Signed-off-by: Fabrice Fontaine <[email protected]>
+[Upstream status: not sent yet]
+---
+ configure.ac | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/configure.ac b/configure.ac
+index ee59c9d8e..5ec341231 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1331,6 +1331,7 @@
+     AC_CHECK_HEADERS([pcap.h pcap/pcap.h pcap/bpf.h])
+ 
+     LIBPCAP=""
++    PKG_CHECK_MODULES([PCAP],libpcap,[CPPFLAGS="${CPPFLAGS} ${PCAP_CFLAGS}" LIBS="${LIBS} ${PCAP_LIBS}"],[])
+     AC_CHECK_LIB(${PCAP_LIB_NAME}, pcap_open_live,, LIBPCAP="no")
+     if test "$LIBPCAP" = "no"; then
+         echo
+-- 
+2.20.1
+
Signature · 1 line
2.20.1
#2 lore raw

PATCH 2/3 package/suricata: fix pcap static build

Quoted 4 lines · Fabrice Fontaine

Fixes:
- no autobuilder failures yet

Applied to master, thanks.

Regards,
Arnout

Quoted 41 lines
---
 ...figure.ac-fix-static-build-with-pcap.patch | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 package/suricata/0002-configure.ac-fix-static-build-with-pcap.patch
package/suricata/0002-configure.ac-fix-static-build-with-pcap.patch new file +29 -0
new file mode 100644
index 0000000000..3312550620
@@ -0,0 +1,29 @@
+From 2660123b0c16d7f6a49747711be676c4119561c9 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <[email protected]>
+Date: Wed, 24 Apr 2019 20:35:20 +0200
+Subject: [PATCH] configure.ac: fix static build with pcap
+
+pcap can depends on nl-3 so use pkg-config to find these dependencies
+otherwise all AC_CHECK_LIB calls will fail when building statically
+
+Signed-off-by: Fabrice Fontaine <[email protected]>
+[Upstream status: not sent yet]
+---
+ configure.ac | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/configure.ac b/configure.ac
+index ee59c9d8e..5ec341231 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1331,6 +1331,7 @@
+     AC_CHECK_HEADERS([pcap.h pcap/pcap.h pcap/bpf.h])
+ 
+     LIBPCAP=""
++    PKG_CHECK_MODULES([PCAP],libpcap,[CPPFLAGS="${CPPFLAGS} ${PCAP_CFLAGS}" LIBS="${LIBS} ${PCAP_LIBS}"],[])
+     AC_CHECK_LIB(${PCAP_LIB_NAME}, pcap_open_live,, LIBPCAP="no")
+     if test "$LIBPCAP" = "no"; then
+         echo
+-- 
+2.20.1
+
#3 lore raw

PATCH 3/3 package/libhtp: add -lz to htp.pc

In reply to Fabrice Fontaine

This will fix static build of suricata

Fixes:
- No autobuilder failures

---
 ...002-htp.pc.in-add-lz-to-Libs.private.patch | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 package/libhtp/0002-htp.pc.in-add-lz-to-Libs.private.patch
package/libhtp/0002-htp.pc.in-add-lz-to-Libs.private.patch new file +29 -0
new file mode 100644
index 0000000000..b5b0c0e2b6
@@ -0,0 +1,29 @@
+From 39e534ab696157b244ec226d649c789dcf423e42 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <[email protected]>
+Date: Wed, 24 Apr 2019 20:48:57 +0200
+Subject: [PATCH] htp.pc.in: add -lz to Libs.private
+
+zlib is a mandatory dependency so add it to Libs.private otherwise
+static linking iof suricata will fail
+
+Signed-off-by: Fabrice Fontaine <[email protected]>
+[Upstream status: not sent yet]
+---
+ htp.pc.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/htp.pc.in b/htp.pc.in
+index 2fec995..9b1a6cc 100644
+--- a/htp.pc.in
++++ b/htp.pc.in
+@@ -7,6 +7,6 @@ Name: @PACKAGE_NAME@
+ Description: A security-aware HTTP parser, designed for use in IDS/IPS and WAF products.
+ Version: @PACKAGE_VERSION@
+ Libs: -L${libdir} -lhtp
+-Libs.private: @LIBICONV@
++Libs.private: -lz @LIBICONV@
+ Cflags: -I${includedir} -I${libdir}/htp/include
+ 
+-- 
+2.20.1
+
Signature · 1 line
2.20.1
#4 lore raw

PATCH 3/3 package/libhtp: add -lz to htp.pc

Quoted 6 lines · Fabrice Fontaine

This will fix static build of suricata

Fixes:
- No autobuilder failures

Applied to master, thanks.

Quoted 11 lines
---
 ...002-htp.pc.in-add-lz-to-Libs.private.patch | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 package/libhtp/0002-htp.pc.in-add-lz-to-Libs.private.patch
package/libhtp/0002-htp.pc.in-add-lz-to-Libs.private.patch new file +0 -0
new file mode 100644
index 0000000000..b5b0c0e2b6

package/libhtp/0002-htp.pc.in-add-lz-to-Libs.private.patch line 7

Quoted 7 lines
package/libhtp/0002-htp.pc.in-add-lz-to-Libs.private.patch new file +7 -0
@@ -0,0 +1,29 @@
+From 39e534ab696157b244ec226d649c789dcf423e42 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <[email protected]>
+Date: Wed, 24 Apr 2019 20:48:57 +0200
+Subject: [PATCH] htp.pc.in: add -lz to Libs.private
+
+zlib is a mandatory dependency so add it to Libs.private otherwise
+static linking iof suricata will fail

I've slightly reworded this (grammar errors mostly) so you may want to take the
version I committed to push upstream.

Regards,
Arnout

Quoted 23 lines
package/libhtp/0002-htp.pc.in-add-lz-to-Libs.private.patch new file +22 -0
+
+Signed-off-by: Fabrice Fontaine <[email protected]>
+[Upstream status: not sent yet]
+---
+ htp.pc.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/htp.pc.in b/htp.pc.in
+index 2fec995..9b1a6cc 100644
+--- a/htp.pc.in
++++ b/htp.pc.in
+@@ -7,6 +7,6 @@ Name: @PACKAGE_NAME@
+ Description: A security-aware HTTP parser, designed for use in IDS/IPS and WAF products.
+ Version: @PACKAGE_VERSION@
+ Libs: -L${libdir} -lhtp
+-Libs.private: @LIBICONV@
++Libs.private: -lz @LIBICONV@
+ Cflags: -I${includedir} -I${libdir}/htp/include
+ 
+-- 
+2.20.1
+
#5 lore raw

PATCH 1/3 package/suricata: fix build on m68k

In reply to Fabrice Fontaine
Quoted 16 lines · Fabrice Fontaine

Fixes:
- http://autobuild.buildroot.org/results/ed923bcc1454ce90444b8dac7c064b5f4ea4a0a5

---
 .../0001-fix-build-on-m68k-with-uclibc.patch  | 48 +++++++++++++++++++
 package/suricata/suricata.mk                  |  2 +
 2 files changed, 50 insertions(+)
 create mode 100644 package/suricata/0001-fix-build-on-m68k-with-uclibc.patch
package/suricata/0001-fix-build-on-m68k-with-uclibc.patch new file +0 -0
new file mode 100644
index 0000000000..09b4b70588

package/suricata/0001-fix-build-on-m68k-with-uclibc.patch line 8

Quoted 8 lines
package/suricata/0001-fix-build-on-m68k-with-uclibc.patch new file +8 -0
@@ -0,0 +1,48 @@
+From 58750008dd562c08642bed1bb3194cb87e301570 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <[email protected]>
+Date: Wed, 24 Apr 2019 19:14:29 +0200
+Subject: [PATCH] fix build on m68k with uclibc
+
+uclibc on m68k defines _POSIX_SPIN_LOCKS but does not define
+pthread_spin_unlock so check for this function before using
+pthread_spin_xxx functions

This makes no sense... If pthread_spin_lock is defined but pthread_spin_unlock
is not, then there are no spinlocks. So this clearly is a uClibc bug.

Since NPTL support for m68k seems to be pretty incomplete in uClibc, I think we
should just disable it.

And for this specific package, I'd just disable it for m68k.

Regards,
Arnout

Quoted 54 lines
package/suricata/0001-fix-build-on-m68k-with-uclibc.patch new file +40 -0
+
+Fixes:
+ - http://autobuild.buildroot.org/results/ed923bcc1454ce90444b8dac7c064b5f4ea4a0a5
+
+Signed-off-by: Fabrice Fontaine <[email protected]>
+[Upstream status: https://github.com/OISF/suricata/pull/3816]
+---
+ configure.ac  | 2 ++
+ src/threads.h | 2 +-
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index a6669ec47..ee59c9d8e 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -889,6 +889,8 @@
+         exit 1
+     fi
+ 
++    AC_CHECK_FUNCS([pthread_spin_unlock])
++
+   # libjansson
+     AC_ARG_WITH(libjansson_includes,
+             [  --with-libjansson-includes=DIR  libjansson include directory],
+diff --git a/src/threads.h b/src/threads.h
+index 4e6f61134..4eb1a7360 100644
+--- a/src/threads.h
++++ b/src/threads.h
+@@ -155,7 +155,7 @@ enum {
+ #define SCCtrlCondDestroy pthread_cond_destroy
+ 
+ /* spinlocks */
+-#if ((_POSIX_SPIN_LOCKS - 200112L) < 0L) || defined HELGRIND
++#if ((_POSIX_SPIN_LOCKS - 200112L) < 0L) || defined HELGRIND || !defined(HAVE_PTHREAD_SPIN_UNLOCK)
+ #define SCSpinlock                              SCMutex
+ #define SCSpinLock(spin)                        SCMutexLock((spin))
+ #define SCSpinTrylock(spin)                     SCMutexTrylock((spin))
+-- 
+2.20.1
+
package/suricata/suricata.mk +2 -0
index e5884cdfe4..0491fad6d5 100644
@@ -8,6 +8,8 @@ SURICATA_VERSION = 4.1.3
 SURICATA_SITE = https://www.openinfosecfoundation.org/download
 SURICATA_LICENSE = GPL-2.0
 SURICATA_LICENSE_FILES = COPYING LICENSE
+# We're patching configure.ac
+SURICATA_AUTORECONF = YES
 
 SURICATA_DEPENDENCIES = \
 	host-pkgconf \