NetBSD Problem Report #49425

From reinoud@diablo.13thmonkey.org  Fri Nov 28 15:36:42 2014
Return-Path: <reinoud@diablo.13thmonkey.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 21D22A5B2E
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 28 Nov 2014 15:36:42 +0000 (UTC)
Message-Id: <20141128153638.DE1BBC1347B@diablo.13thmonkey.org>
Date: Fri, 28 Nov 2014 16:36:38 +0100 (CET)
From: reinoud@diablo.13thmonkey.org
Reply-To: reinoud@diablo.13thmonkey.org
To: gnats-bugs@NetBSD.org
Subject: internal compiler error compiling riscv userland
X-Send-Pr-Version: 3.95

>Number:         49425
>Category:       toolchain
>Synopsis:       internal compiler error compiling riscv userland
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 28 15:40:00 +0000 2014
>Closed-Date:    Thu Dec 20 22:26:05 +0000 2018
>Last-Modified:  Thu Dec 20 22:26:05 +0000 2018
>Originator:     Reinoud Zandijk
>Release:        NetBSD 7.99.1
>Organization:
NetBSD

>Environment:


System: NetBSD diablo.13thmonkey.org 7.99.1 NetBSD 7.99.1 (GENERIC) #1: Thu Oct 30 21:35:29 CET 2014 reinoud@diablo.13thmonkey.org:/usr/sources/cvs.netbsd.org/src-clean/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

While trying to build the NetBSD userland part using 
   ./build.sh -a riscv64 -m riscv -u build

The compilation terminates with:

dependall ===> lib/../external/gpl3/gcc/lib/libasan
#   compile  libasan/asan_allocator2.o
/usr/sources/cvs.netbsd.org/src-clean/obj/tooldir.NetBSD-7.99.1-amd64/bin/riscv64--netbsd-c++
-frandom-seed=5fba94ba -O2 -Werror
--sysroot=/usr/sources/cvs.netbsd.org/src-clean/obj/destdir.riscv
-I/usr/sources/cvs.netbsd.org/src-clean/external/gpl3/gcc/dist/libsanitizer/include
-I/usr/sources/cvs.netbsd.org/src-clean/external/gpl3/gcc/dist/libsanitizer
-c
/usr/sources/cvs.netbsd.org/src-clean/external/gpl3/gcc/dist/libsanitizer/asan/asan_allocator2.cc
-o asan_allocator2.o
In file included from
/usr/sources/cvs.netbsd.org/src-clean/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_atomic.h:56:0,
                 from
/usr/sources/cvs.netbsd.org/src-clean/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_mutex.h:15,
                 from
/usr/sources/cvs.netbsd.org/src-clean/external/gpl3/gcc/dist/libsanitizer/asan/asan_thread_registry.h:19,
                 from
/usr/sources/cvs.netbsd.org/src-clean/external/gpl3/gcc/dist/libsanitizer/asan/asan_allocator2.cc:22:
/usr/sources/cvs.netbsd.org/src-clean/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h:
In function '__asan::AsanChunk*
__asan::GetAsanChunkByAddr(__sanitizer::uptr)':
/usr/sources/cvs.netbsd.org/src-clean/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h:92:3:
internal compiler error: in gen_lowpart_general, at rtlhooks.c:59
   v = __sync_lock_test_and_set(&a->val_dont_use, v);
   ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://www.NetBSD.org/Misc/send-pr.html> for instructions.



>How-To-Repeat:
Just try to compile with -current src tree

>Fix:

internal gcc issue or hopefully fixed with gcc 4.9 ?

>Release-Note:

