Hi,

news/newsfetch doesn't build on vax, because of problem while linking:

$ cc -o newsfetch newsfetch.o nntp.o net.o opt.o util.o getopt.o            
newsfetch.o(.text+0x82): In function `main':
: warning: strcpy() is almost always misused, please use strlcpy()
newsfetch.o(.text+0x597): In function `checkLockFile':
: warning: strcat() is almost always misused, please use strlcat()
util.o(.text+0x6f): In function `defaultRcFiles':
: warning: sprintf() is often misused, please use snprintf()
/usr/lib/libc.a(getopt_long.o)(.data+0x0): In function `gcd':
/usr/src/lib/libc/stdlib/getopt_long.c:103: multiple definition of `opterr'
getopt.o(.data+0x0): first defined here
/usr/lib/libc.a(getopt_long.o)(.data+0x4): In function `gcd':
/usr/src/lib/libc/stdlib/getopt_long.c:103: multiple definition of `optind'
getopt.o(.data+0x4): first defined here
collect2: ld returned 1 exit status

about the error I found that thread here:
https://sourceware.org/ml/newlib/2010/msg00477.html

and they suggested to use -fno-common. So I tried, but that
did not helped.

However, just not initializing opterr and optind in the 
getopt.c fixed the problem. in libc getopt_long.c both are initialized
to the same values. If I understand it right, newsfetch will
then take the value from libc?

Still builds fine on amd64. 
I don't use usenet news, so haven't tested runtime.

If my assumption about the initialization is right, OK?

$ cc -o newsfetch newsfetch.o nntp.o net.o opt.o util.o getopt.o            
newsfetch.o(.text+0x82): In function `main':
: warning: strcpy() is almost always misused, please use strlcpy()
newsfetch.o(.text+0x597): In function `checkLockFile':
: warning: strcat() is almost always misused, please use strlcat()
util.o(.text+0x6f): In function `defaultRcFiles':
: warning: sprintf() is often misused, please use snprintf()
/usr/lib/libc.a(getopt_long.o)(.data+0x0): In function `gcd':
/usr/src/lib/libc/stdlib/getopt_long.c:103: multiple definition of `opterr'
getopt.o(.data+0x0): first defined here
/usr/lib/libc.a(getopt_long.o)(.data+0x4): In function `gcd':
/usr/src/lib/libc/stdlib/getopt_long.c:103: multiple definition of `optind'
getopt.o(.data+0x4): first defined here
collect2: ld returned 1 exit status


cheers,
Sebastian

Index: Makefile
===================================================================
RCS file: /cvs/ports/news/newsfetch/Makefile,v
retrieving revision 1.23
diff -u -r1.23 Makefile
--- Makefile    11 Mar 2013 11:35:58 -0000      1.23
+++ Makefile    9 Oct 2014 22:56:33 -0000
@@ -9,6 +9,7 @@
 COMMENT=       download news articles from NNTP server
 
 DISTNAME=      newsfetch-1.21
+REVISION=      0
 CATEGORIES=    news
 MASTER_SITES=  ${MASTER_SITE_SUNSITE:=system/news/readers/}
 
Index: patches/patch-getopt_c
===================================================================
RCS file: patches/patch-getopt_c
diff -N patches/patch-getopt_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-getopt_c      9 Oct 2014 22:53:38 -0000
@@ -0,0 +1,18 @@
+$OpenBSD$
+
+prevent multiple definition of `opterr' and `optind'
+on vax.
+
+--- getopt.c.orig      Thu Oct  9 16:51:28 2014
++++ getopt.c   Thu Oct  9 16:51:43 2014
+@@ -1,8 +1,8 @@
+ #include        <stdio.h>
+ #define EPR                 fprintf(stderr,
+ #define ERR(str, chr)       if(opterr){EPR "%s%c\n", str, chr);}
+-int     opterr = 1;
+-int     optind = 1;
++int     opterr;
++int     optind;
+ int     optopt;
+ char    *optarg;
+ char    *strchr();


Reply via email to