Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create an optional GCC-4.7.2 package #13150

Closed
jdemeyer opened this issue Jun 22, 2012 · 18 comments
Closed

Create an optional GCC-4.7.2 package #13150

jdemeyer opened this issue Jun 22, 2012 · 18 comments

Comments

@jdemeyer
Copy link

For testing purposes, or just to have the latest GCC, some people might prefer GCC-4.7.2 over the Sage-shipped GCC-4.6.3.

spkg: http://boxen.math.washington.edu/home/jdemeyer/spkg/gcc-4.7.2.spkg (based on the gcc-4.6.3 spkg by just bumping the src/ directory version).

md5sum: ea1018aa0020d534b830d2952ea6c7cc gcc-4.7.2.spkg

This includes all of GCC, i.e. also Java, Go, Objective-C,... compilers in addition to C, C++ and Fortran in the Sage GCC spkg.

CC: @nexttime

Component: packages: optional

Author: Jeroen Demeyer

Reviewer: Volker Braun

Issue created by migration from https://trac.sagemath.org/ticket/13150

@jdemeyer

This comment has been minimized.

@jdemeyer
Copy link
Author

Author: Jeroen Demeyer

@jdemeyer

This comment has been minimized.

@nexttime
Copy link
Mannequin

nexttime mannequin commented Jul 3, 2012

comment:4

Replying to @jdemeyer:

This includes all of GCC, i.e. also Java, Go, Objective-C,... compilers in addition to C, C++ and Fortran in the Sage GCC spkg.

Also

The following languages will be built: c,c++,fortran,java,lto,objc
...

(Ubuntu 10.04 x86_64)

Don't know whether that's intended.

@nexttime
Copy link
Mannequin

nexttime mannequin commented Jul 24, 2012

comment:5

FWIW, R 2.14.0 still fails to build (segfault when byte-compiling package "base") with GCC 4.7.1 and -O3, like it did with [FSF GCC] 4.7.0, at least on Ubuntu x86_64.

