pnkfelix / larceny-test

test import of trac db
Other
2 stars 0 forks source link

ctools flag for 64 bit systems #488

Open larceny-trac-import opened 11 years ago

larceny-trac-import commented 11 years ago

_Reported by: pnkfelix on Tue Oct 23 14:05:14 2007 _ Ray Racine writes:

Nice to see the FFI using cc to determine offsets in cstructs.  
I was segfaulting on my AMD64, Linux system however as gcc defaults to
64-bit compilation.  

After adding the -m32 flag to the cc options its working fine.

I have a bit of code from awhile back where I did a hand layout for
using Larceny with libusb.  I'll try and redo it this weekend to use the
ctools approach.

$ svn diff foreign-ctools.sch 
Index: foreign-ctools.sch
===================================================================
--- foreign-ctools.sch  (revision 5010)
+++ foreign-ctools.sch  (working copy)
@@ -188,6 +188,7 @@
                              (string-append
                               cc " "
                               include-directives
+                              " -m32 "
                               " -D_XOPEN_SOURCE=500 "
                               " -o " exe-path
                               " "  c-src-path)))))

On November 4th, Ray adds:

For completeness regarding Ticket 488.  To build Larceny on a 64 bit
system the following the 3 changes are required.

--------------

The first spoofs the system to be a i386 to the FFI.

[raymond@corwin larceny_src]$ svn diff lib/Ffi/ffi-load.sch
Index: lib/Ffi/ffi-load.sch
===================================================================
--- lib/Ffi/ffi-load.sch        (revision 5067)
+++ lib/Ffi/ffi-load.sch        (working copy)
@@ -25,6 +25,10 @@
                  (zero?
                   (system "test \"`uname -m | grep 'i.86'`x\" != \"x
\"")))
             'i386-linux)
+            ((and (string=? os "Linux")
+                  (zero?
+                   (system "test \"`uname -m | grep 'x86_64'`x\" != \"x
\"")))
+             'i386-linux)
            (else
             (error "FFI: unsupported operating system " os)))))

-------------------------

The second change is to add the -m32 compiler flag so ctools generate 32
bit code for struct layouts.  Harmless on a 32 bit system I'd think.

[raymond@corwin larceny_src]$ svn diff lib/Standard/foreign-ctools.sch 
Index: lib/Standard/foreign-ctools.sch
===================================================================
--- lib/Standard/foreign-ctools.sch     (revision 5067)
+++ lib/Standard/foreign-ctools.sch     (working copy)
@@ -188,6 +188,7 @@
                              (string-append
                               cc " "
                               include-directives
+                              " -m32 "
                               " -D_XOPEN_SOURCE=500 "
                               " -o " exe-path
                               " "  c-src-path)))))

--------------------------

The final change is to add the same -m32 flag into the Rts Makefile
template.  Its there twice, once for compiling and then for linking.

[raymond@corwin larceny_src]$ svn diff src/Rts/make-templates.sch 
Index: src/Rts/make-templates.sch
===================================================================
--- src/Rts/make-templates.sch  (revision 5067)
+++ src/Rts/make-templates.sch  (working copy)
@@ -163,7 +163,7 @@
 CC=gcc
 DEBUGINFO=#-g -gstabs+
 OPTIMIZE=-O3 -DNDEBUG2 # -DNDEBUG
-CFLAGS+=-c -falign-functions=4
+CFLAGS+=-c -falign-functions=4 -m32
 LIBS=-ldl -lm
 AS=nasm
 ASFLAGS+=-f elf -g -DLINUX"))
@@ -356,7 +356,7 @@

 (define make-template-target-sassy-unix-static
 "larceny.bin: $(X86_SASSY_LARCENY_OBJECTS)
-       $(CC) $(PROFILE) $(TCOV) -o larceny.bin
$(X86_SASSY_LARCENY_OBJECTS) \\
+       $(CC) $(PROFILE) -m32 $(TCOV) -o larceny.bin
$(X86_SASSY_LARCENY_OBJECTS) \\
                $(LIBS) $(EXTRALIBS) $(EXTRALIBPATH) $(LDXFLAGS)
        rm Sys/version.$(O)")
larceny-trac-import commented 11 years ago

Author: pnkfelix See changeset:5100.

larceny-trac-import commented 11 years ago

Author: pnkfelix Will and I noticed some warning messages being emitted on Solaris machines, so we may want to refine changeset:5100 so that does not affect Solaris targets.

larceny-trac-import commented 11 years ago

Author: will If this is now just a matter of annoying warning messages on Sparc builds, then Will thinks its priority should be downgraded to trivial.