net/argus fails to build with clang on amd64:

cc -O2 -pipe   -I.  -I./../include  -DHAVE_CONFIG_H -DSYSCONFDIR=\"/etc\" -o 
../bin/argus argus.o ArgusModeler.o ArgusSource.o ArgusUtil.o ArgusOutput.o 
ArgusUdp.o ArgusTcp.o ArgusIcmp.o ArgusIgmp.o ArgusEsp.o ArgusArp.o ArgusFrag.o 
ArgusUdt.o ArgusLcp.o ArgusIsis.o ArgusAuth.o Argus802.11.o ArgusApp.o 
ArgusEvents.o ArgusNetflow.o ArgusSflow.o  -lpcap    -lm -lz 
../lib/argus_common.a -lm
argus.o: In function `ArgusComplete':
argus.c:(.text+0x2d1e): warning: warning: sprintf() is often misused, please 
use snprintf()
/usr/bin/ld: ../lib/argus_common.a(argus_filter.o): relocation R_X86_64_PC32 
against `blocks' can not be used when making a shared object; recompile with 
-fPIC
/usr/bin/ld: final link failed: Bad value
cc: error: linker command failed with exit code 1 (use -v to see invocation)

argus embeds a copy of pcap code for some purpose, but also links
against libpcap.  Both code bases use the same global symbols
(`blocks', `edges', etc.).

Wait, that's the error kettenis@'s fixed in binutils.  What's going
on here?  The problem is the linking order.  The shared library
needs to come later.  Patch below.  This builds, but I have no idea
if it works.  On the other hand, I don't see why it shouldn't.

Testers?  ok?

Index: Makefile
===================================================================
RCS file: /cvs/ports/net/argus/Makefile,v
retrieving revision 1.21
diff -u -p -r1.21 Makefile
--- Makefile    12 Aug 2016 21:38:52 -0000      1.21
+++ Makefile    27 Jul 2017 20:43:40 -0000
@@ -3,6 +3,7 @@
 COMMENT =      Audit Record Generation and Utilization System
 
 DISTNAME =     argus-3.0.8.2
+REVISION =     0
 CATEGORIES =   net
 
 HOMEPAGE =     http://qosient.com/argus/
Index: patches/patch-argus_Makefile_in
===================================================================
RCS file: /cvs/ports/net/argus/patches/patch-argus_Makefile_in,v
retrieving revision 1.2
diff -u -p -r1.2 patch-argus_Makefile_in
--- patches/patch-argus_Makefile_in     8 Jul 2012 19:20:58 -0000       1.2
+++ patches/patch-argus_Makefile_in     27 Jul 2017 20:43:40 -0000
@@ -1,6 +1,7 @@
 $OpenBSD: patch-argus_Makefile_in,v 1.2 2012/07/08 19:20:58 steven Exp $
---- argus/Makefile.in.orig     Wed Jan  4 01:15:19 2012
-+++ argus/Makefile.in  Wed Jun 27 22:27:06 2012
+Index: argus/Makefile.in
+--- argus/Makefile.in.orig
++++ argus/Makefile.in
 @@ -19,6 +19,7 @@
  prefix = @prefix@
  exec_prefix = @exec_prefix@
@@ -18,3 +19,12 @@ $OpenBSD: patch-argus_Makefile_in,v 1.2 
  #DEFS = -DARGUSPERFMETRICS=1 @DEFS@
  
  
+@@ -84,7 +85,7 @@ PROG =       @INSTALL_BIN@/argus
+ 
+ OBJ = $(SRC:.c=.o)
+ 
+-LIB = @LIBS@ @V_THREADS@ $(WRAPLIBS) $(SASLLIBS) $(COMPATLIB) 
../lib/argus_common.a -lm
++LIB = ../lib/argus_common.a @LIBS@ @V_THREADS@ $(WRAPLIBS) $(SASLLIBS) 
$(COMPATLIB) -lm
+ 
+ HDR = pcap.h pcap-int.h pcap-namedb.h pcap-nit.h pcap-pf.h \
+       ethertype.h gencode.h gnuc.h
-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to