#7864: libfplll tries to link 64-bit objects to 32-bit libstdc++.so
---------------------------------------------------+------------------------
   Reporter:  drkirkby                             |       Owner:  drkirkby     
                            
       Type:  defect                               |      Status:  needs_work   
                            
   Priority:  major                                |   Milestone:  sage-4.5     
                            
  Component:  solaris                              |    Keywords:               
                            
     Author:  David Kirkby, Willem Jan Palenstijn  |    Upstream:  Reported 
upstream. Little or no feedback.
   Reviewer:                                       |      Merged:               
                            
Work_issues:                                       |  
---------------------------------------------------+------------------------
Changes (by newvalueoldvalue):

  * author:  David Kirkby => David Kirkby, Willem Jan Palenstijn


Comment:

 Hi William,

 your solution of setting CC="gcc -m64" works well. (Actually, it needs CXX
 set to "g++ -m64", though I have set both CC and CXX)

 I've written the changes to spkg-install in such a way it should work for
 any compiler (not just gcc/g++. This should help in the unlikely even this
 is ever ported to AIX or HP-UX. Here are some test results using your
 method.

 I've put you as an author too.

 The package is here and needs review

 http://boxen.math.washington.edu/home/kirkby/patches/libfplll-3.0.12.p1.spkg

 Here are some test results. I've tested on Solaris 10, !OpenSolaris and OS
 X.

 == Testing on !OpenSolaris x64 as a 64-bit build ({{{SAGE64="yes"}}}) ==
  * Sun Ultra 27
  * 3.33 GHz Intel W3580 Xeon. Quad core. 8 threads.
  * 12 GB RAM
  * !OpenSolaris 2009.06 snv_134 X86
  * Sage 4.5.rc0
  * gcc 4.4.4 configured to use the Sun linker and the GNU assembler
  * SAGE64 exported to "yes"
 {{{
 drkir...@hawk:~/sage-4.5.rc0$ export SAGE64=yes
 drkir...@hawk:~/sage-4.5.rc0$ cd ..^C
 drkir...@hawk:~/sage-4.5.rc0$ ./sage -f libfplll-3.0.12.p1
 Force installing libfplll-3.0.12.p1
 Calling sage-spkg on libfplll-3.0.12.p1
 Warning: Attempted to overwrite SAGE_ROOT environment variable
 Building Sage on Solaris in 64-bit mode
 Creating SAGE_LOCAL/lib/sage-64.txt since it does not exist
 Detected SAGE64 flag
 Building Sage on Solaris in 64-bit mode
 libfplll-3.0.12.p1
 <SNIP>
 make[1]: Entering directory
 `/export/home/drkirkby/sage-4.5.rc0/spkg/build/libfplll-3.0.12.p1/src/src'
 make[1]: warning: -jN forced in submake: disabling jobserver mode.
 if g++ -m64 -DPACKAGE_NAME=\"libfplll\" -DPACKAGE_TARNAME=\"libfplll\"
 -DPACKAGE_VERSION=\"3.0.12\" -DPACKAGE_STRING=\"libfplll\ 3.0.12\"
 -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"libfplll\" -DVERSION=\"3.0.12\"
 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1
 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1
 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1
 -DHAVE_LIBGMP=1 -DHAVE_LIBMPFR=1 -DSTDC_HEADERS=1 -DHAVE_FLOAT_H=1
 -DHAVE_LIMITS_H=1 -DHAVE_STDLIB_H=1 -DHAVE_SYS_TIME_H=1 -DHAVE_UNISTD_H=1
 -DHAVE_STDBOOL_H=1 -DHAVE_FLOOR=1 -DHAVE_POW=1 -DHAVE_RINT=1 -DHAVE_SQRT=1
 -DHAVE_STRTOL=1 -DHAVE_LIBGMP=1 -DHAVE_LIBMPFR=1 -I. -I.
 -I/export/home/drkirkby/sage-4.5.rc0/local/include/ -m64  -fPIC
 -I/export/home/drkirkby/sage-4.5.rc0/local/include/
 -L/export/home/drkirkby/sage-4.5.rc0/local/lib -m64 -MT main.o -MD -MP -MF
 ".deps/main.Tpo" -c -o main.o main.cpp; \
         then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f
 ".deps/main.Tpo"; exit 1; fi
 <SNIP>
 real    0m17.637s
 user    0m30.920s
 sys     0m5.211s
 Successfully installed libfplll-3.0.12.p1
 }}}
 An inspection of the shared libraries shows they are 64-bit.
 {{{
 drkir...@hawk:~/sage-4.5.rc0$ file local/lib/libfpll*
 local/lib/libfplll.a:   current ar archive, not a dynamic executable or
 shared object
 local/lib/libfplll.la:  commands text
 local/lib/libfplll.so:  ELF 64-bit LSB dynamic lib AMD64 Version 1,
 dynamically linked, not stripped, no debugging information available
 local/lib/libfplll.so.0:        ELF 64-bit LSB dynamic lib AMD64 Version
 1, dynamically linked, not stripped, no debugging information available
 local/lib/libfplll.so.0.1.0:    ELF 64-bit LSB dynamic lib AMD64 Version
 1, dynamically linked, not stripped, no debugging information available
 }}}

 Hence I conclude this is probably working on !OpenSolaris, and is
 certainly an improvement over the libfplll.p0.spkg. Since Sage does not
 build fully as an !OpenSolaris application, it's impossible to run the
 doctests and prove conclusively this is working on !OpenSolaris x64.

 == Testing on !OpenSolaris x64 as a 32-bit build ({{{SAGE64}}} was unset)
 ==
  * Sun Ultra 27
  * 3.33 GHz Intel W3580 Xeon. Quad core. 8 threads.
  * 12 GB RAM
  * !OpenSolaris 2009.06 snv_134 X86
  * Sage 4.5.rc0
  * gcc 4.4.4 configured to use the Sun linker and the GNU assembler
  * SAGE64 was unset.

 Since I already had a 64-bit build, a quick test was done to fool the Sage
 build process into trying to make a 32-bit version of libfplll. This could
 not be expected to produce a binary, as gmp was already built 64-bit. In
 fact, a successful installation of libfplll would have indicated a bug!

 {{{
 drkir...@hawk:~/sage-4.5.rc0$ rm local/lib/sage-64.txt
 drkir...@hawk:~/sage-4.5.rc0$ unset SAGE64
 drkir...@hawk:~/sage-4.5.rc0$ ./sage -f libfplll-3.0.12.p1
 <SNIP>
 ld: fatal: file /export/home/drkirkby/sage-4.5.rc0/local/lib/libmpfr.so:
 wrong ELF class: ELFCLASS64
 ld: fatal: file processing errors. No output written to generate
 collect2: ld returned 1 exit status
 make[1]: *** [generate] Error 1
 make[1]: *** Waiting for unfinished jobs....
 make[1]: Leaving directory
 `/export/home/drkirkby/sage-4.5.rc0/spkg/build/libfplll-3.0.12.p1/src/src'
 make: *** [all-recursive] Error 1
 Error building libfplll

 real    0m9.185s
 user    0m23.389s
 sys     0m3.792s
 sage: An error occurred while installing libfplll-3.0.12.p1
 }}}
 The failure to link to the 64-bit GMP library is to be expected. The fact
 the -m64 flag was not passed to g++ when build libfplll indicates that the
 code should work when SAGE64 is '''not''' set to "yes"

 == Testing on Solaris 10 SPARC as a 64-bit build ({{{SAGE64="yes"}}}) ==
  * Sun T4240
  * 2 x 1167 MHz Sun T2+ UltraSPARC processors (16 cores, 128 threads in
 total)
  * 32 GB RAM
  * Solaris 10 update 7
  * Sage 4.5.rc0
  * gcc 4.4.1 configured to use the Sun linker and the Sun assembler
  * SAGE64 exported to "yes"
 {{{
 kir...@t2:[~/64/sage-4.5.rc0] $ ./sage -f libfplll-3.0.12.p1
 <SNIP>
 real    4m17.508s
 user    5m32.027s
 sys     1m33.492s
 Successfully installed libfplll-3.0.12.p1
 Now cleaning up tmp files.
 rm: Cannot remove any directory in the path of the current working
 directory
 /rootpool2/local/kirkby/64/sage-4.5.rc0/spkg/build/libfplll-3.0.12.p1
 Making Sage/Python scripts relocatable...
 Making script relocatable
 Finished installing libfplll-3.0.12.p1.spkg
 }}}
 An inspection of the libraries shows they are 64-bit, as expected.
 {{{
 kir...@t2:[~/64/sage-4.5.rc0] $ file local/lib/libfplll*
 local/lib/libfplll.a:   current ar archive, not a dynamic executable or
 shared object
 local/lib/libfplll.la:  commands text
 local/lib/libfplll.so:  ELF 64-bit MSB dynamic lib SPARCV9 Version 1,
 dynamically linked, not stripped, no debugging information available
 local/lib/libfplll.so.0:        ELF 64-bit MSB dynamic lib SPARCV9 Version
 1, dynamically linked, not stripped, no debugging information available
 local/lib/libfplll.so.0.1.0:    ELF 64-bit MSB dynamic lib SPARCV9 Version
 1, dynamically linked, not stripped, no debugging information available
 kir...@t2:[~/64/sage-4.5.rc0] $
 }}}


 == Testing on Solaris 10 SPARC as a 32-bit build ({{{SAGE64}}} was unset)
 ==
  * Sun Blade 2000
  * 2 x 1200 MHz UltraSPARC III+ CPUs
  * 8 GB RAM
  * Solaris 10 update 8 10/09 (The latest release of Solaris 10)
  * gcc 4.4.4 (uses Sun linker and assembler)
  * Sage 4.4.4

 {{{
 drkir...@swan:~/sage-4.4.4$ ./sage -f libfplll-3.0.12.p1
 <SNIP>
 real    2m33.007s
 user    2m40.012s
 sys     0m48.908s
 Successfully installed libfplll-3.0.12.p1
 Now cleaning up tmp files.
 rm: Cannot remove any directory in the path of the current working
 directory
 /export/home/drkirkby/sage-4.4.4/spkg/build/libfplll-3.0.12.p1
 Making Sage/Python scripts relocatable...
 Making script relocatable
 Finished installing libfplll-3.0.12.p1.spkg
 drkir...@swan:~/sage-4.4.4$ file local/lib/libfplll*
 local/lib/libfplll.a:   current ar archive, not a dynamic executable or
 shared object
 local/lib/libfplll.la:  commands text
 local/lib/libfplll.so:  ELF 32-bit MSB dynamic lib SPARC32PLUS Version 1,
 V8+ Required, dynamically linked, not stripped, no debugging information
 available
 local/lib/libfplll.so.0:        ELF 32-bit MSB dynamic lib SPARC32PLUS
 Version 1, V8+ Required, dynamically linked, not stripped, no debugging
 information available
 local/lib/libfplll.so.0.1.0:    ELF 32-bit MSB dynamic lib SPARC32PLUS
 Version 1, V8+ Required, dynamically linked, not stripped, no debugging
 information available
 }}}

 Sage at least works, though I do not know what doc tests would prove that
 libfplll was working. But I think it's a safe assumption that libfplll
 would have built ok.
 {{{
 drkir...@swan:~/sage-4.4.4$ ./sage
 ----------------------------------------------------------------------
 | Sage Version 4.4.4, Release Date: 2010-06-23                       |
 | Type notebook() for the GUI, and license() for information.        |
 ----------------------------------------------------------------------
 sage: 1+1
 2
 sage:
 }}}
 == Testing on OS X (bsd.math) This defaults to 64-bit, so no need to set
 SAGE64 ==
  * OS X 10.6
  * gcc 4.2.1

 Again, libfplll builds ok.
 {{{
 [kir...@bsd sage-4.5.rc0]$ ./sage -f libfplll-3.0.12.p1
 <SNIP>
 make[1]: Nothing to be done for `check-am'.

 real    1m5.418s
 user    0m31.424s
 sys     0m12.003s
 Successfully installed libfplll-3.0.12.p1
 }}}

 So I think this is pretty convincing that this is building properly.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7864#comment:19>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to