URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [boehm-gc/] [doc/] [README.linux] - Rev 721
Compare with Previous | Blame | View Log
See README.alpha for Linux on DEC AXP info.This file applies mostly to Linux/Intel IA32. Ports to Linux on an M68K, IA64,SPARC, MIPS, Alpha and PowerPC are also integrated. They should behavesimilarly, except that the PowerPC port lacks incremental GC support, andit is unknown to what extent the Linux threads code is functional.See below for M68K specific notes.Incremental GC is generally supported.Dynamic libraries are supported on an ELF system. A static executableshould be linked with the gcc option "-Wl,-defsym,_DYNAMIC=0".The collector appears to work reliably with Linux threads, but bewareof older versions of glibc and gdb.The garbage collector uses SIGPWR and SIGXCPU if it is used withLinux threads. These should not be touched by the client program.To use threads, you need to abide by the following requirements:1) You need to use LinuxThreads or NPTL (which are included in libc6).The collector relies on some implementation details of the LinuxThreadspackage. This code may not work on otherpthread implementations (in particular it will *not* work withMIT pthreads).2) You must compile the collector with -DGC_LINUX_THREADS and -D_REENTRANTspecified in the Makefile.3a) Every file that makes thread calls should define GC_LINUX_THREADS and_REENTRANT and then include gc.h. Gc.h redefines some of thepthread primitives as macros which also provide the collector withinformation it requires.3b) A new alternative to (3a) is to build the collector and compile GC clientswith -DGC_USE_LD_WRAP, and to link the final program with(for ld) --wrap read --wrap dlopen --wrap pthread_create \--wrap pthread_join --wrap pthread_detach \--wrap pthread_sigmask --wrap sleep(for gcc) -Wl,--wrap -Wl,read -Wl,--wrap -Wl,dlopen -Wl,--wrap \-Wl,pthread_create -Wl,--wrap -Wl,pthread_join -Wl,--wrap \-Wl,pthread_detach -Wl,--wrap -Wl,pthread_sigmask \-Wl,--wrap -Wl,sleepIn any case, _REENTRANT should be defined during compilation.4) Dlopen() disables collection during its execution. (It can't runconcurrently with the collector, since the collector looks at itsdata structures. It can't acquire the allocator lock, since arbitraryuser startup code may run as part of dlopen().) Under unusualconditions, this may cause unexpected heap growth.5) The combination of GC_LINUX_THREADS, REDIRECT_MALLOC, and incrementalcollection fails in seemingly random places. This hasn't been trackeddown yet, but is perhaps not completely astonishing. The thread packageuses malloc, and thus can presumably get SIGSEGVs while inside thepackage. There is no real guarantee that signals are handled properlyat that point.6) Thread local storage may not be viewed as part of the root set by thecollector. This probably depends on the linuxthreads version. For thetime being, any collectable memory referenced by thread local storage shouldalso be referenced from elsewhere, or be allocated as uncollectable.(This is really a bug that should be fixed somehow.)M68K LINUX:(From Richard Zidlicky)The bad news is that it can crash every linux-m68k kernel on a 68040,so an additional test is needed somewhere on startup. I have meanwhilepatches to correct the problem in 68040 buserror handler but it is notyet in any standard kernel.Here is a simple test program to detect whether the kernel has theproblem. It could be run as a separate check in configure or testedupon startup. If it fails (return !0) than mprotect can't be usedon that system./** test for bug that may crash 68040 based Linux*/#include <sys/mman.h>#include <signal.h>#include <unistd.h>#include <stdio.h>#include <stdlib.h>char *membase;int pagesize=4096;int pageshift=12;int x_taken=0;int sighandler(int sig){mprotect(membase,pagesize,PROT_READ|PROT_WRITE);x_taken=1;}main(){long l;signal(SIGSEGV,sighandler);l=(long)mmap(NULL,pagesize,PROT_READ,MAP_PRIVATE | MAP_ANON,-1,0);if (l==-1){perror("mmap/malloc");abort();}membase=(char*)l;*(long*)(membase+sizeof(long))=123456789;if (*(long*)(membase+sizeof(long)) != 123456789 ){fprintf(stderr,"writeback failed !\n");exit(1);}if (!x_taken){fprintf(stderr,"exception not taken !\n");exit(1);}fprintf(stderr,"vmtest Ok\n");exit(0);}
