NetBSD Problem Report #56498

From jdbaker@consolidated.net  Sun Nov 14 04:01:13 2021
Return-Path: <jdbaker@consolidated.net>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_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 ABC8E1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 14 Nov 2021 04:01:13 +0000 (UTC)
Message-Id: <20211114024515.E7A4713E118@spike.technoskunk.fur>
Date: Sat, 13 Nov 2021 20:45:15 -0600 (CST)
From: jdbaker@consolidated.net
Reply-To: jdbaker@consolidated.net
To: gnats-bugs@NetBSD.org
Subject: "devel/m4" build fails on netbsd-9/sparc
X-Send-Pr-Version: 3.95

>Number:         56498
>Category:       pkg
>Synopsis:       "devel/m4" build fails on netbsd-9/sparc
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 14 04:05:01 +0000 2021
>Closed-Date:    Fri Nov 19 09:31:17 +0000 2021
>Last-Modified:  Fri Nov 19 09:31:17 +0000 2021
>Originator:     John D. Baker
>Release:        NetBSD/sparc-9.2_STABLE, pkgsrc-2021Q3
>Organization:
>Environment:
System: NetBSD jean.technoskunk.fur 9.2_STABLE NetBSD 9.2_STABLE (JEAN) #116: Thu Oct 28 02:29:53 CDT 2021  sysop@plex760.technoskunk.fur:/r0/build/netbsd-9/obj/sparc/sys/arch/sparc/compile/JEAN sparc
Architecture: sparc
Machine: sparc
>Description:
Building "devel/m4" from pkgsrc-2021Q3 on NetBSD/sparc-9.2_STABLE fails
with:

[...]
Making all in lib
--- all ---
/usr/bin/make  all-am
--- ftello.o ---
--- getcwd-lgpl.o ---
  CC       getcwd-lgpl.o
--- ftello.o ---
  CC       ftello.o
ftello.c: In function 'rpl_ftello':
ftello.c:122:12: error: 'FILE {aka struct __sFILE}' has no member named '_flag'; did you mean '_flags'?
   if (fp_->_flag & _IOWRT)
            ^~~~~
            _flags
ftello.c:122:20: error: '_IOWRT' undeclared (first use in this function); did you mean '_IOFBF'?
   if (fp_->_flag & _IOWRT)
                    ^~~~~~
                    _IOFBF
ftello.c:122:20: note: each undeclared identifier is reported only once for each function it appears in
ftello.c:133:21: error: 'FILE {aka struct __sFILE}' has no member named '_flag'; did you mean '_flags'?
           if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL)
                     ^~~~~
                     _flags
--- getdtablesize.o ---
--- ftello.o ---
ftello.c:133:48: error: 'FILE {aka struct __sFILE}' has no member named '_base'
           if ((fp_->_flag & _IONBF) == 0 && fp_->_base != NULL)
                                                ^~
--- getdtablesize.o ---
  CC       getdtablesize.o
--- ftello.o ---
ftello.c:134:25: error: 'FILE {aka struct __sFILE}' has no member named '_ptr'; did you mean '_p'?
             pos += fp_->_ptr - fp_->_base;
                         ^~~~
                         _p
ftello.c:134:35: error: 'FILE {aka struct __sFILE}' has no member named '_base'
             pos += fp_->_ptr - fp_->_base;
                                   ^~
*** [ftello.o] Error code 1

make[3]: stopped in /d0/build/pkgsrc/devel/m4/work/m4-1.4.19/lib
1 error
[...]

>How-To-Repeat:
See Above.
>Fix:

>Release-Note:

