NetBSD Problem Report #48252

From www@NetBSD.org  Sun Sep 29 19:29:59 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 404187253A
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 29 Sep 2013 19:29:59 +0000 (UTC)
Message-Id: <20130929192957.518A1726F2@mollari.NetBSD.org>
Date: Sun, 29 Sep 2013 19:29:57 +0000 (UTC)
From: jdbaker@mylinuxisp.com
Reply-To: jdbaker@consolidated.net
To: gnats-bugs@NetBSD.org
Subject: x11/rxvt-unicode invalid assembly macro for sparc
X-Send-Pr-Version: www-1.0

>Number:         48252
>Notify-List:    jdbaker@consolidated.net
>Category:       pkg
>Synopsis:       x11/rxvt-unicode invalid assembly macro for sparc
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    morr
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 29 19:30:00 +0000 2013
>Last-Modified:  Sat May 23 20:20:01 +0000 2020
>Originator:     John D. Baker
>Release:        NetBSD/sparc-6.1_STABLE, pkgsrc-HEAD (pre-pkgsrc-2013Q3)
>Organization:
>Environment:
NetBSD jean 6.1_STABLE NetBSD 6.1_STABLE (JEAN) #26: Fri Sep 20 12:37:38 CDT 2013  sysop@verthandi.technoskunk.fur:/d0/build/netbsd-6/obj/sparc/sys/arch/sparc/compile/JEAN sparc

>Description:
Building x11/rxvt-unicode on NetBSD/sparc-6.1_STABLE fails as follows
(CFLAGS+=-save-temps):

[...]
c++ -I.. -I. -I. -I./../libev -I./../libptytty/src -DHAVE_CONFIG_H -I/usr/pkg/include -I/usr/X11R7/include -I/usr/include -I/usr/X11R7/include/freetype2 -D_REENTRANT -I/usr/X11R7/include  -D_REENTRANT -I/usr/X11R7/include -I/usr/pkg/include -I/usr/X11R7/include/freetype2 -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 -I/usr/X11R7/include  -I/usr/pkg/include -I/usr/X11R7/include/freetype2 -I/usr/X11R7/include -I/usr/X11R7/include/freetype2 -I/usr/X11R7/include -O2 -save-temps -I/usr/pkg/include -I/usr/X11R7/include -I/usr/include -I/usr/X11R7/include/freetype2 -w -I/usr/X11R7/include -c ev_cpp.C
In file included from ev_cpp.C:2:0:
./../libev/ev.c:1535:20: warning: 'ev_rt_now' initialized and declared 'extern'
ev_cpp.s: Assembler messages:
ev_cpp.s:1367: Error: Architecture mismatch on "membar".
ev_cpp.s:1367:  (Requires v9|v9a|v9b; requested architecture is sparclite.)
ev_cpp.s:1380: Error: Architecture mismatch on "membar".
ev_cpp.s:1380:  (Requires v9|v9a|v9b; requested architecture is sparclite.)
ev_cpp.s:1385: Error: Architecture mismatch on "membar".
ev_cpp.s:1385:  (Requires v9|v9a|v9b; requested architecture is sparclite.)
ev_cpp.s:1394: Error: Architecture mismatch on "membar".
ev_cpp.s:1394:  (Requires v9|v9a|v9b; requested architecture is sparclite.)
ev_cpp.s:1484: Error: Architecture mismatch on "membar".
ev_cpp.s:1484:  (Requires v9|v9a|v9b; requested architecture is sparclite.)
ev_cpp.s:1521: Error: Architecture mismatch on "membar".
ev_cpp.s:1521:  (Requires v9|v9a|v9b; requested architecture is sparclite.)
ev_cpp.s:1531: Error: Architecture mismatch on "membar".
ev_cpp.s:1531:  (Requires v9|v9a|v9b; requested architecture is sparclite.)
ev_cpp.s:3674: Error: Architecture mismatch on "membar".
ev_cpp.s:3674:  (Requires v9|v9a|v9b; requested architecture is sparclite.)
ev_cpp.s:3757: Error: Architecture mismatch on "membar".
ev_cpp.s:3757:  (Requires v9|v9a|v9b; requested architecture is sparclite.)
ev_cpp.s:3893: Error: Architecture mismatch on "membar".
ev_cpp.s:3893:  (Requires v9|v9a|v9b; requested architecture is sparclite.)
*** Error code 1

