NetBSD Problem Report #53314

From www@NetBSD.org  Sat May 26 00:46:36 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 2427A7A174
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 26 May 2018 00:46:36 +0000 (UTC)
Message-Id: <20180526004634.BC7F57A218@mollari.NetBSD.org>
Date: Sat, 26 May 2018 00:46:34 +0000 (UTC)
From: venture37@geeklan.co.uk
Reply-To: venture37@geeklan.co.uk
To: gnats-bugs@NetBSD.org
Subject: strncasecmp conflict when cross-compiling libgroff on FreeBSD
X-Send-Pr-Version: www-1.0

>Number:         53314
>Category:       toolchain
>Synopsis:       strncasecmp conflict when cross-compiling libgroff on FreeBSD
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    riastradh
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat May 26 00:50:00 +0000 2018
>Closed-Date:    Tue Nov 06 22:07:31 +0000 2018
>Last-Modified:  Wed Nov 07 09:15:00 +0000 2018
>Originator:     Sevan Janiyan
>Release:        NetBSD-HEAD
>Organization:
>Environment:
FreeBSD 11.2-BETA2 #0 r333797
>Description:
In file included from /netbsd-src/external/gpl2/groff/dist/src/libs/libgroff/color.cpp:28:
/netbsd-src/tools/groff/../../external/gpl2/groff/dist/src/include/lib.h:119:18: error: conflicting types for 'strncasecmp'
extern "C" { int strncasecmp(const char *, const char *, int); }
                 ^
/usr/include/strings.h:64:6: note: previous declaration is here
int      strncasecmp(const char *, const char *, size_t) __pure;
         ^

>How-To-Repeat:
On FreeBSD 11.2
./build.sh -U -m amd64 tools
>Fix:

>Release-Note:

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/53314: strncasecmp conflict when cross-compiling
 libgroff on FreeBSD
Date: Sat, 26 May 2018 20:41:15 +0300

 On Sat, May 26, 2018 at 00:50:00 +0000, venture37@geeklan.co.uk wrote:

 > In file included from /netbsd-src/external/gpl2/groff/dist/src/libs/libgroff/color.cpp:28:
 > /netbsd-src/tools/groff/../../external/gpl2/groff/dist/src/include/lib.h:119:18: error: conflicting types for 'strncasecmp'
 > extern "C" { int strncasecmp(const char *, const char *, int); }
 >                  ^
 > /usr/include/strings.h:64:6: note: previous declaration is here
 > int      strncasecmp(const char *, const char *, size_t) __pure;
 >          ^

 Check your tools/groff/build/src/include/config.h and
 tools/groff/build/config.log, search for strncasecmp
 (case-insensitive).

 -uwe

From: Sevan Janiyan <venture37@geeklan.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/53314: strncasecmp conflict when cross-compiling
 libgroff on FreeBSD
