"Sebastian Reitenbach" <sebas...@l00-bugdead-prods.de> writes:

> Hi,

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?

It looks like ld doesn't like finding the same symbol twice in the same
section, but I don't believe that moving some symbols from data to bss
is the best workaround.

What about this instead? (needs a fresh checkout)

Index: Makefile
===================================================================
RCS file: /cvs/ports/news/newsfetch/Makefile,v
retrieving revision 1.24
diff -u -p -r1.24 Makefile
--- Makefile    29 Oct 2014 00:07:17 -0000      1.24
+++ Makefile    29 Oct 2014 00:25:08 -0000
@@ -3,7 +3,7 @@
 COMMENT=       download news articles from NNTP server
 
 DISTNAME=      newsfetch-1.21
-REVISION=      0
+REVISION=      1
 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      29 Oct 2014 00:25:08 -0000
@@ -0,0 +1,14 @@
+$OpenBSD$
+--- getopt.c.orig      Wed Oct 29 01:11:34 2014
++++ getopt.c   Wed Oct 29 01:12:14 2014
+@@ -1,4 +1,10 @@
+ #include        <stdio.h>
++
++#define optarg        Optarg
++#define optind        Optind
++#define opterr        Opterr
++#define optopt        Optopt
++
+ #define EPR                 fprintf(stderr,
+ #define ERR(str, chr)       if(opterr){EPR "%s%c\n", str, chr);}
+ int     opterr = 1;
Index: patches/patch-opt_c
===================================================================
RCS file: /cvs/ports/news/newsfetch/patches/patch-opt_c,v
retrieving revision 1.2
diff -u -p -r1.2 patch-opt_c
--- patches/patch-opt_c 4 Jan 2004 21:39:33 -0000       1.2
+++ patches/patch-opt_c 29 Oct 2014 00:25:08 -0000
@@ -1,14 +1,22 @@
 $OpenBSD: patch-opt_c,v 1.2 2004/01/04 21:39:33 espie Exp $
---- opt.c.orig 1998-04-13 16:39:59.000000000 +0200
-+++ opt.c      2004-01-04 22:36:26.000000000 +0100
-@@ -1,4 +1,6 @@
+--- opt.c.orig Mon Apr 13 16:39:59 1998
++++ opt.c      Wed Oct 29 01:19:24 2014
+@@ -1,7 +1,14 @@
  #include <stdio.h>
 +#include <string.h>
 +#include <stdlib.h>
  #include <unistd.h>
  #include "newsfetch.h"        
  
-@@ -34,7 +36,7 @@ while (1)
++#define optarg        Optarg
++#define optind        Optind
++#define opterr        Opterr
++#define optopt        Optopt
++
+ int get_commandline(int argc, char *argv[], char *dirname, char *rcname,
+               int *cleanup, int *wait_after_articles, int *wait_for_time,
+               int *command_flag, char *execute_command,
+@@ -34,7 +41,7 @@ while (1)
  -Y -> pipe each article
  */
           c = Getopt(argc, argv, "w:t:T:d:f:U:N:x:p:P:Y:yslVvchH-");
@@ -17,7 +25,7 @@ $OpenBSD: patch-opt_c,v 1.2 2004/01/04 2
                break;
  
           switch (c)
-@@ -192,9 +194,8 @@ opt_help(char *prog_name)
+@@ -192,9 +199,8 @@ opt_help(char *prog_name)
  {
  
  char *options=


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to