Stop.
make: stopped in /var/tmp/pkgsrc/x11/rxvt-unicode/work/rxvt-unicode-9.18/src
*** Error code 1

Stop.
make: stopped in /var/tmp/pkgsrc/x11/rxvt-unicode/work/rxvt-unicode-9.18
*** Error code 1

Stop.
make: stopped in /x/pkgsrc/x11/rxvt-unicode
*** Error code 1

Stop.



Looking at the first occurrance of the complaint in ev_cpp.s:

[...]
! 2135 "./../libev/ev.c" 1
        membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad
[...]


Looking in the vicinity of line 2135 of the referenced C source:

[...]
inline_speed void
evpipe_write (EV_P_ EV_ATOMIC_T *flag)
{
  ECB_MEMORY_FENCE; /* push out the write before this function was called, acquire flag */
[...]

Looking back at the top of the file reveals the variant macro
definition:

[...]
#if ECB_NO_SMP
  #define ECB_MEMORY_FENCE do { } while (0)
#endif

#ifndef ECB_MEMORY_FENCE
  #if ECB_GCC_VERSION(2,5) || defined __INTEL_COMPILER || (__llvm__ && __GNUC__) || __SUNPRO_C >= 0x5110 || __SUNPRO_CC >= 0x5110
    #if __i386 || __i386__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory")
      #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ (""                        : : : "memory")
      #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("")
    #elif __amd64 || __amd64__ || __x86_64 || __x86_64__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("mfence"   : : : "memory")
      #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ (""         : : : "memory")
      #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("")
    #elif __powerpc__ || __ppc__ || __powerpc64__ || __ppc64__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("sync"     : : : "memory")
    #elif defined __ARM_ARCH_6__  || defined __ARM_ARCH_6J__  \
       || defined __ARM_ARCH_6K__ || defined __ARM_ARCH_6ZK__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("mcr p15,0,%0,c7,c10,5" : : "r" (0) : "memory")
    #elif defined __ARM_ARCH_7__  || defined __ARM_ARCH_7A__  \
       || defined __ARM_ARCH_7M__ || defined __ARM_ARCH_7R__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("dmb"      : : : "memory")
    #elif __sparc || __sparc__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad" : : : "memory")
      #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad"                            : : : "memory")
      #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore             | #StoreStore")
    #elif defined __s390__ || defined __s390x__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("bcr 15,0" : : : "memory")
    #elif defined __mips__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("sync"     : : : "memory")
    #elif defined __alpha__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("mb"       : : : "memory")
    #elif defined __hppa__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ (""         : : : "memory")
      #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("")
    #elif defined __ia64__
      #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("mf"       : : : "memory")
    #endif
  #endif
#endif
[...]

And further conditional definitions of "ECB_MEMORY_FENCE" if the above
conditional didn't define it.

So, there appears to be ambiguity when selecting architecture-specific
code.  Or just an assembler macro that assumes all sparc is sparcv9.
Or something (Portability?  What's that?  But that's a different rant).

>How-To-Repeat:
Using pkgsrc-HEAD from about 201309280000Z, attempt to build
x11/rxvt-unicode on netbsd-6(5?)/sparc.

>Fix:
Workaround:  Change conditional to something that doesn't match __sparc
or __sparc__.  What's the correct one for NetBSD gcc?  (__sparc_v9__, if
I read the output of 'strings $(which gcc)' correctly.)

Any sparc assembly gurus think of a proper macro for non-v9 sparc?

>Release-Note:

>Audit-Trail:
From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/48252: x11/rxvt-unicode invalid assembly macro for sparc
Date: Mon, 30 Sep 2013 09:47:47 -0500 (CDT)

 Changing the affected conditionals to "__sparc_v9" and "__sparc_v9__"
 respectively, allows build to succeed on NetBSD/sparc-6.1_STABLE.

 I do not currently have a sparc64 system set up, so I cannot test whether
 the change does the right thing for that platform.


 --- libev/ev.c.orig	2013-09-29 14:52:28.000000000 -0500
 +++ libev/ev.c	2013-09-29 14:53:15.000000000 -0500
 @@ -622,7 +622,7 @@
       #elif defined __ARM_ARCH_7__  || defined __ARM_ARCH_7A__  \
          || defined __ARM_ARCH_7M__ || defined __ARM_ARCH_7R__
         #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("dmb"      : : : "memory")
 -    #elif __sparc || __sparc__
 +    #elif __sparc_v9 || __sparc_v9__
         #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad" : : : "memory")
         #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad"                            : : : "memory")
         #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore             | #StoreStore")

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    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@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/48252: x11/rxvt-unicode invalid assembly macro for sparc
Date: Tue, 1 Oct 2013 19:38:01 -0500 (CDT)

 On Mon, 30 Sep 2013, John D. Baker wrote:

 > Changing the affected conditionals to "__sparc_v9" and "__sparc_v9__"
 > respectively, allows build to succeed on NetBSD/sparc-6.1_STABLE.

 I should also note that the resulting binary appears to work just fine
 on NetBSD/sparc-6.1_STABLE.

 > I do not currently have a sparc64 system set up, so I cannot test whether
 > the change does the right thing for that platform.

 Also, it is not clear what symbols are defined on non-NetBSD platforms
 where pkgsrc may be used on sparc or sparc64.  The patch I posted may
 be insufficient to cover other cases.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    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: "OBATA Akio" <obata@lins.jp>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/48252: x11/rxvt-unicode invalid assembly macro for sparc
Date: Fri, 07 Feb 2014 19:07:06 +0900

 On Mon, 30 Sep 2013 23:50:01 +0900, John D. Baker <jdbaker@mylinuxisp.com> wrote:

 >  --- libev/ev.c.orig	2013-09-29 14:52:28.000000000 -0500
 >  +++ libev/ev.c	2013-09-29 14:53:15.000000000 -0500
 >  @@ -622,7 +622,7 @@
 >        #elif defined __ARM_ARCH_7__  || defined __ARM_ARCH_7A__  \
 >           || defined __ARM_ARCH_7M__ || defined __ARM_ARCH_7R__
 >          #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("dmb"      : : : "memory")
 >  -    #elif __sparc || __sparc__
 >  +    #elif __sparc_v9 || __sparc_v9__
 >          #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad" : : : "memory")
 >          #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad"                            : : : "memory")
 >          #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore             | #StoreStore")
 > --

 Can you reproduce this issue in devel/libev too?

 Here are libev upstream changes, probably related this issue:
 http://cvs.schmorp.de/libev/ev.c?r1=1.461&r2=1.462

 -    #elif __sparc || __sparc__
 +    #elif (__sparc || __sparc__) && !__sparcv8


 -- 
 OBATA Akio / obata@lins.jp