>Audit-Trail:
From: "John D. Baker" <jdbaker@consolidated.net>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/56498: "devel/m4" build fails on netbsd-9/sparc
Date: Sun, 14 Nov 2021 09:42:56 -0600 (CST)

 During the configure phase, right after the check for sparcV8+ instructions,
 all subsequent compilations of the "conftest" proglets unconditionally
 include "-mcpu=v9":

 [...]
 configure:8810: checking whether SPARC v8+ instructions are supported
 configure:8827: gcc -c -O2 -D_FORTIFY_SOURCE=2  conftest.c >&5
 /tmp/cccJEe4g.s: Assembler messages:
 /tmp/cccJEe4g.s:12: Error: Architecture mismatch on "membar 2".
 /tmp/cccJEe4g.s:12: (Requires v9|v9a|v9b|v9c|v9d|v9e|v9v|v9m|m8; requested architecture is sparclite.)
 configure:8827: $? = 1
 configure: failed program was:
 | /* confdefs.h */
 | #define PACKAGE_NAME "GNU M4"
 | #define PACKAGE_TARNAME "m4"
 | #define PACKAGE_VERSION "1.4.19"
 | #define PACKAGE_STRING "GNU M4 1.4.19"
 | #define PACKAGE_BUGREPORT "bug-m4@gnu.org"
 | #define PACKAGE_URL "https://www.gnu.org/software/m4/"
 | #define PACKAGE "m4"
 | #define VERSION "1.4.19"
 | #define HAVE_STDIO_H 1
 | #define HAVE_STDLIB_H 1
 | #define HAVE_STRING_H 1
 | #define HAVE_INTTYPES_H 1
 | #define HAVE_STDINT_H 1
 | #define HAVE_STRINGS_H 1
 | #define HAVE_SYS_STAT_H 1
 | #define HAVE_SYS_TYPES_H 1
 | #define HAVE_UNISTD_H 1
 | #define HAVE_WCHAR_H 1
 | #define HAVE_PTHREAD_H 1
 | #define HAVE_SYS_PARAM_H 1
 | #define HAVE_SYS_SOCKET_H 1
 | #define HAVE_DIRENT_H 1
 | #define HAVE_GETOPT_H 1
 | #define HAVE_SYS_CDEFS_H 1
 | #define HAVE_THREADS_H 1
 | #define HAVE_ICONV_H 1
 | #define HAVE_LIMITS_H 1
 | #define HAVE_WCTYPE_H 1
 | #define HAVE_LANGINFO_H 1
 | #define HAVE_MATH_H 1
 | #define HAVE_SYS_MMAN_H 1
 | #define HAVE_MALLOC_H 1
 | #define HAVE_SPAWN_H 1
 | #define HAVE_SYS_TIME_H 1
 | #define HAVE_SYS_WAIT_H 1
 | #define HAVE_ARPA_INET_H 1
 | #define HAVE_SEMAPHORE_H 1
 | #define HAVE_NETDB_H 1
 | #define HAVE_NETINET_IN_H 1
 | #define HAVE_SYS_SELECT_H 1
 | #define HAVE_SYS_IOCTL_H 1
 | #define HAVE_SYS_UIO_H 1
 | #define STDC_HEADERS 1
 | #define _ALL_SOURCE 1
 | #define _DARWIN_C_SOURCE 1
 | #define _GNU_SOURCE 1
 | #define _HPUX_ALT_XOPEN_SOCKET_API 1
 | #define _NETBSD_SOURCE 1
 | #define _OPENBSD_SOURCE 1
 | #define _POSIX_PTHREAD_SEMANTICS 1
 | #define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1
 | #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
 | #define __STDC_WANT_IEC_60559_DFP_EXT__ 1
 | #define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
 | #define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
 | #define __STDC_WANT_LIB_EXT2__ 1
 | #define __STDC_WANT_MATH_SPEC_FUNCS__ 1
 | #define _TANDEM_SOURCE 1
 | #define __EXTENSIONS__ 1
 | #define HAVE_FSEEKO 1
 | /* end confdefs.h.  */
 | 
 | int
 | main (void)
 | {
 | asm volatile ("membar 2");
 |   ;
 |   return 0;
 | }
 configure:8836: result: no
 configure:9612: checking for unsigned long long int
 configure:9652: gcc -mcpu=v9 -o conftest -O2 -D_FORTIFY_SOURCE=2  -Wl,-R/usr/pkg/lib conftest.c  >&5
 configure:9652: $? = 0
 configure:9662: result: yes
 configure:9672: checking for long long int
 configure:9712: gcc -mcpu=v9 -o conftest -O2 -D_FORTIFY_SOURCE=2  -Wl,-R/usr/pkg/lib conftest.c  >&5
 configure:9712: $? = 0
 configure:9712: ./conftest
 [1]   Illegal instruction (core dumped) ./conftest${ac_exeext}
 configure:9712: $? = 132
 configure: program exited with status 132
 configure: failed program was:
 | /* confdefs.h */
 | #define PACKAGE_NAME "GNU M4"
 | #define PACKAGE_TARNAME "m4"
 | #define PACKAGE_VERSION "1.4.19"
 | #define PACKAGE_STRING "GNU M4 1.4.19"
 | #define PACKAGE_BUGREPORT "bug-m4@gnu.org"
 | #define PACKAGE_URL "https://www.gnu.org/software/m4/"
 | #define PACKAGE "m4"
 | #define VERSION "1.4.19"
 | #define HAVE_STDIO_H 1
 | #define HAVE_STDLIB_H 1
 | #define HAVE_STRING_H 1
 | #define HAVE_INTTYPES_H 1
 | #define HAVE_STDINT_H 1
 | #define HAVE_STRINGS_H 1
 | #define HAVE_SYS_STAT_H 1
 | #define HAVE_SYS_TYPES_H 1
 | #define HAVE_UNISTD_H 1
 | #define HAVE_WCHAR_H 1
 | #define HAVE_PTHREAD_H 1
 | #define HAVE_SYS_PARAM_H 1
 | #define HAVE_SYS_SOCKET_H 1
 | #define HAVE_DIRENT_H 1
 | #define HAVE_GETOPT_H 1
 | #define HAVE_SYS_CDEFS_H 1
 | #define HAVE_THREADS_H 1
 | #define HAVE_ICONV_H 1
 | #define HAVE_LIMITS_H 1
 | #define HAVE_WCTYPE_H 1
 | #define HAVE_LANGINFO_H 1
 | #define HAVE_MATH_H 1
 | #define HAVE_SYS_MMAN_H 1
 | #define HAVE_MALLOC_H 1
 | #define HAVE_SPAWN_H 1
 | #define HAVE_SYS_TIME_H 1
 | #define HAVE_SYS_WAIT_H 1
 | #define HAVE_ARPA_INET_H 1
 | #define HAVE_SEMAPHORE_H 1
 | #define HAVE_NETDB_H 1
 | #define HAVE_NETINET_IN_H 1
 | #define HAVE_SYS_SELECT_H 1
 | #define HAVE_SYS_IOCTL_H 1
 | #define HAVE_SYS_UIO_H 1
 | #define STDC_HEADERS 1
 | #define _ALL_SOURCE 1
 | #define _DARWIN_C_SOURCE 1
 | #define _GNU_SOURCE 1
 | #define _HPUX_ALT_XOPEN_SOCKET_API 1
 | #define _NETBSD_SOURCE 1
 | #define _OPENBSD_SOURCE 1
 | #define _POSIX_PTHREAD_SEMANTICS 1
 | #define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1
 | #define __STDC_WANT_IEC_60559_BFP_EXT__ 1
 | #define __STDC_WANT_IEC_60559_DFP_EXT__ 1
 | #define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1
 | #define __STDC_WANT_IEC_60559_TYPES_EXT__ 1
 | #define __STDC_WANT_LIB_EXT2__ 1
 | #define __STDC_WANT_MATH_SPEC_FUNCS__ 1
 | #define _TANDEM_SOURCE 1
 | #define __EXTENSIONS__ 1
 | #define HAVE_FSEEKO 1
 | #define GNULIB_REGEX_SINGLE_THREAD 1
 | #define GNULIB_MBRTOWC_SINGLE_THREAD 1
 | #define GNULIB_WCHAR_SINGLE_LOCALE 1
 | #define HAVE_UNSIGNED_LONG_LONG_INT 1
 | /* end confdefs.h.  */
 | #include <limits.h>
 |                  #ifndef LLONG_MAX
 |                  # define HALF                           (1LL << (sizeof (long long int) * CHAR_BIT - 2))
 |                  # define LLONG_MAX (HALF - 1 + HALF)
 |                  #endif
 | int
 | main (void)
 | {
 | long long int n = 1;
 |                  int i;
 |                  for (i = 0; ; i++)
 |                    {
 |                      long long int m = n << i;
 |                      if (m >> i != n)
 |                        return 1;
 |                      if (LLONG_MAX / 2 < m)
 |                        break;
 |                    }
 |                  return 0;
 |   ;
 |   return 0;
 | }
 configure:9725: result: no
 [...]

 Some "conftest" proglets pass, so apparently no sparcV9 instructions
 were emitted by the compiler, but a number of them fail with Illegal
 Instruction, causing the configure script to assume that a particular
 feature or capability is not available, prompting substitution with its
 own implementation in "lib", and then failing later.

 Perhaps the configure script assumes that on a non-V9 system using
 "-mcpu=v9" is a NOP, but that's clearly not the case on NetBSD, since
 running sparc userland on sparc64 hardware will try to take advantage
 of v9 instructions where it can.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]consolidated[flyspeck]net  OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: "John D. Baker" <jdbaker@consolidated.net>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/56498: "devel/m4" build fails on netbsd-9/sparc