Date: Sat, 26 May 2018 20:30:38 +0100

 On 05/26/18 18:45, Valery Ushakov wrote:
 >  Check your tools/groff/build/src/include/config.h and
 >  tools/groff/build/config.log, search for strncasecmp
 >  (case-insensitive).
 >  


 /* Define to 1 if you have the `strncasecmp' function. */
 #define HAVE_STRNCASECMP 1

 /* Define if your C++ doesn't declare strncasecmp(). */
 #define NEED_DECLARATION_STRNCASECMP 1


 configure:7436: checking whether strncasecmp must be declared
 configure:7493: c++ -c -O
 -I/home/sevan/sandbox/tools/amd64/include/compat
 -I/netbsd-src-ro/tools/compat  -DHAVE_NBTOOL_CONFIG_H=1
 -D_FILE_OFFSET_BITS=64 conftest.cc >&5
 In file included from conftest.cc:52:
 In file included from /usr/include/c++/v1/stdlib.h:94:
 /usr/include/stdlib.h:95:1: error: function declared '[[noreturn]]'
 after its first declaration
 _Noreturn void   exit(int);
 ^
 /usr/include/sys/cdefs.h:291:22: note: expanded from macro '_Noreturn'
 #define _Noreturn               [[noreturn]]
                                   ^
 conftest.cc:10:6: note: declaration missing '[[noreturn]]' attribute is here
 void exit (int);
      ^
 In file included from conftest.cc:52:
 In file included from /usr/include/c++/v1/stdlib.h:94:
 /usr/include/stdlib.h:95:17: error: declaration of 'exit' has a
 different language linkage
 _Noreturn void   exit(int);
                  ^
 conftest.cc:10:6: note: previous declaration is here
 void exit (int);
      ^
 2 errors generated.
 configure:7499: $? = 1
 configure: failed program was:
 |
 | 	  /* confdefs.h.  */
 |
 | #define PACKAGE_NAME ""
 | #define PACKAGE_TARNAME ""
 | #define PACKAGE_VERSION ""
 | #define PACKAGE_STRING ""
 | #define PACKAGE_BUGREPORT ""
 | #ifdef __cplusplus
 | void exit (int);
 | #endif
 | #define X_DISPLAY_MISSING 1
 | #define STDC_HEADERS 1
 | #define HAVE_SYS_TYPES_H 1
 | #define HAVE_SYS_STAT_H 1
 | #define HAVE_STDLIB_H 1
 | #define HAVE_STRING_H 1
 | #define HAVE_MEMORY_H 1
 | #define HAVE_STRINGS_H 1
 | #define HAVE_INTTYPES_H 1
 | #define HAVE_STDINT_H 1
 | #define HAVE_UNISTD_H 1
 | #define HAVE_STDLIB_H 1
 | #define HAVE_UNISTD_H 1
 | #define HAVE_DIRENT_H 1
 | #define HAVE_LIMITS_H 1
 | #define HAVE_SYS_DIR_H 1
 | #define HAVE_STRING_H 1
 | #define HAVE_STRINGS_H 1
 | #define HAVE_MATH_H 1
 | #define HAVE_SYS_TIME_H 1
 | #define NEED_DECLARATION_GETTIMEOFDAY 1
 | #define NEED_DECLARATION_HYPOT 1
 | #define NEED_DECLARATION_POPEN 1
 | #define NEED_DECLARATION_PCLOSE 1
 | #define NEED_DECLARATION_PUTENV 1
 | #define NEED_DECLARATION_RAND 1
 | #define NEED_DECLARATION_SNPRINTF 1
 | #define NEED_DECLARATION_SRAND 1
 | #define NEED_DECLARATION_STRCASECMP 1
 | /* end confdefs.h.  */
 |
 |
 | #include <stdio.h>
 | #ifdef HAVE_STRING_H
 | #include <string.h>
 | #endif
 | #ifdef HAVE_STRINGS_H
 | #include <strings.h>
 | #endif
 | #ifdef HAVE_STDLIB_H
 | #include <stdlib.h>
 | #endif
 | #ifdef HAVE_SYS_TIME_H
 | #include <sys/time.h>
 | #endif
 | #ifdef HAVE_UNISTD_H
 | #include <unistd.h>
 | #endif
 | #ifdef HAVE_MATH_H
 | #include <math.h>
 | #endif
 |
 |
 | int
 | main ()
 | {
 |
 |
 | #ifndef strncasecmp
 |   char *p = (char *) strncasecmp;
 | #endif
 |
 |
 |   ;
 |   return 0;
 | }
 |
 configure:7524: result: yes


 configure:9016: checking for strncasecmp
 configure:9073: cc -o conftest -O
 -I/home/sevan/sandbox/tools/amd64/include/compat
 -I/netbsd-src-ro/tools/compat  -DHAVE_NBTOOL_CONFIG_H=1
 -D_FILE_OFFSET_BITS=64  conftest.c  -lc -lm >&5
 conftest.c:82:6: warning: incompatible redeclaration of library function
 'strncasecmp' [-Wincompatible-library-redeclaration]
 char strncasecmp ();
      ^
 conftest.c:82:6: note: 'strncasecmp' is a builtin with type 'int (const
 char *, const char *, unsigned long)'
 1 warning generated.
 configure:9079: $? = 0
 configure:9083: test -z
 			 || test ! -s conftest.err
 configure:9086: $? = 0
 configure:9089: test -s conftest
 configure:9092: $? = 0
 configure:9104: result: yes
 configure:9016: checking for strtol
 configure:9073: cc -o conftest -O
 -I/home/sevan/sandbox/tools/amd64/include/compat
 -I/netbsd-src-ro/tools/compat  -DHAVE_NBTOOL_CONFIG_H=1
 -D_FILE_OFFSET_BITS=64  conftest.c  -lc -lm >&5
 configure:9079: $? = 0
 configure:9083: test -z
 			 || test ! -s conftest.err
 configure:9086: $? = 0
 configure:9089: test -s conftest
 configure:9092: $? = 0
 configure:9104: result: yes



 configure:7436: checking whether strncasecmp must be declared
 configure:7493: c++ -c -O
 -I/home/sevan/sandbox/tools/amd64/include/compat
 -I/netbsd-src-ro/tools/compat  -DHAVE_NBTOOL_CONFIG_H=1
 -D_FILE_OFFSET_BITS=64 conftest.cc >&5
 In file included from conftest.cc:52:
 In file included from /usr/include/c++/v1/stdlib.h:94:
 /usr/include/stdlib.h:95:1: error: function declared '[[noreturn]]'
 after its first declaration
 _Noreturn void   exit(int);
 ^
 /usr/include/sys/cdefs.h:291:22: note: expanded from macro '_Noreturn'
 #define _Noreturn               [[noreturn]]
                                   ^
 conftest.cc:10:6: note: declaration missing '[[noreturn]]' attribute is here
 void exit (int);
      ^
 In file included from conftest.cc:52:
 In file included from /usr/include/c++/v1/stdlib.h:94:
 /usr/include/stdlib.h:95:17: error: declaration of 'exit' has a
 different language linkage
 _Noreturn void   exit(int);
                  ^
 conftest.cc:10:6: note: previous declaration is here
 void exit (int);
      ^
 2 errors generated.
 configure:7499: $? = 1
 configure: failed program was:
 |
 | 	  /* confdefs.h.  */
 |
 | #define PACKAGE_NAME ""
 | #define PACKAGE_TARNAME ""
 | #define PACKAGE_VERSION ""
 | #define PACKAGE_STRING ""
 | #define PACKAGE_BUGREPORT ""
 | #ifdef __cplusplus
 | void exit (int);
 | #endif
 | #define X_DISPLAY_MISSING 1
 | #define STDC_HEADERS 1
 | #define HAVE_SYS_TYPES_H 1
 | #define HAVE_SYS_STAT_H 1
 | #define HAVE_STDLIB_H 1
 | #define HAVE_STRING_H 1
 | #define HAVE_MEMORY_H 1
 | #define HAVE_STRINGS_H 1
 | #define HAVE_INTTYPES_H 1
 | #define HAVE_STDINT_H 1
 | #define HAVE_UNISTD_H 1
 | #define HAVE_STDLIB_H 1
 | #define HAVE_UNISTD_H 1
 | #define HAVE_DIRENT_H 1
 | #define HAVE_LIMITS_H 1
 | #define HAVE_SYS_DIR_H 1
 | #define HAVE_STRING_H 1
 | #define HAVE_STRINGS_H 1
 | #define HAVE_MATH_H 1
 | #define HAVE_SYS_TIME_H 1
 | #define NEED_DECLARATION_GETTIMEOFDAY 1
 | #define NEED_DECLARATION_HYPOT 1
 | #define NEED_DECLARATION_POPEN 1
 | #define NEED_DECLARATION_PCLOSE 1
 | #define NEED_DECLARATION_PUTENV 1
 | #define NEED_DECLARATION_RAND 1
 | #define NEED_DECLARATION_SNPRINTF 1
 | #define NEED_DECLARATION_SRAND 1
 | #define NEED_DECLARATION_STRCASECMP 1
 | /* end confdefs.h.  */
 |
 |
 | #include <stdio.h>
 | #ifdef HAVE_STRING_H
 | #include <string.h>
 | #endif
 | #ifdef HAVE_STRINGS_H
 | #include <strings.h>
 | #endif
 | #ifdef HAVE_STDLIB_H
 | #include <stdlib.h>
 | #endif
 | #ifdef HAVE_SYS_TIME_H
 | #include <sys/time.h>
 | #endif
 | #ifdef HAVE_UNISTD_H
 | #include <unistd.h>
 | #endif
 | #ifdef HAVE_MATH_H
 | #include <math.h>
 | #endif
 |
 |
 | int
 | main ()
 | {
 |
 |
 | #ifndef strncasecmp
 |   char *p = (char *) strncasecmp;
 | #endif
 |
 |
 |   ;
 |   return 0;
 | }
 |
 configure:7524: result: yes

From: coypu@sdf.org
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/53314: strncasecmp conflict when cross-compiling
 libgroff on FreeBSD
Date: Tue, 6 Nov 2018 01:17:42 +0000

 freebsd ships broken headers for C++11. they should remove _Noreturn
 from exit.

 You can work around it with HOST_CXXFLAGS=-std=gnu++03.

From: Taylor R Campbell <riastradh@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: toolchain-manager@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org, venture37@geeklan.co.uk
Subject: Re: toolchain/53314: strncasecmp conflict when cross-compiling libgroff on FreeBSD
Date: Tue, 6 Nov 2018 01:58:25 +0000

 The problem is not with FreeBSD's headers.  Doubtless there are bugs
 in FreeBSD's headers, but in this case, the logic in our tree is doing
 something wrong and we can straightforwardly fix it in our tree.

 The problem in our tree is that there was a bodgy autoconf feature
 that got baked into the groff configure script to attempt to _guess_
 the correct declaration of the exit function by enumerating several
 options, none of which is the one that FreeBSD uses now.

 Because the autoconf-generated configure script fails to find the
 declaration of exit, it gets confused and generates the wrong test
 programs, leading it to infer that the system's strncasecmp
 declaration is missing too.  On the basis of that, groff decides to
 fantasize its own strncasecmp declaration, which, incidentally, also
 disagrees with the standard one.

 The bodgy autoconf feature was a combination of a workaround for a bug
 dating back to 1988 in SunOS and difficulty with finding a usable
 declaration for exit when the C++ compiler is being abused as a C
 compiler[1].  Fortunately, this autoconf feature was removed in
 2006[2], 12 years ago, when the bug it worked around was only 18 years
 old.

 There are two obvious ways to fix this:

 1. Patch the groff configure script to try an exit declaration that
    FreeBSD actually uses:

 diff --git a/external/gpl2/groff/dist/configure b/external/gpl2/groff/dist/=
 configure
 index 107aadcae070..972b95703f29 100755
 --- a/external/gpl2/groff/dist/configure
 +++ b/external/gpl2/groff/dist/configure
 @@ -2511,6 +2511,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
     'extern "C" void std::exit (int); using std::exit;' \
     'extern "C" void exit (int) throw ();' \
     'extern "C" void exit (int);' \
 +   'extern "C" [[noreturn]] void exit (int);' \
 +   'extern "C" _Noreturn void exit (int);' \
     'void exit (int);'
  do
    cat >conftest.$ac_ext <<_ACEOF


 2. Regenerate the groff configure script with a modern autoconf that
    doesn't twist itsef into knots trying to guess how to declare exit.

 Neither of these requires changing FreeBSD; it is a legitimate bug in
 NetBSD that the toolchain doesn't build on FreeBSD right now, and
 rather embarrassing that it has been the case for months.


 [1] https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Ex=
 iting-Portably.html
 [2] https://git.savannah.gnu.org/gitweb/?p=3Dautoconf.git;a=3Dcommit;h=3Da7=
 1c24a704ec0570ba99be909fffbc044d50908b

