Opened 3 years ago

Closed 3 years ago

#24599 closed defect (fixed)

Internal compiler error when compiling giac-1.4.9.45 with gcc-7.2.0

Reported by: rws Owned by:
Priority: blocker Milestone: sage-8.2
Component: build Keywords:
Cc: Merged in:
Authors: Jeroen Demeyer Reviewers: Ralf Stephan
Report Upstream: N/A Work issues:
Branch: c7b0dac (Commits) Commit: c7b0dac707e329540d2d8983d8c103534c62dab9
Dependencies: Stopgaps:

Description (last modified by jdemeyer)

gcc-7.2.0 is currently distributed with Sage. Complete log is attached.

[giac-1.4.9.45] modpoly.cc: In function 'std::complex<double> giac::horner_newton(const vecteur&, const std::complex<double>&, const giac::context*)':
[giac-1.4.9.45] modpoly.cc:5035:19: internal compiler error: Aborted
[giac-1.4.9.45]    complex<double> horner_newton(const vecteur & p,const std::complex<double> &x,GIAC_CONTEXT){
[giac-1.4.9.45]                    ^~~~~~~~~~~~~
[giac-1.4.9.45] 0xafbc6f crash_signal
[giac-1.4.9.45] 	../../src/gcc/toplev.c:337
[giac-1.4.9.45] 0x7f3e0cfeedd3 mpfr_assert_fail
[giac-1.4.9.45] 	/home/ralf/sage/local/var/tmp/sage/build/mpfr-3.1.5.p0/src/src/mpfr-gmp.c:305
[giac-1.4.9.45] 0x7f3e0cfe59c1 mpfr_init2
[giac-1.4.9.45] 	/home/ralf/sage/local/var/tmp/sage/build/mpfr-3.1.5.p0/src/src/init2.c:52
[giac-1.4.9.45] 0x7f3e0d21b472 mpc_div_zero
[giac-1.4.9.45] 	/home/ralf/sage/local/var/tmp/sage/build/mpc-1.1.0/src/src/div.c:31
[giac-1.4.9.45] 0x7f3e0d21b472 mpc_div
[giac-1.4.9.45] 	/home/ralf/sage/local/var/tmp/sage/build/mpc-1.1.0/src/src/div.c:257
[giac-1.4.9.45] 0x77b6b9 do_mpc_arg2(tree_node*, tree_node*, tree_node*, int, int (*)(__mpc_struct*, __mpc_struct const*, __mpc_struct const*, int))
[giac-1.4.9.45] 	../../src/gcc/builtins.c:10179
[giac-1.4.9.45] 0x8afa0a const_binop
[giac-1.4.9.45] 	../../src/gcc/fold-const.c:1316
[giac-1.4.9.45] 0x8b0c5e const_binop(tree_code, tree_node*, tree_node*, tree_node*)
[giac-1.4.9.45] 	../../src/gcc/fold-const.c:1565
[giac-1.4.9.45] 0xdb4962 gimple_resimplify2(gimple**, code_helper*, tree_node*, tree_node**, tree_node* (*)(tree_node*))
[giac-1.4.9.45] 	../../src/gcc/gimple-match-head.c:132
[giac-1.4.9.45] 0xe384b0 gimple_simplify(gimple*, code_helper*, tree_node**, gimple**, tree_node* (*)(tree_node*), tree_node* (*)(tree_node*))
[giac-1.4.9.45] 	../../src/gcc/gimple-match-head.c:642
[giac-1.4.9.45] 0x8e4306 fold_stmt_1
[giac-1.4.9.45] 	../../src/gcc/gimple-fold.c:4362
[giac-1.4.9.45] 0xbdb5ff execute
[giac-1.4.9.45] 	../../src/gcc/tree-ssa-forwprop.c:2391
[giac-1.4.9.45] Please submit a full bug report,

Minimal crashing example:

#include <complex>
auto inf = 1.0 / std::complex<double>();

The underlying reason is that, in #24353, the MPC upgrade did not change the .so version number but the MPFR upgrade did change the .so version number. So now GCC is linking with the old MPFR but the new MPC which is what causes the breakage...

Attachments (1)

giac-1.4.9.45.log (107.4 KB) - added by rws 3 years ago.

Download all attachments as: .zip

Change History (17)

Changed 3 years ago by rws

comment:1 Changed 3 years ago by fbissey

Because gcc links to mpfr/mpc and there is a change of soname from mpfr (so.4 to so.6) gcc needs to be rebuilt. Currently mpfr is only a built order dependency because there wasn't a change in soname for a long time it was fine. But it looks like this need to be changed.

comment:2 Changed 3 years ago by rws

OTOH, mpfr depends on gcc so gcc cannot depend on mpfr. If gcc really uses mpfr as it looks like then I think mpfr needs to be compiled before gcc, i.e. using the system gcc.

comment:3 Changed 3 years ago by fbissey

mpfr doesn't depend on gcc

cat build/pkgs/mpfr/dependencies 
$(MP_LIBRARY)

----------
All lines of this file are ignored except the first.
It is copied by SAGE_ROOT/build/make/install into SAGE_ROOT/build/make/Makefile.

but gcc does depend on mpfr - but only build order dependency, that is gcc is not rebuilt after an mpfr upgrade (which is fine as long as the soname doesn't change either)

cat build/pkgs/gcc/dependencies 
| $(MP_LIBRARY) mpfr mpc zlib xz

----------
All lines of this file are ignored except the first.
It is copied by SAGE_ROOT/build/make/install into SAGE_ROOT/build/make/Makefile.

Same thing for MP_LIBRARY, mpc and zlib really. xz is only needed to unpack the tarball.

comment:4 Changed 3 years ago by rws

Well, I can only say that just now mpfr was rebuilt after I reinstalled gcc and said make so there is some dependency.

comment:5 Changed 3 years ago by fbissey

Ha! That's because of the way the gcc spkg - and the sage toolchain is set up. The gcc spkg ends with this

# Force re-installation of gmp, mpir, mpfr and mpc with the GCC we just built.
cd "$SAGE_SPKG_INST"
rm -f gmp-* mpir-* mpfr-* mpc-*

# Force re-configuration: the next time that "make" is run, we don't
# want GCC to be built again, see Trac #19324
touch "$SAGE_ROOT/configure"

comment:6 Changed 3 years ago by rws

As to the root cause what I don't understand is that gcc usually builds all its libraries itself, but with mpfr they depend on a shared library. I think that is the problem.

comment:7 Changed 3 years ago by jdemeyer

  • Description modified (diff)

comment:8 Changed 3 years ago by jdemeyer

  • Description modified (diff)

I don't see an obvious solution...

comment:9 Changed 3 years ago by jdemeyer

The problem is that there is no logic in configure.ac to check whether the Sage-installed GCC actually works... we just assume that it does.

comment:10 Changed 3 years ago by jdemeyer

  • Branch set to u/jdemeyer/ticket/24599

comment:11 Changed 3 years ago by jdemeyer

  • Authors set to Jeroen Demeyer
  • Commit set to 0ee2274c23fa74f29f0c39ea8f299923dcbace18
  • Status changed from new to needs_review

New commits:

0ee2274Check for broken g++ in $SAGE_LOCAL

comment:12 Changed 3 years ago by git

  • Commit changed from 0ee2274c23fa74f29f0c39ea8f299923dcbace18 to c7b0dac707e329540d2d8983d8c103534c62dab9

Branch pushed to git repo; I updated commit sha1. New commits:

c7b0dacLibraries should be real dependencies

comment:13 Changed 3 years ago by fbissey

Good find on the minimal example. I think this will work so it is positive for me but Ralph should test it - if he can before setting the ticket to positive review.

comment:14 Changed 3 years ago by rws

It seems -O3 is needed for the ICE. What I did:

> make distclean
> git checkout 8.2.beta3
> ./sage -f mpfr
> ./sage -f gcc
> git checkout 8.2.beta4
> ./sage -f giac

As expected this fails again with the same error. Then I put the snippet into t.cpp and did ./local/bin/g++ -c -O3 t.cpp which also fails.

comment:15 Changed 3 years ago by rws

  • Reviewers set to Ralf Stephan
  • Status changed from needs_review to positive_review

Then I did git pull trac u/jdemeyer/ticket/24599 (EDIT: and make start) in a branch and gcc was recompiled.

Last edited 3 years ago by rws (previous) (diff)

comment:16 Changed 3 years ago by vbraun

  • Branch changed from u/jdemeyer/ticket/24599 to c7b0dac707e329540d2d8983d8c103534c62dab9
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.