Date: Sun, 14 Nov 2021 08:38:29 -0600 (CST)

 Since "m4" builds fine on netbsd-9/amd64, I started looking at the build
 output.  The amd64 build doesn't build anything in the "lib" directory,
 so neither should sparc.

 Looking at "config.log", there are at least two instances where the
 generated "conftest" executable terminates with an illegal instruction.

 Something is mis-detecting the CPU and all the conftest programs are
 being compiled with "-mcpu=v9".  No wonder some fail with SIGILL!

 The host is a SPARCstation 5, 110MHz MicroSPARC-II, so it shouldn't
 be detected as sparcV9.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]consolidated[flyspeck]net  OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: "John D. Baker" <jdbaker@consolidated.net>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/56498: "devel/m4" build fails on netbsd-9/sparc
Date: Sun, 14 Nov 2021 09:50:59 -0600 (CST)

 Looking at the configure script, I think there's a typo in the section
 that tests for sparc v8+:

 [...]
   case "$host_cpu" in
     sparc*)
       if test -n "$GCC"; then
         { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether SPARC v8+
  instructions are supported" >&5
 printf %s "checking whether SPARC v8+ instructions are supported... " >&6; }
 if test ${gl_cv_sparc_v8plus+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */

 int
 main (void)
 {
 asm volatile ("membar 2");
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"
 then :
   gl_cv_sparc_v8plus=yes
 else $as_nop
   gl_cv_sparc_v8plus=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext

 fi
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sparc_v8plus" >&5
 printf "%s\n" "$gl_cv_sparc_v8plus" >&6; }
         if test $gl_cv_sparc_v8plus = no; then
 >>>                                 ^          <<<
                               CC="$CC -mcpu=v9"
           CXX="$CXX -mcpu=v9"
         fi
       fi
       ;;
   esac
 [...]

 I believe the line marked with ">>> ^  <<<" below it should be "!="
 rather than "=".

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]consolidated[flyspeck]net  OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: "John D. Baker" <jdbaker@consolidated.net>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/56498: "devel/m4" build fails on netbsd-9/sparc
Date: Sun, 14 Nov 2021 11:18:47 -0600 (CST)

 The following patch allows a successful build on sparc:

 +--- configure.orig	2021-11-14 09:54:26.066002850 -0600
 ++++ configure	2021-11-14 09:55:14.061722618 -0600
 +@@ -8835,7 +8835,7 @@ rm -f core conftest.err conftest.$ac_obj
 + fi
 + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_sparc_v8plus" >&5
 + printf "%s\n" "$gl_cv_sparc_v8plus" >&6; }
 +-        if test $gl_cv_sparc_v8plus = no; then
 ++        if test $gl_cv_sparc_v8plus != no; then
 +                               CC="$CC -mcpu=v9"
 +           CXX="$CXX -mcpu=v9"
 +         fi

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]consolidated[flyspeck]net  OpenBSD            FreeBSD
 | X  No HTML/proprietary data in email.   BSD just sits there and works!
 |/ \ GPGkeyID:  D703 4A7E 479F 63F8 D3F4  BD99 9572 8F23 E4AD 1645

From: "Nia Alarie" <nia@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56498 CVS commit: pkgsrc/devel/m4
Date: Mon, 15 Nov 2021 13:20:04 +0000

 Module Name:	pkgsrc
 Committed By:	nia
 Date:		Mon Nov 15 13:20:04 UTC 2021

 Modified Files:
 	pkgsrc/devel/m4: distinfo
 Added Files:
 	pkgsrc/devel/m4/patches: patch-configure patch-m4_sparcv8+.m4

 Log Message:
 m4: fix building on sparcv8

 from John D. Baker in PR pkg/56498


 To generate a diff of this commit:
 cvs rdiff -u -r1.51 -r1.52 pkgsrc/devel/m4/distinfo
 cvs rdiff -u -r0 -r1.1 pkgsrc/devel/m4/patches/patch-configure \
     pkgsrc/devel/m4/patches/patch-m4_sparcv8+.m4

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

State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Fri, 19 Nov 2021 09:31:17 +0000
State-Changed-Why:
Fixed by nia, thanks for the PR! Please send this upstream.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.