>Audit-Trail:
From: Dennis Ferguson <dennis.c.ferguson@gmail.com>
To: gnats-bugs@NetBSD.org
Cc: toolchain-manager@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: toolchain/49425: internal compiler error compiling riscv userland
Date: Sat, 29 Nov 2014 10:50:25 +0800

 You can work around that with the following patch.  I haven't gotten
 around to figuring out whether this problem also occurs in the compilers
 the RISC-V people maintain or is an issue unique to the gcc 4.8.3
 support.

 Dennis Ferguson

 Index: external/gpl3/gcc/lib/libasan/Makefile
 ===================================================================
 RCS file: /cvsroot/src/external/gpl3/gcc/lib/libasan/Makefile,v
 retrieving revision 1.7
 diff -u -r1.7 Makefile
 --- external/gpl3/gcc/lib/libasan/Makefile	23 Oct 2014 23:31:26 -0000	1.7
 +++ external/gpl3/gcc/lib/libasan/Makefile	29 Nov 2014 02:42:07 -0000
 @@ -56,4 +56,10 @@
  LIBDPLIBS+=    stdc++ ${.CURDIR}/../libstdc++-v3
  LIBDPLIBS+=    pthread ${.CURDIR}/../../../../../lib/libpthread

 +.if ${MACHINE_ARCH} == "riscv64"
 +COPTS.asan_allocator2.cc += -O0
 +COPTS.sanitizer_netbsd.cc += -O0
 +.endif
 +
 +
  .include <bsd.lib.mk>

From: Martin Husemann <martin@duskware.de>
To: Dennis Ferguson <dennis.c.ferguson@gmail.com>
Cc: gnats-bugs@NetBSD.org, toolchain-manager@netbsd.org,
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: toolchain/49425: internal compiler error compiling riscv userland
Date: Sat, 29 Nov 2014 09:55:09 +0100

 On Sat, Nov 29, 2014 at 10:50:25AM +0800, Dennis Ferguson wrote:
 > You can work around that with the following patch.  I haven't gotten
 > around to figuring out whether this problem also occurs in the compilers
 > the RISC-V people maintain or is an issue unique to the gcc 4.8.3
 > support.

 VAX has similar issues if the global -O1 is removed from sys.mk.
 Is -O1 enough for risc-v as well?

 Martin

From: Dennis Ferguson <dennis.c.ferguson@gmail.com>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@NetBSD.org,
 toolchain-manager@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: toolchain/49425: internal compiler error compiling riscv userland
Date: Sat, 29 Nov 2014 17:19:04 +0800

 On 29 Nov, 2014, at 16:55 , Martin Husemann <martin@duskware.de> wrote:
 > VAX has similar issues if the global -O1 is removed from sys.mk.
 > Is -O1 enough for risc-v as well?

 Unfortunately no.  I got the same errors at -O1, only -O0 fixed it.
 I guess a global -O0 would work, as might a global -O0 for C++ only
 if that's possible, but everything other than those 2 files compile
 okay at -O2.




From: Martin Husemann <martin@duskware.de>
To: Dennis Ferguson <dennis.c.ferguson@gmail.com>
Cc: gnats-bugs@NetBSD.org, toolchain-manager@netbsd.org,
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: toolchain/49425: internal compiler error compiling riscv userland
Date: Mon, 1 Dec 2014 09:10:12 +0100

 On Sat, Nov 29, 2014 at 05:19:04PM +0800, Dennis Ferguson wrote:
 > 
 > On 29 Nov, 2014, at 16:55 , Martin Husemann <martin@duskware.de> wrote:
 > > VAX has similar issues if the global -O1 is removed from sys.mk.
 > > Is -O1 enough for risc-v as well?
 > 
 > Unfortunately no.  I got the same errors at -O1, only -O0 fixed it.
 > I guess a global -O0 would work, as might a global -O0 for C++ only
 > if that's possible, but everything other than those 2 files compile
 > okay at -O2.

 OK, so the list of files differs (see toolchain/49434) and -O1 vs -O0;
 these are likely different MD gcc bugs.

 Reinoud or you should report this upstream.

 Commiting the workaround for now sounds OK to me (I would do with the vax
 variant, but the default VAX build does not trigger it, so no point there).

 Martin

From: Dennis Ferguson <dennis.c.ferguson@gmail.com>
To: Martin Husemann <martin@duskware.de>
Cc: gnats-bugs@NetBSD.org,
 toolchain-manager@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org,
 Matt Thomas <matt@3am-software.com>
