c++11, mpirxx, and normaliz problem

335 views
Skip to first unread message

Dima Pasechnik

unread,
Nov 18, 2014, 9:39:32 AM11/18/14
to sage-...@googlegroups.com
basically, current (upstream) normaliz does not compile with gcc 4.9.2;
(with Sage 4.5.beta0).
I tracked it down to the following test, showing that mpir(xx) does
something strange...

$ cat b.cpp
#include <mpirxx.h>
int main()
{
return alignof(std::max_align_t);
}

$ g++ -std=c++11 -c b.cpp
In file included from
/home/scratch/dimpase/sage/sage6.3/local/include/mpir.h:53:0,
from
/home/scratch/dimpase/sage/sage6.3/local/include/mpirxx.h:44,
from b.cpp:1:
/home/scratch/dimpase/sage/sage6.3/local/include/c++/4.9.2/cstddef:51:11:
error: '::max_align_t' has not been declared
using ::max_align_t;
^
b.cpp: In function 'int main()':
b.cpp:6:20: error: 'max_align_t' is not a member of 'std'
return alignof(std::max_align_t);

e$ g++ -v
Using built-in specs.
COLLECT_GCC=/home/scratch/dimpase/sage/sage6.3/local/bin/g++
COLLECT_LTO_WRAPPER=/home/scratch/dimpase/sage/sage6.3/local/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../src/configure
--prefix=/home/scratch/dimpase/sage/sage6.3/local
--with-local-prefix=/home/scratch/dimpase/sage/sage6.3/local
--with-gmp=/home/scratch/dimpase/sage/sage6.3/local
--with-mpfr=/home/scratch/dimpase/sage/sage6.3/local
--with-mpc=/home/scratch/dimpase/sage/sage6.3/local --with-system-zlib
--disable-multilib --disable-nls --enable-languages=c,c++,fortran
--disable-libitm
Thread model: posix
gcc version 4.9.2 (GCC)


Volker Braun

unread,
Nov 18, 2014, 9:54:58 AM11/18/14
to sage-...@googlegroups.com, mpir-...@googlegroups.com
Yes, this is a MPIR bug. In mpir.h, the following takes place:

#define __need_size_t  /* tell gcc stddef.h we only want size_t */
#include <cstddef>     /* for size_t */

As expected from changing implementation macros, his breaks sooner or later:

$ gcc -std=c++11 align.cc
In file included from align.cc:2:0:
/usr/include/c++/4.9.2/cstddef:51:11: error: ‘::max_align_t’ has not been declared
   using ::max_align_t;
           ^

Francesco Biscani

unread,
Nov 18, 2014, 9:55:09 AM11/18/14
to sage-...@googlegroups.com
Looks like this might be the root:

https://gcc.gnu.org/gcc-4.9/porting_to.html

Unformatted quoting:

"""
Header <cstddef> changes

The <cstddef> header was updated for C++11 support and this breaks some libraries which misuse macros meant for internal use by GCC only. For instance with GMP versions up to 5.1.3, you may see:

/usr/include/c++/4.9.0/cstddef:51:11: error: ‘::max_align_t’ has not been declared
   using ::max_align_t;
           ^
Another possible error is:

someheader.h:99:13: error: ‘ptrdiff_t’ does not name a type

A workaround until libraries get updated is to include <cstddef> or <stddef.h> before any headers from that library.
"""



--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To post to this group, send email to sage-...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Dima Pasechnik

unread,
Nov 18, 2014, 10:04:17 AM11/18/14
to sage-...@googlegroups.com
On 2014-11-18, Dima Pasechnik <dim...@gmail.com> wrote:
> basically, current (upstream) normaliz does not compile with gcc 4.9.2;
> (with Sage 4.5.beta0).
> I tracked it down to the following test, showing that mpir(xx) does
> something strange...

As Jeroen mentiones on the mpir list, a workaround is suggested in
https://gcc.gnu.org/gcc-4.9/porting_to.html, section
Header <cstddef> changes

And it seems to help here.

Dima Pasechnik

unread,
Nov 18, 2014, 10:10:12 AM11/18/14
to sage-...@googlegroups.com
On 2014-11-18, Volker Braun <vbrau...@gmail.com> wrote:
> ------=_Part_3954_883918061.1416322498399
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: quoted-printable
>
> Yes, this is a MPIR bug. In mpir.h, the following takes place:
>
> #define __need_size_t /* tell gcc stddef.h we only want size_t */
> #include <cstddef> /* for size_t */
>
> As expected from changing implementation macros, his breaks sooner or later=

