Opened 6 years ago

Closed 6 years ago

#14737 closed defect (fixed)

Fragile GMP header hack in Singular and track all files

Reported by: leif Owned by: leif
Priority: critical Milestone: sage-5.12
Component: packages: standard Keywords: git cf_gmp.h bits/c++config.h spkg factory build error Arch Linux Slackware
Cc: mmezzarobba Merged in: sage-5.12.beta0
Authors: Leif Leonhardy, Volker Braun Reviewers: Volker Braun, Jean-Pierre Flori
Report Upstream: Not yet reported upstream; Will do shortly. Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by vbraun)

One (variant of possible) symptom(s):

In file included from ../kernel/si_gmp.h:4:0,
                  from ../kernel/structs.h:15,
                  from weight0.c:13:
../factory/cf_gmp.h:2501:28: fatal error: bits/c++config.h: No such file or directory
  #include <bits/c++config.h>
                             ^
compilation terminated.
make[4]: *** [weight0.o] Error 1

This is still present in Singular 3-1-6.


The file factory/cf_gmp.h is supposed to contain a copy of the otherwise used gmp.h found on the system, with some C++ definitions removed, later on to be used both by Singular C and C++ files (i.e., those include cf_gmp.h instead of gmp.h).

The actual problem is getting the location (i.e., the absolute path) of the header file used by the C/C++ compiler / preprocessor, in order to create a modified copy of it.

The latter is achieved by using GCC's -M switch to output Makefile dependencies (also taking into account include directory search paths eventually specified by the user, probably via --with-gmp=...), but isn't robust w.r.t. the formatting of the generated rules.

In particular, undesired additional header files (which usually include others) may end up in cf_gmp.h, leading to (potentially arbitrary) problems at least when C files include it, as the folders searched for C headers usually differ from those used when compiling / preprocessing C++. (This is the case in the rather obscure error above, where bits/c++config.h isn't found.)


The current patch to the Singular spkg both simplifies the generation of cf_gmp.h (no longer needing gen_cf_gmp.template and [to ship] gen_cf_gmp.cc, nor the generation of a temporary shell script, gen_cf_gmp.sh), and of course makes it more robust, also making sure only the contents of gmp.h ends up in its modified copy.


fixed spkg: http://boxen.math.washington.edu/home/vbraun/spkg/singular-3-1-5.p8.spkg

Attachments (1)

sanitize_gmp_header_hack.patch (2.4 KB) - added by leif 6 years ago.
Proposed patch to upstream (included in the .p8 spkg). For reference / review.

Download all attachments as: .zip

Change History (19)

comment:1 Changed 6 years ago by leif

  • Keywords factory build error added

(More to come...)

comment:2 Changed 6 years ago by leif

  • Description modified (diff)

comment:3 Changed 6 years ago by leif

  • Description modified (diff)
  • Owner changed from jdemeyer to leif

comment:4 Changed 6 years ago by leif

For the impatient:

An initial fixed spkg can be found here. (Currently just adds a patch to src/factory/GNUmakefile.in, also simplifying the header generation a bit.)

comment:5 Changed 6 years ago by mmezzarobba

  • Cc mmezzarobba added

comment:6 Changed 6 years ago by leif

  • Keywords Arch Linux Slackware added

comment:7 Changed 6 years ago by leif

  • Description modified (diff)

comment:8 follow-up: Changed 6 years ago by mmezzarobba

I used the patch to build sage 5.11β3 on a system that used to be affected by this bug (debian sid, gcc 4.8). It works for me.

comment:9 in reply to: ↑ 8 Changed 6 years ago by leif

Replying to mmezzarobba:

I used the patch to build sage 5.11β3 on a system that used to be affected by this bug (debian sid, gcc 4.8). It works for me.

Someone else just reported the same error for Debian testing... :-)

comment:10 Changed 6 years ago by leif

  • Description modified (diff)

Slightly changed the spkg; patch now removes unneeded files as well.

Changed 6 years ago by leif

Proposed patch to upstream (included in the .p8 spkg). For reference / review.

comment:11 Changed 6 years ago by vbraun

  • Priority changed from major to critical

comment:12 Changed 6 years ago by ncohen

This spkg fixed the problem for me too ! And I also run debian sid. Thank you very much ! ;-)

Nathann

comment:13 Changed 6 years ago by vbraun

Leif, are you still working on the patch or is this ready for review?

comment:14 Changed 6 years ago by vbraun

  • Description modified (diff)
  • Summary changed from Fragile GMP header hack in Singular to Fragile GMP header hack in Singular and track all files

comment:15 Changed 6 years ago by vbraun

  • Authors set to Leif Leonhardy, Volker Braun
  • Keywords git added
  • Reviewers set to Volker Braun
  • Status changed from new to needs_review

The GMP header patch looks good to me (positive review)

Somebody needs to review the sage-src script and then we are ready.

comment:16 Changed 6 years ago by jpflori

  • Reviewers changed from Volker Braun to Volker Braun, Jean-Pierre Flori
  • Status changed from needs_review to positive_review

I'm ok with spkg-src.

comment:17 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:18 Changed 6 years ago by jdemeyer

  • Merged in set to sage-5.12.beta0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.