3.5 The Compiler

The GAP compiler sf GAC creates C code from GAP code and then calls the system's C compiler to produce machine code from it. This can result in a speedup (see section Suitability for Compilation for more details).

To use the compiler to produce dynamically loadable modules, call it with the '-d' option:

M193 /home/ahulpke > gap4/bin/gac -d test.g
gap4/bin/i386-ibm-linux-gcc2/gap -C /tmp/5827_test.c test.g Init_Dynamic
gcc -fpic -ansi -Wall -O2 -o /tmp/5827_test.o -I
gap4/bin/i386-ibm-linux-gcc2/../../src -c /tmp/5827_test.c
ld -Bshareable -x -o test.so /tmp/5827_test.o
rm -f /tmp/5827_test.o
rm -f /tmp/5827_test.c
This produces a file file.so.

  • LoadDynamicModule( filename ) F
    LoadDynamicModule( filename, crc )

    To load a compiled file, the command LoadDynamicModule is used. This command loads filename as module. If given, the CRC checksum crc must match the value of the module (see CRC Numbers).

    gap> LoadDynamicModule("./test.so");
    gap> CrcFile("test.g");
    2906458206
    gap> LoadDynamicModule("./test.so",1);
    Error <crc> mismatch (or no support for dynamic loading) at
    Error( "<crc> mismatch (or no support for dynamic loading)" );
    Entering break read-eval-print loop, you can 'quit;' to quit to outer loop,
    or you can return to continue
    brk> quit;
    gap> LoadDynamicModule("./test.so",2906458206);
    

    If you want to see or modify the intermediate C code, you can also instruct the compiler to produce only the C files by using the option -C instead of -d.

    [Top] [Previous] [Up] [Next] [Index]

    GAP 4 manual
    February 2000