Thanks. I wonder if blatant abuse of gcc headers is allowed by the draft Sage
Code of Conduct...

>:
>
> $ gcc -std=3Dc++11 align.cc
> In file included from align.cc:2:0:
> /usr/include/c++/4.9.2/cstddef:51:11: error: =E2=80=98::max_align_t=E2=80=
>=99 has not been=20
> declared
> using ::max_align_t;
> ^
>
>=20
>
> On Tuesday, November 18, 2014 2:39:32 PM UTC, Dima Pasechnik wrote:
>>
>> basically, current (upstream) normaliz does not compile with gcc 4.9.2;=
>=20
>> (with Sage 4.5.beta0).=20
>> I tracked it down to the following test, showing that mpir(xx) does=20
>> something strange...=20
>>
>> $ cat b.cpp=20
>> #include <mpirxx.h>=20
>> int main()=20
>> {=20
>> return alignof(std::max_align_t);=20
>> }=20
>>
>> $ g++ -std=3Dc++11 -c b.cpp=20
>> In file included from=20
>> /home/scratch/dimpase/sage/sage6.3/local/include/mpir.h:53:0,=20
>> from=20
>> /home/scratch/dimpase/sage/sage6.3/local/include/mpirxx.h:44,=20
>> from b.cpp:1:=20
>> /home/scratch/dimpase/sage/sage6.3/local/include/c++/4.9.2/cstddef:51:11:=
>=20
>> error: '::max_align_t' has not been declared=20
>> using ::max_align_t;=20
>> ^=20
>> b.cpp: In function 'int main()':=20
>> b.cpp:6:20: error: 'max_align_t' is not a member of 'std'=20
>> return alignof(std::max_align_t);=20
>>
>> e$ g++ -v=20
>> Using built-in specs.=20
>> COLLECT_GCC=3D/home/scratch/dimpase/sage/sage6.3/local/bin/g++=20
>> COLLECT_LTO_WRAPPER=3D/home/scratch/dimpase/sage/sage6.3/local/libexec/gc=
> c/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper=20
>>
>> Target: x86_64-unknown-linux-gnu=20
>> Configured with: ../src/configure=20
>> --prefix=3D/home/scratch/dimpase/sage/sage6.3/local=20
>> --with-local-prefix=3D/home/scratch/dimpase/sage/sage6.3/local=20
>> --with-gmp=3D/home/scratch/dimpase/sage/sage6.3/local=20
>> --with-mpfr=3D/home/scratch/dimpase/sage/sage6.3/local=20
>> --with-mpc=3D/home/scratch/dimpase/sage/sage6.3/local --with-system-zlib=
>=20
>> --disable-multilib --disable-nls --enable-languages=3Dc,c++,fortran=20
>> --disable-libitm =20
>> Thread model: posix=20
>> gcc version 4.9.2 (GCC)=20
>>
>>
>>
>
> --=20
> You received this message because you are subscribed to the Google Groups "=
> sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an e=
> mail to sage-devel+...@googlegroups.com.
> To post to this group, send email to sage-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.
>
> ------=_Part_3954_883918061.1416322498399
> Content-Type: text/html; charset=UTF-8
> Content-Transfer-Encoding: quoted-printable
>
><div dir=3D"ltr">Yes, this is a MPIR bug. In mpir.h, the following takes pl=
> ace:<div><br></div><div><div>#define __need_size_t &nbsp;/* tell gcc stddef=
> .h we only want size_t */</div><div>#include &lt;cstddef&gt; &nbsp; &nbsp; =
> /* for size_t */</div></div><div><br></div><div>As expected from changing i=
> mplementation macros, his breaks sooner or later:</div><div><br></div><div>=
><div>$ gcc -std=3Dc++11 align.cc</div><div>In file included from align.cc:2=
>:0:</div><div>/usr/include/c++/4.9.2/cstddef:51:11: error: =E2=80=98::max_a=
> lign_t=E2=80=99 has not been declared</div><div>&nbsp; &nbsp;using ::max_al=
> ign_t;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^</div></div><div=
>><br></div><div>&nbsp;<br><br>On Tuesday, November 18, 2014 2:39:32 PM UTC,=
> Dima Pasechnik wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;=
> margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">basicall=
> y, current (upstream) normaliz does not compile with gcc 4.9.2;=20
><br>(with Sage 4.5.beta0).
><br>I tracked it down to the following test, showing that mpir(xx) does
><br>something strange...
><br>
><br>$ cat b.cpp
><br>#include &lt;mpirxx.h&gt;
><br>int main()
><br>{
><br>&nbsp; &nbsp; return alignof(std::max_align_t);
><br>}
><br>
><br>$ g++ &nbsp; -std=3Dc++11 -c b.cpp
><br>In file included from
><br>/home/scratch/dimpase/sage/<wbr>sage6.3/local/include/mpir.h:<wbr>53:0,
><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from
><br>/home/scratch/dimpase/sage/<wbr>sage6.3/local/include/mpirxx.<wbr>h:44,
><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;from b.cp=
> p:1:
><br>/home/scratch/dimpase/sage/<wbr>sage6.3/local/include/c++/4.9.<wbr>2/cs=
> tddef:51:11:
><br>error: '::max_align_t' has not been declared
><br>&nbsp; &nbsp;using ::max_align_t;
><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;^
><br>b.cpp: In function 'int main()':
><br>b.cpp:6:20: error: 'max_align_t' is not a member of 'std'
><br>&nbsp; &nbsp; &nbsp;return alignof(std::max_align_t);
><br>
><br>e$ g++ -v
><br>Using built-in specs.
><br>COLLECT_GCC=3D/home/scratch/<wbr>dimpase/sage/sage6.3/local/<wbr>bin/g+=
> +
><br>COLLECT_LTO_WRAPPER=3D/home/<wbr>scratch/dimpase/sage/sage6.3/<wbr>loca=
> l/libexec/gcc/x86_64-<wbr>unknown-linux-gnu/4.9.2/lto-<wbr>wrapper
><br>Target: x86_64-unknown-linux-gnu
><br>Configured with: ../src/configure
><br>--prefix=3D/home/scratch/<wbr>dimpase/sage/sage6.3/local
><br>--with-local-prefix=3D/home/<wbr>scratch/dimpase/sage/sage6.3/<wbr>loca=
> l
><br>--with-gmp=3D/home/scratch/<wbr>dimpase/sage/sage6.3/local
><br>--with-mpfr=3D/home/scratch/<wbr>dimpase/sage/sage6.3/local
><br>--with-mpc=3D/home/scratch/<wbr>dimpase/sage/sage6.3/local --with-syste=
> m-zlib
><br>--disable-multilib --disable-nls --enable-languages=3Dc,c++,<wbr>fortra=
> n
><br>--disable-libitm &nbsp;
><br>Thread model: posix
><br>gcc version 4.9.2 (GCC)=20
><br>
><br>
><br></blockquote></div></div>
>
><p></p>
>
> -- <br />
> You received this message because you are subscribed to the Google Groups &=
> quot;sage-devel&quot; group.<br />
> To unsubscribe from this group and stop receiving emails from it, send an e=
> mail to <a href=3D"mailto:sage-devel+...@googlegroups.com">sage-dev=
> el+unsu...@googlegroups.com</a>.<br />
> To post to this group, send email to <a href=3D"mailto:sage-devel@googlegro=
> ups.com">sage-...@googlegroups.com</a>.<br />
> Visit this group at <a href=3D"http://groups.google.com/group/sage-devel">h=
> ttp://groups.google.com/group/sage-devel</a>.<br />
> For more options, visit <a href=3D"https://groups.google.com/d/optout">http=
> s://groups.google.com/d/optout</a>.<br />
>
> ------=_Part_3954_883918061.1416322498399--
>

Dima Pasechnik

unread,
Apr 17, 2015, 9:57:42 AM4/17/15
to sage-...@googlegroups.com
bump, this is still not fixed in the MPIR we ship, causing pain and suffering such as here:
http://trac.sagemath.org/ticket/18198

I'll open a ticket shortly.

Dima Pasechnik

unread,
Apr 17, 2015, 10:13:12 AM4/17/15
to sage-...@googlegroups.com
this is now #18240

Dima Pasechnik

unread,
Apr 17, 2015, 2:17:01 PM4/17/15
to sage-...@googlegroups.com


On Friday, 17 April 2015 15:13:12 UTC+1, Dima Pasechnik wrote:
this is now #18240

needs review now!
Reply all
Reply to author
Forward
0 new messages