Subject: Re: toolchain/49425: internal compiler error compiling riscv userland
Date: Mon, 1 Dec 2014 16:44:18 +0800

 On 1 Dec, 2014, at 16:10 , Martin Husemann <martin@duskware.de> wrote:
 > OK, so the list of files differs (see toolchain/49434) and -O1 vs -O0;
 > these are likely different MD gcc bugs.
 > 
 > Reinoud or you should report this upstream.

 Yes, though for RISC-V compiler it is a bit ambiguous who the upstream
 is.  As far as I can tell the RISC-V people have only done their MD for
 gcc 4.6.something and 4.9, so it may be Matt(??) who moved this into 4.8.3.
 If I can get one of the supported RISC-V compilers to build I can try it
 to see if it gets the same ICE and report that, otherwise the workaround
 may need to stay until NetBSD moves to a gcc version they also support.

From: Matt Thomas <matt@3am-software.com>
To: Dennis Ferguson <dennis.c.ferguson@gmail.com>
Cc: Martin Husemann <martin@duskware.de>,
 gnats-bugs@NetBSD.org,
 toolchain-manager@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: toolchain/49425: internal compiler error compiling riscv userland
Date: Mon, 1 Dec 2014 00:47:15 -0800

 > On Dec 1, 2014, at 12:44 AM, Dennis Ferguson =
 <dennis.c.ferguson@gmail.com> wrote:
 >=20
 >=20
 > On 1 Dec, 2014, at 16:10 , Martin Husemann <martin@duskware.de> wrote:
 >> OK, so the list of files differs (see toolchain/49434) and -O1 vs =
 -O0;
 >> these are likely different MD gcc bugs.
 >>=20
 >> Reinoud or you should report this upstream.
 >=20
 > Yes, though for RISC-V compiler it is a bit ambiguous who the upstream
 > is.  As far as I can tell the RISC-V people have only done their MD =
 for
 > gcc 4.6.something and 4.9, so it may be Matt(??) who moved this into =
 4.8.3.
 > If I can get one of the supported RISC-V compilers to build I can try =
 it
 > to see if it gets the same ICE and report that, otherwise the =
 workaround
 > may need to stay until NetBSD moves to a gcc version they also =
 support.

 You might also try using the -fno-builtin-<...> to disable the pattern.

 I saw that with the gcc4.9 one as well.

 I first tried to get <riscv/lock.h> to use the C11 atomic but the =
 compiler blew chuncks.=

From: "Dennis Ferguson" <dennis@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/49425 CVS commit: src/external/gpl3/gcc/lib/libasan
Date: Tue, 2 Dec 2014 03:20:39 +0000

 Module Name:	src
 Committed By:	dennis
 Date:		Tue Dec  2 03:20:39 UTC 2014

 Modified Files:
 	src/external/gpl3/gcc/lib/libasan: Makefile

 Log Message:
 Work around RISC-V compiler bug in gcc 4.8.3 (at least).
 Should be reconsidered if the compiler is updated.
 PR toolchain/49425


 To generate a diff of this commit:
 cvs rdiff -u -r1.7 -r1.8 src/external/gpl3/gcc/lib/libasan/Makefile

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

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, toolchain-manager@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, 
	reinoud@diablo.13thmonkey.org
Cc: 
Subject: Re: PR/49425 CVS commit: src/external/gpl3/gcc/lib/libasan
Date: Mon, 1 Dec 2014 22:32:11 -0500

 On Dec 2,  3:25am, dennis@netbsd.org ("Dennis Ferguson") wrote:
 -- Subject: PR/49425 CVS commit: src/external/gpl3/gcc/lib/libasan

 |  Work around RISC-V compiler bug in gcc 4.8.3 (at least).
 |  Should be reconsidered if the compiler is updated.
 |  PR toolchain/49425
 |  

 Can you put an entry in /usr/src/doc/HACKS for that, if there isn't there
 one for it already?

 Thanks,

 christos

State-Changed-From-To: open->closed
State-Changed-By: mrg@NetBSD.org
State-Changed-When: Thu, 20 Dec 2018 22:26:05 +0000
State-Changed-Why:
whether fixed in our tree or not, the riscv compiler is missing currently
and future work to enable it is incoming and likely won't have this bug.


>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.