More related to this ticket (or the GCC spkg in general), ECL somehow gets confused if the "native" GCC has libffi, and fails to build because the spkg's GCC doesn't provide it (and ECL doesn't build its own either).

But maybe my installation is somehow "messed up", or at least untypical:

While ffi.h is located in /usr/lib/gcc/x86_64-linux-gnu/4.{6.3,7.0}/include/, the libraries (including unversioned .sos) are installed in /usr/{lib,lib32}/; the original Ubuntu GCC 4.4.3 doesn't come with libffi.

Ah, while writing, I did again take a closer look at the build logs... The following should certainly get fixed:

...
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C preprocessor... cpp-4.7.0
...
checking for ffi_closure_alloc in -lffi... yes
checking ffi/ffi.h usability... no
checking ffi/ffi.h presence... no
checking for ffi/ffi.h... no
checking ffi.h usability... no
checking ffi.h presence... yes
configure: WARNING: ffi.h: present but cannot be compiled
configure: WARNING: ffi.h:     check for missing prerequisite headers?
configure: WARNING: ffi.h: see the Autoconf documentation
configure: WARNING: ffi.h:     section "Present But Cannot Be Compiled"
configure: WARNING: ffi.h: proceeding with the preprocessor's result
configure: WARNING: ffi.h: in the future, the compiler will take precedence
checking for ffi.h... yes
checking whether we can use the existing libffi library ... yes
...
gcc -DECLDIR="\"${SAGE_ROOT}/local/lib/ecl-11.1.1\"" -I. -I${SAGE_ROOT}/spkg/build/ecl-11.1.2.cvs20111120.p1/src/build -I${SAGE_ROOT}/spkg/build/ecl-11.1.2.cvs20111120.p1/src/src/c -I../ecl/gc -DECL_API -DECL_NO_LEGACY  -march=native -O3 -DHONORS_CPPFLAGS -I${SAGE_ROOT}/local/include -I${SAGE_ROOT}/local/include -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -march=native -O3 -fno-strict-aliasing -DHONORS_CFLAGS -fPIC -Dlinux -c -o ffi.o ffi.o.c
In file included from ${SAGE_ROOT}/spkg/build/ecl-11.1.2.cvs20111120.p1/src/build/ecl/ecl.h:35:0,
                 from ${SAGE_ROOT}/spkg/build/ecl-11.1.2.cvs20111120.p1/src/src/c/ffi.d:18:
${SAGE_ROOT}/spkg/build/ecl-11.1.2.cvs20111120.p1/src/build/ecl/config.h:525:17: fatal error: ffi.h: No such file or directory
compilation terminated.
make[2]: *** [ffi.o] Error 1
make[2]: Leaving directory `${SAGE_ROOT}/spkg/build/ecl-11.1.2.cvs20111120.p1/src/build/c'
make[1]: *** [libeclmin.a] Error 2
make[1]: Leaving directory `${SAGE_ROOT}/spkg/build/ecl-11.1.2.cvs20111120.p1/src/build'
make: *** [all] Error 2
Error - Failed to build ECL ... exiting

(Note the CPP setting; gcc is $SAGE_ROOT/local/bin/gcc.)

It's rather luck that only the ECL spkg is affected; we should either set CPP properly or unset it (before sage-env is called) if we're using Sage's GCC.

Similar is probably true for FC, F77 etc.:

$ ./sage --sh -c 'env | egrep -w "CC|CPP|CXX|FC|F77"' 
CPP=cpp-4.7.0
F77=gfortran-4.7.0
CXX=g++
FC=gfortran-4.7.0
CC=gcc

(I don't set F95 and the like, others may perhaps.)

@nexttime
Copy link
Mannequin

nexttime mannequin commented Jul 24, 2012

comment:6

Looks like we just have to extend the following part of spkg/bin/sage-env:

...

# Override CC and CXX if the gcc spkg was installed.
if [ -x "$SAGE_LOCAL/bin/gcc" ]; then
    CC=gcc
fi
if [ -x "$SAGE_LOCAL/bin/g++" ]; then
    CXX=g++
fi
export CC CXX

I'm not sure how to handle Java, Objective C/C++ etc. if compilers for these get also built by Sage's GCC spkg. (I only recall some Objective C was used on MacOS X by some spkg[s].)

@nexttime
Copy link
Mannequin

nexttime mannequin commented Jul 24, 2012

comment:7

P.S.:

More problems will arise if CFLAGS et al. have been set by the user, but Sage's compiler versions don't understand / support these. In that case we may have to make excessive use of testcflags (testcxxflags, testfflags, ...?) to sort out such options, or at least exit early with an appropriate error message.

@nexttime
Copy link
Mannequin

nexttime mannequin commented Jul 24, 2012

comment:8

Replying to @nexttime:

Looks like we just have to extend the following part of spkg/bin/sage-env:

...

# Override CC and CXX if the gcc spkg was installed.
if [ -x "$SAGE_LOCAL/bin/gcc" ]; then
    CC=gcc
fi
if [ -x "$SAGE_LOCAL/bin/g++" ]; then
    CXX=g++
fi
export CC CXX

Something along these lines:

diff --git a/spkg/bin/sage-env b/spkg/bin/sage-env
--- a/spkg/bin/sage-env
+++ b/spkg/bin/sage-env
@@ -418,6 +418,8 @@
 if [ -z "$CXX" ]; then
     CXX=g++
 fi
+# We may set CPP, FC, F77 (to sage_fortran?) etc. here as well;
+# letting at least CPP have a default value ('cpp') probably makes sense.
 
 # An Objective-C compiler is needed for R on Darwin.
 # On Darwin, /usr/bin/cc supports Objective-C.  The gcc shipped with
@@ -431,14 +433,24 @@
     fi
 fi
 
-# Override CC and CXX if the gcc spkg was installed.
+# Override CC, CPP, CXX, FC, F77 and F95 if the GCC spkg was installed:
+# (We *may* also just unset FC/F77/F95 in case $SAGE_LOCAL/bin/gfortran is
+# present.)
 if [ -x "$SAGE_LOCAL/bin/gcc" ]; then
     CC=gcc
 fi
+if [ -x "$SAGE_LOCAL/bin/cpp" ]; then
+    CPP=cpp
+fi
 if [ -x "$SAGE_LOCAL/bin/g++" ]; then
     CXX=g++
 fi
-export CC CXX
+export CC CPP CXX
+if [ -x "$SAGE_LOCAL/bin/gfortran" ]; then
+    for var in FC F77 F95; do
+        export ${var}=gfortran
+    done
+fi
 
 
 if [ "$LD" = "" ]; then

Don't know whether that interferes / is consistent with the SAGE_FORTRAN variable and/or the odd sage_fortran script (which should IMHO get removed anyway).

Setting / overriding OBJC etc. may not be necessary at the moment, but certainly would make sense, too, if we build compilers for more languages (as is currently the case with the GCC 4.7.x spkg).

@nexttime
Copy link
Mannequin

nexttime mannequin commented Jul 24, 2012

comment:9

I've opened #13287 for the issue with compiler-related environment variables (not [yet] addressing potential problems with *FLAGS).

@jdemeyer
Copy link
Author

comment:10

ping

Can this be reviewed please? This is an optional package, so it should not cause much harm.

@jdemeyer

This comment has been minimized.

@jdemeyer jdemeyer changed the title Create an optional GCC-4.7.1 package Create an optional GCC-4.7.2 package Sep 30, 2012
@vbraun
Copy link
Member

vbraun commented Sep 30, 2012

comment:13

Looks good to me!

@vbraun
Copy link
Member

vbraun commented Sep 30, 2012

Reviewer: Volker Braun

@jhpalmieri
Copy link
Member

comment:15

(Never mind, I did something silly.)

@haraldschilly
Copy link
Member

comment:16

spkg is on server + mirrors

@nexttime
Copy link
Mannequin

nexttime mannequin commented Oct 7, 2012

comment:17

Since this is an optional spkg (rather independent from releases), and is on the servers now, can we close this ticket?

@nexttime

This comment has been minimized.

@jdemeyer
Copy link
Author

jdemeyer commented Oct 7, 2012

comment:18

Replying to @nexttime:

Since this is an optional spkg (rather independent from releases), and is on the servers now, can we close this ticket?

Yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants