Control: tags -1 + patch
Control: affects -1 + r-cran-mime r-cran-digest rjava

Le dimanche 10 janvier 2016 à 17:09 +0100, Sébastien Villemot a écrit :

> I will send you a patch probably by tomorrow.

Here is the patch.

I also attach a small (though probably not minimal) test case for the
bug in GCC 5. When compiled with gcc-5 5.3.1-5, with no flag, or with
optimization, the program fails with "Illegal instruction".

-- 
 .''`.    Sébastien Villemot
: :' :    Debian Developer
`. `'     http://sebastien.villemot.name
  `-      GPG Key: 4096R/381A7594



diff -Nru r-base-3.2.3/debian/changelog r-base-3.2.3/debian/changelog
--- r-base-3.2.3/debian/changelog	2016-01-10 19:42:37.000000000 +0000
+++ r-base-3.2.3/debian/changelog	2016-01-10 19:42:52.000000000 +0000
@@ -1,3 +1,12 @@
+r-base (3.2.3-1.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Use gcc-4.9 to compile C code on mips, as a workaround to a gcc-5 bug.
+    (Closes: #810357).
+  * Enable back optimization flags on mips and mipsel.
+
+ -- Sébastien Villemot <sebast...@debian.org>  Sun, 10 Jan 2016 09:46:40 +0000
+
 r-base (3.2.3-1) unstable; urgency=low
 
   * New upstream version released this morning
diff -Nru r-base-3.2.3/debian/control r-base-3.2.3/debian/control
--- r-base-3.2.3/debian/control	2016-01-10 19:42:37.000000000 +0000
+++ r-base-3.2.3/debian/control	2016-01-10 19:42:52.000000000 +0000
@@ -3,7 +3,7 @@
 Priority: optional
 Maintainer: Dirk Eddelbuettel <e...@debian.org>
 Standards-Version: 3.9.6
-Build-Depends: gcc (>= 4:4.1.0), g++ (>= 4:4.1.0), gfortran (>= 4:4.1.0), libblas-dev, liblapack-dev (>= 3.1.1), tcl8.6-dev, tk8.6-dev, bison, groff-base, libncurses5-dev, libreadline-dev, debhelper (>= 7.2.3), texinfo (>= 4.1-2), libbz2-dev, liblzma-dev, libpcre3-dev, libcurl4-openssl-dev | libcurl4-dev, xdg-utils, zlib1g-dev, libpng-dev, libjpeg-dev, libx11-dev, libxt-dev, x11proto-core-dev, libpango1.0-dev, libcairo2-dev, libtiff5-dev, xvfb, xauth, xfonts-base, texlive-base, texlive-latex-base, texlive-generic-recommended, texlive-fonts-recommended, texlive-fonts-extra, texlive-extra-utils, texlive-latex-recommended, texlive-latex-extra, default-jdk [!arm !hppa !kfreebsd-i386 !kfreebsd-amd64 !hurd-i386], mpack, bash-completion
+Build-Depends: gcc (>= 4:4.1.0), g++ (>= 4:4.1.0), gfortran (>= 4:4.1.0), libblas-dev, liblapack-dev (>= 3.1.1), tcl8.6-dev, tk8.6-dev, bison, groff-base, libncurses5-dev, libreadline-dev, debhelper (>= 7.2.3), texinfo (>= 4.1-2), libbz2-dev, liblzma-dev, libpcre3-dev, libcurl4-openssl-dev | libcurl4-dev, xdg-utils, zlib1g-dev, libpng-dev, libjpeg-dev, libx11-dev, libxt-dev, x11proto-core-dev, libpango1.0-dev, libcairo2-dev, libtiff5-dev, xvfb, xauth, xfonts-base, texlive-base, texlive-latex-base, texlive-generic-recommended, texlive-fonts-recommended, texlive-fonts-extra, texlive-extra-utils, texlive-latex-recommended, texlive-latex-extra, default-jdk [!arm !hppa !kfreebsd-i386 !kfreebsd-amd64 !hurd-i386], mpack, bash-completion, gcc-4.9 [mips]
 Homepage: http://www.r-project.org/
 
 Package: r-base
diff -Nru r-base-3.2.3/debian/rules r-base-3.2.3/debian/rules
--- r-base-3.2.3/debian/rules	2016-01-10 19:42:37.000000000 +0000
+++ r-base-3.2.3/debian/rules	2016-01-10 19:42:52.000000000 +0000
@@ -75,7 +75,11 @@
 # edd 11 Oct 2011  setting -std=gnu99 with compiler (thanks, Kurt Hornik)
 fortrancompiler	= F77=gfortran
 f95compiler     = gfortran
+ifeq ($(arch),mips)
+compiler	= "gcc-4.9 -std=gnu99"
+else
 compiler	= "gcc -std=gnu99"
+endif
 cxxcompiler	= g++
 # edd 31 Mar 2014
 #optimflags	= -O3 -pipe 
@@ -118,17 +122,6 @@
 optimflags	= -O2 -ffunction-sections 
 endif
 
-## edd 20 Jun 2002	no optimisation or debugging on baby systems
-## edd 02 Jun 2003	use this on arm only 
-## edd 12 May 2010	no longer use it on arm either -- thx Modestas
-## edd 04 Aug 2010	on mips and mipsel, don't use -g
-##ifneq "$(findstring $(arch), m68k arm)" ""
-#ifneq "$(findstring $(arch), arm)" ""
-ifneq "$(findstring $(arch), mips mipsel)" ""
-optimflags	= -g0 
-#optimflags	= -O0 -g0 
-endif
-
 ## edd 04 Apr 2009	Alpha dies on deriv.c, trying will less optimisation
 ## edd 16 Apr 2009      commented-out as Kurt Roeckx applied a gcc patch
 #ifeq ($(arch),alpha)
#include <math.h>

static void
machar(int *ibeta, int *it, int *irnd, int *ngrd, int *machep, int *negep,
       int *iexp, int *minexp, int *maxexp, double *eps,
       double *epsneg, double *xmin, double *xmax)
{
	volatile double a, b, beta, betain, betah, one,
		t, temp, tempa, temp1, two, y, z, zero;
	int i, itemp, iz, j, k, mx, nxres;

	one = 1;
	two = one+one;
	zero = one-one;

		/* determine ibeta, beta ala malcolm. */

	a = one;
	do {
		a = a + a;
		temp = a + one;
		temp1 = temp - a;
	}
	while(temp1 - one == zero);
	b = one;
	do {
		b = b + b;
		temp = a + b;
		itemp = (int)(temp - a);
	}
	while (itemp == 0);
	*ibeta = itemp;
	beta = *ibeta;

		/* determine it, irnd */

	*it = 0;
	b = one;
	do {
		*it = *it + 1;
		b = b * beta;
		temp = b + one;
		temp1 = temp - b;
	}
	while(temp1 - one == zero);
	*irnd = 0;
	betah = beta / two;
	temp = a + betah;
	if (temp - a != zero)
		*irnd = 1;
	tempa = a + beta;
	temp = tempa + betah;
	if (*irnd == 0 && temp - tempa != zero)
		*irnd = 2;

		/* determine negep, epsneg */

	*negep = *it + 3;
	betain = one / beta;
	a = one;
	for(i=1 ; i<=*negep ; i++)
		a = a * betain;
	b = a;
	for(;;) {
		temp = one - a;
		if (temp - one != zero)
			break;
		a = a * beta;
		*negep = *negep - 1;
	}
	*negep = -*negep;
	*epsneg = a;
	if (*ibeta != 2 && *irnd != 0) {
		a = (a * (one + a)) / two;
		temp = one - a;
		if (temp - one != zero)
			*epsneg = a;
	}

		/* determine machep, eps */

	*machep = -*it - 3;
	a = b;
	for(;;) {
		temp = one + a;
		if (temp - one != zero)
			break;
		a = a * beta;
		*machep = *machep + 1;
	}
	*eps = a;
	temp = tempa + beta * (one + *eps);
	if (*ibeta != 2 && *irnd != 0) {
		a = (a * (one + a)) / two;
		temp = one + a;
		if (temp - one != zero)
			*eps = a;
	}

		/* determine ngrd */

	*ngrd = 0;
	temp = one + *eps;
	if (*irnd == 0 && temp * one - one != zero)
		*ngrd = 1;

	/* determine iexp, minexp, xmin */

	/* loop to determine largest i and k = 2**i such that */
	/*        (1/beta) ** (2**(i)) */
	/* does not underflow. */
	/* exit from loop is signaled by an underflow. */

	i = 0;
	k = 1;
	z = betain;
	t = one + *eps;
	nxres = 0;
	for(;;) {
		y = z;
		z = y * y;

		/* check for underflow here */

		a = z * one;
		temp = z * t;
		if (a+a == zero || fabs(z) >= y)
			break;
		temp1 = temp * betain;
		if (temp1 * beta == z)
			break;
		i = i+1;
		k = k+k;
	}
	if (*ibeta != 10) {
		*iexp = i + 1;
		mx = k + k;
	}
	else {
		/* this segment is for decimal machines only */

		*iexp = 2;
		iz = *ibeta;
		while (k >= iz) {
			iz = iz * *ibeta;
			iexp = iexp + 1;
		}
		mx = iz + iz - 1;
	}
	do {
		/* loop to determine minexp, xmin */
		/* exit from loop is signaled by an underflow */

		*xmin = y;
		y = y * betain;

		/* check for underflow here */

		a = y * one;
		temp = y * t;
		if (a+a == zero || fabs(y) >= *xmin)
			goto L10;
		k = k + 1;
		temp1 = temp * betain;
	}
	while(temp1 * beta != y);
	nxres = 3;
	*xmin = y;
L10:	*minexp = -k;

	/* determine maxexp, xmax */

	if (mx <= k + k - 3 && *ibeta != 10) {
		mx = mx + mx;
		*iexp = *iexp + 1;
	}
	*maxexp = mx + *minexp;

	/* adjust irnd to reflect partial underflow */

	*irnd = *irnd + nxres;

	/* adjust for ieee-style machines */

	if (*irnd == 2 || *irnd == 5)
		*maxexp = *maxexp - 2;

	/* adjust for non-ieee machines with partial underflow */

	if (*irnd == 3 || *irnd == 4)
		*maxexp = *maxexp - *it;

	/* adjust for machines with implicit leading bit in binary */
	/* significand, and machines with radix point at extreme */
	/* right of significand. */

	i = *maxexp + *minexp;
	if (*ibeta == 2 && i == 0)
		*maxexp = *maxexp - 1;
	if (i > 20)
		*maxexp = *maxexp - 1;
	if (a != y)
		*maxexp = *maxexp - 2;
	*xmax = one - *epsneg;
	if (*xmax * one != *xmax)
		*xmax = one - beta * *epsneg;
	*xmax = *xmax / (beta * beta * beta * *xmin);
	i = *maxexp + *minexp + 3;
	if (i>0)
		for(j=1 ; j<=i ; j++) {
			if (*ibeta == 2)
				*xmax = *xmax + *xmax;
			if (*ibeta != 2)
				*xmax = *xmax * beta;
		}
}

int
main(int argc, char **argv)
{
  int ibeta, it, irnd, ngrd, machep, negep,
    iexp, minexp, maxexp;
  double eps, epsneg, xmin, xmax;
  
  machar(&ibeta, &it, &irnd, &ngrd, &machep, &negep,
       &iexp, &minexp, &maxexp, &eps,
         &epsneg, &xmin, &xmax);
  
  return 0;
}

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to