2011-08-24

compiling gc-7.1 on Mac OS X Lion, but error

For compiling gc-7.1 (boehm-gc) on Mac OS X Lion (Version 10.7) and Xcode 4.1, I had to edit some source files. gcc on Lion is not GNU Compiler Collection, it is llvm.

$ gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2335.15~25/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2335.15~25/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

$ ./configure
$ make
...
 gcc -DPACKAGE_NAME=\"gc\" -DPACKAGE_TARNAME=\"gc\" -DPACKAGE_VERSION=\"7.1\" "-DPACKAGE_STRING=\"gc 7.1\"" -DPACKAGE_BUGREPORT=\"Hans.Boehm@hp.com\" -DGC_VERSION_MAJOR=7 -DGC_VERSION_MINOR=1 -DPACKAGE=\"gc\" -DVERSION=\"7.1\" -DGC_DARWIN_THREADS=1 -DTHREAD_LOCAL_ALLOC=1 -DHAS_X86_THREAD_STATE32___EAX=1 -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 -DNO_EXECUTE_PERMISSION=1 -DALL_INTERIOR_POINTERS=1 -DGC_GCJ_SUPPORT=1 -DJAVA_FINALIZATION=1 -DATOMIC_UNCOLLECTABLE=1 -I./include -fexceptions -I libatomic_ops/src -g -O2 -MT os_dep.lo -MD -MP -MF .deps/os_dep.Tpo -c os_dep.c  -fno-common -DPIC -o .libs/os_dep.o
libatomic_ops/src/atomic_ops/sysdeps/gcc/x86_64.h: In function 'AO_test_and_set_full':
libatomic_ops/src/atomic_ops/sysdeps/gcc/x86_64.h:127: error: unsupported inline asm: input constraint with a matching output constraint of incompatible type!
make[1]: *** [os_dep.lo] Error 1
make: *** [all-recursive] Error 1

In libatomic_ops/src/atomic_ops/sysdeps/gcc/x86_64.h, there is a function: AO_test_and_set_full. This function uses inline assembler. I had to make the code responsive to llvm-gcc.

$ diff libatomic_ops/src/atomic_ops/sysdeps/gcc/x86_64.h.org libatomic_ops/src/atomic_ops/sysdeps/gcc/x86_64.h
129c129
<               : "0"(0xff), "m"(*addr) : "memory");
---
>               : "0"((unsigned char)0xff), "m"(*addr) : "memory");

$ make
...
 gcc -DPACKAGE_NAME=\"gc\" -DPACKAGE_TARNAME=\"gc\" -DPACKAGE_VERSION=\"7.1\" "-DPACKAGE_STRING=\"gc 7.1\"" -DPACKAGE_BUGREPORT=\"Hans.Boehm@hp.com\" -DGC_VERSION_MAJOR=7 -DGC_VERSION_MINOR=1 -DPACKAGE=\"gc\" -DVERSION=\"7.1\" -DGC_DARWIN_THREADS=1 -DTHREAD_LOCAL_ALLOC=1 -DHAS_X86_THREAD_STATE32___EAX=1 -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 -DNO_EXECUTE_PERMISSION=1 -DALL_INTERIOR_POINTERS=1 -DGC_GCJ_SUPPORT=1 -DJAVA_FINALIZATION=1 -DATOMIC_UNCOLLECTABLE=1 -I./include -fexceptions -I libatomic_ops/src -g -O2 -MT mach_dep.lo -MD -MP -MF .deps/mach_dep.Tpo -c mach_dep.c  -fno-common -DPIC -o .libs/mach_dep.o
In file included from mach_dep.c:163:
/usr/include/ucontext.h:43:2: error: #error The deprecated ucontext routines require _XOPEN_SOURCE to be defined
make[1]: *** [mach_dep.lo] Error 1
make: *** [all-recursive] Error 1

There is not /usr/include/ucontext.h on Mac. But there is /usr/include/sys/ucontext.h.

$ ack ucontext.h *
mach_dep.c
163:# include <ucontext.h>

os_dep.c
2755:#   include <ucontext.h>


$ diff mach_dep.c.org mach_dep.c
163c163
< # include <ucontext.h>
---
> # include <sys/ucontext.h>

$ diff os_dep.c.org os_dep.c
2755c2755
< #   include <ucontext.h>
---
> #   include <sys/ucontext.h>

$ make
...
(cd .libs && rm -f libcord.1.dylib && ln -s libcord.1.0.3.dylib libcord.1.dylib)
(cd .libs && rm -f libcord.dylib && ln -s libcord.1.0.3.dylib libcord.dylib)
ar cru .libs/libcord.a  cord/cordbscs.o cord/cordprnt.o cord/cordtest.o cord/cordxtra.o
ranlib .libs/libcord.a
creating libcord.la
(cd .libs && rm -f libcord.la && ln -s ../libcord.la libcord.la)
$ 

Done? I checked.


