[mercury-users] dynamic linking, Guile

Tomas By tomas at basun.net
Sun Feb 7 01:23:02 AEDT 2010


Hi all,

I am trying to write a Guile module in Mercury. Have created a dynamic
library using the Mercury compiler, but when I try to load it in Guile,
with "dynamic link", I get errors. Apparently Guile, like Mercury, uses
the Boehm GC, and the problem seems related to this. In my first try,
my Mercury .so was linked with the libgc.so in the Mercury distribution,
and then I tried linking it with the one that Guile uses instead (by
the crude method of renaming the Mercury libgc.so). It seems to me that
the problems are the same in both cases. What the "mmap2", "mprotect",
and "munmap" calls are about I do not know.

Has anybody done this before? Could somebody explain how to tell the
Mercury compiler to use the system wide libgc using polite language?

Any help appreciated. Output from strace follows.

/Tomas

---------- begin Mercury GC ---------------------------------------
open("/usr/local/mercury-rotd-2009-12-28/lib/mercury/lib/libgc.so",
O_RDONLY) = 9
read(9,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0 at y\0\0004\0\0\0"..., 512)
= 512
fstat64(9, {st_mode=S_IFREG|0755, st_size=121223, ...}) = 0
mmap2(NULL, 464944, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 9, 0)
= 0x9a4000
mmap2(0x9bb000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 9, 0x17) = 0x9bb000
mmap2(0x9bd000, 362544, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x9bd000
close(9)                                = 0
mprotect(0x9bb000, 4096, PROT_READ)     = 0
mprotect(0x298000, 4096, PROT_READ)     = 0
mprotect(0x11b2000, 126976, PROT_READ)  = 0
mprotect(0x422000, 20480, PROT_READ|PROT_WRITE) = 0
munmap(0x422000, 24684)                 = 0
munmap(0xdec000, 6385312)               = 0
munmap(0x255000, 287840)                = 0
munmap(0x9a4000, 464944)                = 0
----------------------------------------------------------------

---------- begin Guile GC -----------------------------------------
open("/usr/lib/libgc.so", O_RDONLY)     = 9
read(9, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0
\200\0\0004\0\0\0"..., 512) = 512
fstat64(9, {st_mode=S_IFREG|0644, st_size=137280, ...}) = 0
mmap2(NULL, 206620, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 9, 0)
= 0x49b000
mmap2(0x4bc000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 9, 0x20) = 0x4bc000
mmap2(0x4be000, 63260, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x4be000
close(9)                                = 0
open("/usr/local/mercury-rotd-2009-12-28/lib/mercury/lib/libgcc_s.so.1",
O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/local/mercury-rotd-2009-12-28/lib/mercury/lib/asm_fast.gc/libgcc_s.so.1",
O_RDONLY) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or
directory)
open("/lib/libgcc_s.so.1", O_RDONLY)    = 9
read(9,
"\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0p#\0\0004\0\0\0"..., 512)
= 512
fstat64(9, {st_mode=S_IFREG|0644, st_size=116272, ...}) = 0
mmap2(NULL, 119336, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 9, 0)
= 0xe5b000
mmap2(0xe77000, 8192, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 9, 0x1b) = 0xe77000
close(9)                                = 0
mprotect(0xe77000, 4096, PROT_READ)     = 0
mprotect(0x4bc000, 4096, PROT_READ)     = 0
munmap(0xb782b000, 91754)               = 0
munmap(0xab8000, 24684)                 = 0
munmap(0xf83000, 6385312)               = 0
munmap(0x304000, 287840)                = 0
munmap(0x49b000, 206620)                = 0
munmap(0xe5b000, 119336)                = 0
------------------------------------------------------------------


--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list