NetBSD Problem Report #44547

From www@NetBSD.org  Fri Feb 11 00:59:06 2011
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id E1C0D63B8BA
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 11 Feb 2011 00:59:05 +0000 (UTC)
Message-Id: <20110211005905.1AACB63B842@www.NetBSD.org>
Date: Fri, 11 Feb 2011 00:59:05 +0000 (UTC)
From: acruhl@gmail.com
Reply-To: acruhl@gmail.com
To: gnats-bugs@NetBSD.org
Subject: pkgsrc build failure for g95 on NetBSD/cobalt
X-Send-Pr-Version: www-1.0

>Number:         44547
>Category:       pkg
>Synopsis:       pkgsrc build failure for g95 on NetBSD/cobalt
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    maya
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 11 01:00:00 +0000 2011
>Last-Modified:  Wed Sep 28 15:35:00 +0000 2016
>Originator:     Andy Ruhl
>Release:        NetBSD 5.1 cobalt
>Organization:
>Environment:
NetBSD taz 5.1_STABLE NetBSD 5.1_STABLE (PCIDEVS.FEB10_2011) #0: Thu Feb 10 17:27:29 MST 2011  root@foghorn:/usr/obj-cobalt/sys/arch/cobalt/compile/PCIDEVS.FEB10_2011 cobalt

>Description:
Build failure of pkgsrc/lang/g95:

/usr/pkg/bin/gmake  all-am
gmake[1]: Entering directory `/usr/pkgsrc/lang/g95/work/g95-0.92/libf95.a-0.92'
gcc -DHAVE_CONFIG_H -I.     -D_FILE_OFFSET_BITS=64 -DHAVE_REAL_10=0 -fPIC -g -O2 -MT mutex.o -MD -MP -MF .deps/mutex.Tpo -c -o mutex.o `test -f 'runtime/mutex.c' || echo './'`runtime/mutex.c
/var/tmp//ccKoVKRj.s: Assembler messages:
/var/tmp//ccKoVKRj.s:30: Error: opcode not supported on this processor: mips1 (mips1) `ll $5,0($4)'
/var/tmp//ccKoVKRj.s:32: Error: opcode not supported on this processor: mips1 (mips1) `sc $6,0($4)'
gmake[1]: *** [mutex.o] Error 1
gmake[1]: Leaving directory `/usr/pkgsrc/lang/g95/work/g95-0.92/libf95.a-0.92'
gmake: *** [all] Error 2
*** Error code 2

>How-To-Repeat:
cd pkgsrc/lang/g95 && make package
>Fix:
Not known

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->maya
Responsible-Changed-By: maya@NetBSD.org
Responsible-Changed-When: Thu, 08 Sep 2016 12:22:21 +0000
Responsible-Changed-Why:
take


From: coypu@SDF.ORG
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/44547
Date: Thu, 8 Sep 2016 12:20:39 +0000

 ll/sc are synchronization primitives for MIPS2 and above.
 it sounds as something in the package is defaulting for -mips3 for some
 things.

 (I think) base gcc defaults to -mips1, and it is unhappy about not being
 told it's working with mips >1 code.

 it's likely possible to force a default of mips1 (most "proper" fix, as
 we do support some mips1 platforms).

 workaround #1 is to force passing -mips3 to gcc (CFLAGS?)
 cobalt (RM52xx) is MIPS 5, so it should have no trouble with -mips3 as an
 option.

 workaround #2 (expensive compile time) is PKGSRC_FORTRAN=gfortran. it
 may result in similar failure.

 I will try to see if I can address this without a workaround.

From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/44547
Date: Sun, 11 Sep 2016 03:19:12 +0000

 On Thu, Sep 08, 2016 at 12:25:00PM +0000, coypu@SDF.ORG wrote:
  >  ll/sc are synchronization primitives for MIPS2 and above.
  >  it sounds as something in the package is defaulting for -mips3 for some
  >  things.

 So, it looks like the only thing that uses that are some questionable
 locks around malloc calls and some malloc-related memory metadata
 maintained by the runtime.

 There is no reason for the runtime to be multithreaded on a mips1;
 however, one would have to dig a lot deeper to be sure that it won't
 try to be. Meanwhile, we'd like the code to compile and run for mips3+
 such that it works when parallelized. So it really ought to check at
 runtime what kind of mips it is (which one does how in userland? sigh)
 and choose one or the other implementation of locking.

 You can also just fix the build by putting

    .set push
    .set mips32 (or .set mips3)
       :
    .set pop

 around the ll/sc sequence; but then the resulting binaries will crash
 on mips1.

 -- 
 David A. Holland
 dholland@netbsd.org

From: coypu@SDF.ORG
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/44547
Date: Thu, 22 Sep 2016 23:31:55 +0000

 --qDbXVdCdHGoSgWSk
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 This patch ought to do it, but I can't test it. I will do it soon.

 --qDbXVdCdHGoSgWSk
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="g95-mips.diff"

 Index: distinfo
 ===================================================================
 RCS file: /cvsroot/pkgsrc/lang/g95/distinfo,v
 retrieving revision 1.25
 diff -u -p -u -r1.25 distinfo
 --- distinfo	29 Dec 2015 23:34:46 -0000	1.25
 +++ distinfo	22 Sep 2016 23:30:55 -0000
 @@ -33,3 +33,4 @@ SHA1 (patch-libf95.a-0.93_math_ff.c) = d
  SHA1 (patch-libf95.a-0.93_math_x87.S) = 25dc2b613969947ae60fdc9b1dc6d9524b0157be
  SHA1 (patch-libf95.a-0.93_quad_power16.c) = eb6711bcd1018cac675dbbe212cd22a831a9d191
  SHA1 (patch-libf95.a-0.93_runtime_main.c) = dfde68072f38bf5bbb9c54ebeea5b9ce07d0c6be
 +SHA1 (patch-libf95.a-0.93_runtime_mutex.c) = 8252537e4cbc5fd53b3f89e4403b581e3c73e52c
 Index: patches/patch-libf95.a-0.93_runtime_mutex.c
 ===================================================================
 RCS file: patches/patch-libf95.a-0.93_runtime_mutex.c
 diff -N patches/patch-libf95.a-0.93_runtime_mutex.c
 --- /dev/null	1 Jan 1970 00:00:00 -0000
 +++ patches/patch-libf95.a-0.93_runtime_mutex.c	22 Sep 2016 23:30:55 -0000
 @@ -0,0 +1,22 @@
 +$NetBSD$
 +
 +gcc on netbsd/mips rejects ll/sc as it targets mips1 which lacks
 +these instructions. tell it it's mips3 code. it will crash
 +at runtime for mips1 (unlikely to compile this package), but
 +makes it possible to build for newer mips.
 +
 +--- libf95.a-0.93/runtime/mutex.c.orig	2008-09-17 03:45:13.000000000 +0000
 ++++ libf95.a-0.93/runtime/mutex.c
 +@@ -116,9 +116,12 @@ int old_val, temp;
 + 
 +     __asm__ __volatile__("   move %5, %2     \n"
 + 			 "1: move %2, %5     \n"
 ++			 "   .set push       \n"
 ++			 "   .set mips3      \n"
 + 			 "   ll   %0, %4     \n"
 + 			 "   bne  %0, %3, 2f \n"
 + 			 "   sc   %2, %1     \n"
 ++			 "   .set pop        \n"
 + 			 "   beqz %2, 1b     \n"
 + 			 "2:\n"
 + 			 : "=&r" (old_val), "=m" (*addr)

 --qDbXVdCdHGoSgWSk--

From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: maya@NetBSD.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org,
	acruhl@gmail.com
Subject: Re: pkg/44547
Date: Fri, 23 Sep 2016 11:08:22 +0200

 On Thu, Sep 22, 2016 at 11:35:01PM +0000, coypu@SDF.ORG wrote:
 >  This patch ought to do it, but I can't test it. I will do it soon.

 A better idea might be to use __sync_* and just depend on libc to get
 things right.

 Joerg

From: "Maya Rashish" <maya@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44547 CVS commit: pkgsrc/lang/g95
Date: Wed, 28 Sep 2016 15:34:54 +0000

 Module Name:	pkgsrc
 Committed By:	maya
 Date:		Wed Sep 28 15:34:54 UTC 2016

 Modified Files:
 	pkgsrc/lang/g95: distinfo
 Added Files:
 	pkgsrc/lang/g95/patches: patch-libf95.a-0.93_runtime_mutex.c

 Log Message:
 lang/g95: blindly apply patch to help netbsd/mips build issues.

 netbsd/mips gcc defaults to -mips1 which lacks ll/sc instructions
 (or anything like them), and rejects the assembly code used here.

 switch to mips3 (bare minimum for synchronization primitives) for
 these instructions. this will result in runtime failures (illegal
 instruction) on mips1, but we're unlikely to see any such users
 (MIPS3 was released in 1992).

 I'm not comfortable using the proper fix of switching to using
 __sync_* because that seems to be a compiler builtin and gcc 4.1.2
 might not have it.
 Also, that change requires careful testing that this 'dumb' change
 doesn't. Additionally, g95 is a dead end (upstream gone), so not
 worth the effort.

 PR pkg/44547: pkgsrc build failure for g95 on NetBSD/cobalt


 To generate a diff of this commit:
 cvs rdiff -u -r1.26 -r1.27 pkgsrc/lang/g95/distinfo
 cvs rdiff -u -r0 -r1.1 \
     pkgsrc/lang/g95/patches/patch-libf95.a-0.93_runtime_mutex.c

 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.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.