$ make check
...
tests/thread_leak_test.c: In function ‘main’:
tests/thread_leak_test.c:38: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 2 has type ‘int’
tests/thread_leak_test.c:38: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 2 has type ‘int’
/bin/sh ./libtool --tag=CC --mode=link gcc -fexceptions -I libatomic_ops/src -g -O2   -o threadleaktest  tests/thread_leak_test.o ./libgc.la  
gcc -fexceptions -I libatomic_ops/src -g -O2 -o .libs/threadleaktest tests/thread_leak_test.o  ./.libs/libgc.dylib -lpthread
creating threadleaktest
make  check-TESTS
Switched to incremental mode
Emulating dirty bits with mprotect/signals
List reversal produced incorrect list - collector is broken
Test failed
/bin/sh: line 1: 55042 Abort trap: 6           ${dir}$tst
FAIL: gctest
Leaked composite object at 0x10162cee0 (tests/leak_test.c:12, sz=13, NORMAL)

Leaked composite object at 0x10162cf20 (tests/leak_test.c:12, sz=12, NORMAL)

Leaked composite object at 0x10162cf60 (tests/leak_test.c:12, sz=11, NORMAL)

Leaked composite object at 0x10162cfa0 (tests/leak_test.c:12, sz=10, NORMAL)

Leaked composite object at 0x10162cfe0 (tests/leak_test.c:12, sz=9, NORMAL)

Leaked composite object at 0x10162bf20 (tests/leak_test.c:12, sz=8, NORMAL)

Leaked composite object at 0x10162bf50 (tests/leak_test.c:12, sz=7, NORMAL)

Leaked composite object at 0x10162bf80 (tests/leak_test.c:12, sz=6, NORMAL)

Leaked composite object at 0x10162bfb0 (tests/leak_test.c:12, sz=5, NORMAL)

Leaked composite object at 0x10162bfe0 (tests/leak_test.c:12, sz=4, NORMAL)

GC_debug_free: found smashed location at 0x10162bfa8 in or near object at 0x10162bfb0(0�b:0, sz=0)
GC_debug_free: found smashed location at 0x10162bf78 in or near object at 0x10162bf80(EMPTY(smashed?):0, sz=0)
GC_debug_free: found smashed location at 0x10162bf48 in or near object at 0x10162bf50(EMPTY(smashed?):0, sz=0)
GC_debug_free: found smashed location at 0x10162bf18 in or near object at 0x10162bf20(, appr. sz = 9)
GC_debug_free: found smashed location at 0x10162cfd8 in or near object at 0x10162cfe0(@�b:0, sz=0)
GC_debug_free: found smashed location at 0x10162cf98 in or near object at 0x10162cfa0(EMPTY(smashed?):0, sz=0)
GC_debug_free: found smashed location at 0x10162cf58 in or near object at 0x10162cf60(��b:0, sz=0)
GC_debug_free: found smashed location at 0x10162cf18 in or near object at 0x10162cf20(EMPTY(smashed?):0, sz=0)
GC_debug_free: found smashed location at 0x10162ced8 in or near object at 0x10162cee0(, appr. sz = 25)
/bin/sh: line 1: 55061 Segmentation fault: 11  ${dir}$tst
FAIL: leaktest
Final heap size is 131072
PASS: middletest
GC_check_heap_block: found smashed heap objects:
0x10df1dfe8 in or near object at 0x10df1dfc0(tests/smash_test.c:21, sz=40)
GC_check_heap_block: found smashed heap objects:
0x10df1dfe8 in or near object at 0x10df1dfc0(tests/smash_test.c:21, sz=40)
GC_check_heap_block: found smashed heap objects:
0x10df90f98 in or near object at 0x10df90f70(tests/smash_test.c:21, sz=40)
0x10df1dfe8 in or near object at 0x10df1dfc0(tests/smash_test.c:21, sz=40)
PASS: smashtest
GC Warning: Out of Memory!  Returning NIL!
GC Warning: Out of Memory!  Returning NIL!
GC Warning: Out of Memory!  Returning NIL!
PASS: hugetest
Leaked composite object at 0x10b7a8fe0 (tests/thread_leak_test.c:14, sz=4, NORMAL)

Leaked composite object at 0x10b7a8f80 (tests/thread_leak_test.c:14, sz=4, NORMAL)

Leaked composite object at 0x10b7a8ef0 (tests/thread_leak_test.c:14, sz=4, NORMAL)

Leaked composite object at 0x10b7a8d40 (tests/thread_leak_test.c:14, sz=4, NORMAL)

Leaked composite object at 0x10b7a8e30 (tests/thread_leak_test.c:14, sz=4, NORMAL)

PASS: threadleaktest
==================================
2 of 6 tests failed
Please report to Hans.Boehm@hp.com
==================================
make[2]: *** [check-TESTS] Error 1
make[1]: *** [check-am] Error 2
make: *** [check-recursive] Error 1

It failed in gctest and leaktest and Segmentation fault occurred.

I went under and found the github repository on Wikipedia: Boehm garbage collector. It would appear that the repository is updated frequently. I think there is hope.

Thanks.

0 comments:

Post a Comment