From: "John D. Baker" <jdbaker@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/48252: x11/rxvt-unicode invalid assembly macro for sparc
Date: Wed, 12 Feb 2014 17:17:58 -0600 (CST)

 On Fri, 7 Feb 2014, OBATA Akio wrote:

 > Can you reproduce this issue in devel/libev too?

 Yes.

 > Here are libev upstream changes, probably related this issue:
 > http://cvs.schmorp.de/libev/ev.c?r1=1.461&r2=1.462
 >
 > -    #elif __sparc || __sparc__
 > +    #elif (__sparc || __sparc__) && !__sparcv8

 The above is not sufficient.  The NetBSD/sparc C compiler predefines only
 "__sparc" and "__sparc__" when no "-mcpu=xxxx" directive is present.  If,
 for example, "-mcpu=v8" was specified, "__sparc_v8__" would be defined
 in addition to the other macros.

 It would be nice if a sparcv9-specific macro could be guaranteed defined
 on sparc64 toolchains when no cpu-tuning options are given.

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    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@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/48252: x11/rxvt-unicode invalid assembly macro for sparc
Date: Mon, 7 Jul 2014 10:29:47 -0500 (CDT)

 On Wed, 12 Feb 2014, John D. Baker wrote:

 > On Fri, 7 Feb 2014, OBATA Akio wrote:
 > 
 > > Here are libev upstream changes, probably related this issue:
 > > http://cvs.schmorp.de/libev/ev.c?r1=1.461&r2=1.462
 > > 
 > > -    #elif __sparc || __sparc__
 > > +    #elif (__sparc || __sparc__) && !__sparcv8

 As of pkgsrc-2014Q2 I see the above is now in the local libev/ev.c
 included with rxvt-unicode v9.20.  As I wrote then:

 > The above is not sufficient.  The NetBSD/sparc C compiler predefines only
 > "__sparc" and "__sparc__" when no "-mcpu=xxxx" directive is present.  If,
 > for example, "-mcpu=v8" was specified, "__sparc_v8__" would be defined
 > in addition to the other macros.
 > 
 > It would be nice if a sparcv9-specific macro could be guaranteed defined
 > on sparc64 toolchains when no cpu-tuning options are given.

 I don't know whether this will work on actual sparc64 toolchains, but
 to compile for generic sparc (the assembler claims the default to be
 "sparclite" but no compiler symbols to that effect are defined), I must
 now use the following patch:

 +--- libev/ev.c.orig	2014-03-25 14:26:35.000000000 -0500
 ++++ libev/ev.c	2014-07-06 11:57:06.000000000 -0500
 +@@ -629,7 +629,7 @@ struct signalfd_siginfo
 +       #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("dmb"      : : : "memory")
 +     #elif __aarch64__
 +       #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("dmb ish"  : : : "memory")
 +-    #elif (__sparc || __sparc__) && !__sparcv8
 ++    #elif (__sparc || __sparc__) && (__sparcv9 || __sparcv9__ || __sparc_v9__)
 +       #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad" : : : "memory")
 +       #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad"                            : : : "memory")
 +       #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore             | #StoreStore")

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    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@mylinuxisp.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/48252: x11/rxvt-unicode invalid assembly macro for sparc
Date: Fri, 18 Mar 2016 21:22:22 -0500 (CDT)

 As of rxvt-unicode 9.22, the symbol definition test has been changed,
 but is still inadequate for plain sparc w/o "-mcpu=v8".  As such, the
 revised patch is as follows:

 +--- libev/ev.c.orig	2015-12-20 15:12:53.000000000 -0600
 ++++ libev/ev.c	2016-03-18 21:08:43.000000000 -0500
 +@@ -681,7 +681,7 @@ struct signalfd_siginfo
 +       #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("dmb"      : : : "memory")
 +     #elif __aarch64__
 +       #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("dmb ish"  : : : "memory")
 +-    #elif (__sparc || __sparc__) && !(__sparc_v8__ || defined __sparcv8)
 ++    #elif (__sparc || __sparc__) && (__sparcv9 || __sparcv9__ || __sparc_v9__)
 +       #define ECB_MEMORY_FENCE         __asm__ __volatile__ ("membar #LoadStore | #LoadLoad | #StoreStore | #StoreLoad" : : : "memory")
 +       #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad"                            : : : "memory")
 +       #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore             | #StoreStore")

 -- 
 |/"\ John D. Baker, KN5UKS               NetBSD     Darwin/MacOS X
 |\ / jdbaker[snail]mylinuxisp[flyspeck]com    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

Responsible-Changed-From-To: pkg-manager->morr
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Sat, 19 Mar 2016 10:43:25 +0000
Responsible-Changed-Why:
Over to last updater in the hope he commits the patch :-)


From: "John D. Baker" <jdbaker@consolidated.net>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/48252: x11/rxvt-unicode invalid assembly macro for sparc
Date: Sat, 23 May 2020 15:19:25 -0500 (CDT)

 The following commit to "devel/libev":

   http://mail-index.netbsd.org/pkgsrc-changes/2020/05/23/msg214389.html

 (or a version of it) also applies to "x11/rxvt-unicode", eliminating
 the need for my local patches.

 Tested on NetBSD/sparc-9.0_STABLE.

 +Index: x11/rxvt-unicode/Makefile
 +===================================================================
 +RCS file: /cvsroot/pkgsrc/x11/rxvt-unicode/Makefile,v
 +retrieving revision 1.61
 +diff -u -p -r1.61 Makefile
 +--- x11/rxvt-unicode/Makefile	11 Aug 2019 13:25:18 -0000	1.61
 ++++ x11/rxvt-unicode/Makefile	23 May 2020 20:17:58 -0000
 +@@ -25,6 +25,13 @@ INSTALLATION_DIRS+=	share/doc/rxvt-unico
 + 
 + LIBS.SunOS+=	-lnsl -lsocket
 + 
 ++.include "../../mk/bsd.prefs.mk"
 ++
 ++.if !empty(MACHINE_PLATFORM:MNetBSD-*-sparc)
 ++# Prevent libev/ev.c from using v9 memory barrier instructions
 ++CPPFLAGS+=     -D__sparc_v8__=1
 ++.endif
 ++
 + post-install:
 + 	${INSTALL_DATA} ${WRKSRC}/README.FAQ \
 + 		${DESTDIR}${PREFIX}/share/doc/rxvt-unicode

 -- 
 |/"\ 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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.