From: Sevan Janiyan <venture37@geeklan.co.uk>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/53314: strncasecmp conflict when cross-compiling
 libgroff on FreeBSD
Date: Tue, 6 Nov 2018 09:18:18 +0000

 Applied the following patch on FreeBSD 13-CURRENT as requested

 Index: external/gpl2/groff/dist/configure
 ===================================================================
 RCS file: /cvsroot/src/external/gpl2/groff/dist/configure,v
 retrieving revision 1.1.1.1
 diff -u -p -u -r1.1.1.1 configure
 --- external/gpl2/groff/dist/configure  13 Jan 2016 18:41:45 -0000
 1.1.1.1
 +++ external/gpl2/groff/dist/configure  6 Nov 2018 09:15:08 -0000
 @@ -2511,6 +2511,8 @@ if { (eval echo "$as_me:$LINENO: \"$ac_c
     'extern "C" void std::exit (int); using std::exit;' \
     'extern "C" void exit (int) throw ();' \
     'extern "C" void exit (int);' \
 +   'extern "C" [[noreturn]] void exit (int);' \
 +   'extern "C" _Noreturn void exit (int);' \
     'void exit (int);'
  do
    cat >conftest.$ac_ext <<_ACEOF

 But it still failed building the amd64 tools on an amd64 host with
 c++ -I. -I/sandbox/usr/src/external/gpl2/groff/dist/src/libs/libgroff
 -I//sandbox/obj/amd64/tools/groff/build/src/include
 -I/sandbox/usr/src/tools/groff/../../external/gpl
 2/groff/dist/src/include -DHAVE_CONFIG_H -O
 -I//sandbox/tools/include/compat -I/sandbox/usr/src/tools/compat
 -DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -c  /sandbox/u
 sr/src/external/gpl2/groff/dist/src/libs/libgroff/color.cpp


 In file included from
 /sandbox/usr/src/external/gpl2/groff/dist/src/libs/libgroff/color.cpp:28:


 /sandbox/usr/src/tools/groff/../../external/gpl2/groff/dist/src/include/lib.h:119:18:
 error: conflicting types for 'strncasecmp'

 extern "C" { int strncasecmp(const char *, const char *, int); }


                  ^


 /usr/include/strings.h:66:6: note: previous declaration is here


 int      strncasecmp(const char *, const char *, size_t) __pure;


          ^


 1 error generated.





 *** Failed target:  color.o


 *** Failed command: c++ -I.
 -I/sandbox/usr/src/external/gpl2/groff/dist/src/libs/libgroff
 -I//sandbox/obj/amd64/tools/groff/build/src/include
 -I/sandbox/usr/src/tools/groff
 /../../external/gpl2/groff/dist/src/include -DHAVE_CONFIG_H -O
 -I//sandbox/tools/include/compat -I/sandbox/usr/src/tools/compat
 -DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -c
 /sandbox/usr/src/external/gpl2/groff/dist/src/libs/libgroff/color.cpp


 *** Error code 1

Responsible-Changed-From-To: toolchain-manager->riastradh
Responsible-Changed-By: sevan@NetBSD.org
Responsible-Changed-When: Tue, 06 Nov 2018 22:07:31 +0000
Responsible-Changed-Why:
Taylor fixed it


State-Changed-From-To: open->closed
State-Changed-By: sevan@NetBSD.org
State-Changed-When: Tue, 06 Nov 2018 22:07:31 +0000
State-Changed-Why:
Issue is resolved, I was able to build the amd64 toolchain without issue.


From: "Sevan Janiyan" <sevan@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53314 CVS commit: src/external/gpl2/groff/dist
Date: Tue, 6 Nov 2018 22:01:16 +0000

 Module Name:	src
 Committed By:	sevan
 Date:		Tue Nov  6 22:01:16 UTC 2018

 Modified Files:
 	src/external/gpl2/groff/dist: configure

 Log Message:
 Test for other exit cases.
 It might be worth regenerating configure with modern autoconf.

 Reviewed by <riastradh>
 Closes PR toolchain/53314


 To generate a diff of this commit:
 cvs rdiff -u -r1.1.1.1 -r1.2 src/external/gpl2/groff/dist/configure

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53314 CVS commit: [netbsd-8] src/external/gpl2/groff/dist
Date: Wed, 7 Nov 2018 09:12:28 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Wed Nov  7 09:12:28 UTC 2018

 Modified Files:
 	src/external/gpl2/groff/dist [netbsd-8]: configure

 Log Message:
 Pull up following revision(s) (requested by sevan in ticket #1083):

 	external/gpl2/groff/dist/configure: revision 1.2

 Test for other exit cases.

 It might be worth regenerating configure with modern autoconf.
 Reviewed by <riastradh>

 Closes PR toolchain/53314


 To generate a diff of this commit:
 cvs rdiff -u -r1.1.1.1 -r1.1.1.1.8.1 src/external/gpl2/groff/dist/configure

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.