NetBSD Problem Report #48696
From www@NetBSD.org Tue Apr 1 10:18:22 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1 with cipher ECDHE-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 7E19BA5803
for <gnats-bugs@gnats.NetBSD.org>; Tue, 1 Apr 2014 10:18:22 +0000 (UTC)
Message-Id: <20140401101821.0270DA5812@mollari.NetBSD.org>
Date: Tue, 1 Apr 2014 10:18:21 +0000 (UTC)
From: macallan@netbsd.org
Reply-To: macallan@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: gcc crashes on loongson when optimizing
X-Send-Pr-Version: www-1.0
>Number: 48696
>Category: toolchain
>Synopsis: gcc crashes on loongson when optimizing
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Apr 01 10:20:01 +0000 2014
>Last-Modified: Tue May 13 19:00:00 +0000 2014
>Originator: Michael
>Release: 6.99.39
>Organization:
>Environment:
NetBSD kilbeggan 6.99.39 NetBSD 6.99.39 (KILBEGGAN) #5: Sun Mar 30 15:39:17 EDT 2014 ml@blackbush:/stuff/build/obj_evbmips/sys/arch/evbmips/compile/KILBEGGAN evbmips
>Description:
cc -pipe -march=loongson2f -O2 -o flops flops.c
flops.c: In function 'main':
flops.c:641:4: warning: incompatible implicit declaration of built-in function 'exit'
flops.c:642:1: internal compiler error: Bus error
Please submit a full bug report,
with preprocessed source if appropriate.
See for instructions.
*** Error code 1
Stop.
make: stopped in /tmp/benchmarks/flops/work
This only happens when running on Loongson hardware itself ( I'll try other MIPS but I suspect they'll have the same problem ) - a cross-gcc targeting MIPS built from the same source running on sparc64 works just fine ( as in build.sh -m evbmips64-el )
The most recent, locally built binaries I could find on my gdium are from 2013-05-21 so the problem must have been introduced after that.
>How-To-Repeat:
Try to compile anything with optimization enabled.
>Fix:
>Audit-Trail:
From: Michael <macallan@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: toolchain/48696: gcc crashes on loongson when optimizing
Date: Thu, 10 Apr 2014 09:31:02 -0400
The crash comes from gmp, namely the mips64 .asm routines which
unconditionally use 64bit loads and stores, even with 32bit ABIs.
Using mips32 .asm seems to fix the problem ( see patch below ).
I don't think the patch is committable as is, we should probably
provide versions of the mips64 asm routines that use 32bit loads and
stores, since we still want to optimize for MIPS-III or better.
Index: lib/libgmp/arch/mips64el/Makefile.inc
===================================================================
RCS file: /cvsroot/src/external/lgpl3/gmp/lib/libgmp/arch/mips64el/Makefile.inc,v
retrieving revision 1.5
diff -u -w -r1.5 Makefile.inc
--- lib/libgmp/arch/mips64el/Makefile.inc 4 Dec 2013 00:49:18 -0000 1.5
+++ lib/libgmp/arch/mips64el/Makefile.inc 10 Apr 2014 13:01:57 -0000
@@ -158,6 +158,8 @@
redc_n.c \
sub_err1_n.c \
+.if (defined(CPUFLAGS) && !empty(CPUFLAGS:M-mabi=64))
+GMP_LIMB_BITS=64
C_SRCS_LIST= \
xor_n.c mpn/generic/logops_n.c \
sb_div_r_sec.c mpn/generic/sb_div_sec.c \
@@ -185,10 +187,34 @@
addmul_1.asm mpn/mips64/addmul_1.asm \
sub_n.asm mpn/mips64/sub_n.asm \
-.if (defined(CPUFLAGS) && !empty(CPUFLAGS:M-mabi=64))
-GMP_LIMB_BITS=64
.else
GMP_LIMB_BITS=32
+C_SRCS_LIST= \
+ xor_n.c mpn/generic/logops_n.c \
+ sb_div_r_sec.c mpn/generic/sb_div_sec.c \
+ nand_n.c mpn/generic/logops_n.c \
+ nior_n.c mpn/generic/logops_n.c \
+ hamdist.c mpn/generic/popham.c \
+ popcount.c mpn/generic/popham.c \
+ sbpi1_div_qr_sec.c mpn/generic/sbpi1_div_sec.c \
+ and_n.c mpn/generic/logops_n.c \
+ ior_n.c mpn/generic/logops_n.c \
+ sb_div_qr_sec.c mpn/generic/sb_div_sec.c \
+ xnor_n.c mpn/generic/logops_n.c \
+ iorn_n.c mpn/generic/logops_n.c \
+ sbpi1_div_r_sec.c mpn/generic/sbpi1_div_sec.c \
+ andn_n.c mpn/generic/logops_n.c \
+
+ASM_SRCS_LIST= \
+ add_n.asm mpn/mips32/add_n.asm \
+ submul_1.asm mpn/mips32/submul_1.asm \
+ umul.asm mpn/mips32/umul.asm \
+ lshift.asm mpn/mips32/lshift.asm \
+ mul_1.asm mpn/mips32/mul_1.asm \
+ rshift.asm mpn/mips32/rshift.asm \
+ addmul_1.asm mpn/mips32/addmul_1.asm \
+ sub_n.asm mpn/mips32/sub_n.asm \
+
.endif
COPTS+= -Wno-error
Index: lib/libgmp/arch/mips64el/config.h
===================================================================
RCS file: /cvsroot/src/external/lgpl3/gmp/lib/libgmp/arch/mips64el/config.h,v
retrieving revision 1.4
diff -u -w -r1.4 config.h
--- lib/libgmp/arch/mips64el/config.h 29 Nov 2013 13:26:16 -0000 1.4
+++ lib/libgmp/arch/mips64el/config.h 10 Apr 2014 13:01:57 -0000
@@ -223,7 +223,11 @@
implementation of the corresponding routine exists. */
#define HAVE_NATIVE_mpn_add_n 1
/* #undef HAVE_NATIVE_mpn_add_n_sub_n */
+
+#ifdef _LP64
#define HAVE_NATIVE_mpn_add_nc 1
+#endif
+
/* #undef HAVE_NATIVE_mpn_addaddmul_1msb0 */
/* #undef HAVE_NATIVE_mpn_addcnd_n */
/* #undef HAVE_NATIVE_mpn_addlsh1_n */
@@ -310,10 +314,14 @@
/* #undef HAVE_NATIVE_mpn_rsh1sub_nc */
#define HAVE_NATIVE_mpn_rshift 1
/* #undef HAVE_NATIVE_mpn_sqr_basecase */
+#ifdef _LP64
#define HAVE_NATIVE_mpn_sqr_diagonal 1
+#endif
/* #undef HAVE_NATIVE_mpn_sqr_diag_addlsh1 */
#define HAVE_NATIVE_mpn_sub_n 1
+#ifdef _LP64
#define HAVE_NATIVE_mpn_sub_nc 1
+#endif
/* #undef HAVE_NATIVE_mpn_subcnd_n */
/* #undef HAVE_NATIVE_mpn_sublsh1_n */
/* #undef HAVE_NATIVE_mpn_sublsh2_n */
From: "Michael Lorenz" <macallan@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/48696 CVS commit: src/external/lgpl3/gmp/lib/libgmp/arch
Date: Tue, 13 May 2014 18:46:48 +0000
Module Name: src
Committed By: macallan
Date: Tue May 13 18:46:48 UTC 2014
Modified Files:
src/external/lgpl3/gmp/lib/libgmp/arch/mips64eb: Makefile.inc config.h
src/external/lgpl3/gmp/lib/libgmp/arch/mips64el: Makefile.inc config.h
Log Message:
on mips64* use generic C functions instead of assembly routines when building
n32 binaries. Should work around PR48696
ok mrg@
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/external/lgpl3/gmp/lib/libgmp/arch/mips64eb/Makefile.inc
cvs rdiff -u -r1.4 -r1.5 \
src/external/lgpl3/gmp/lib/libgmp/arch/mips64eb/config.h
cvs rdiff -u -r1.5 -r1.6 \
src/external/lgpl3/gmp/lib/libgmp/arch/mips64el/Makefile.inc
cvs rdiff -u -r1.4 -r1.5 \
src/external/lgpl3/gmp/lib/libgmp/arch/mips64el/config.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Michael Lorenz" <macallan@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/48696 CVS commit: src/doc
Date: Tue, 13 May 2014 18:55:07 +0000
Module Name: src
Committed By: macallan
Date: Tue May 13 18:55:07 UTC 2014
Modified Files:
src/doc: HACKS
Log Message:
mention workaround for PR48696
To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/doc/HACKS
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
(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-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.