From 72d5537ab2355b2114e4477e8cfee69c7b26a8bf Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Thu, 7 Sep 2006 05:39:37 +0000 Subject: [PATCH] Add "--gc" option to build in Boehm GC allocator. [SVN r35031] --- src/engine/build.jam | 60 ++++++++++++++++++++++++++++---------------- src/engine/mem.c | 60 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 22 deletions(-) create mode 100644 src/engine/mem.c diff --git a/src/engine/build.jam b/src/engine/build.jam index f95b31c91..3dea7c2ed 100644 --- a/src/engine/build.jam +++ b/src/engine/build.jam @@ -84,6 +84,16 @@ if $(with-python) } } +# Boehm GC? +if --gc in $(ARGV) +{ + --boehm-gc = true ; +} +if $(--boehm-gc) +{ + --boehm-gc-include = [ .path [ PWD ] "boehm_gc" "include" ] ; +} + # An explicit root for the toolset? (trim spaces) toolset-root = [ MATCH --toolset-root=(.*) : $(ARGV) ] ; { @@ -119,14 +129,14 @@ toolset acc cc : "-o " : -D : -Ae [ opt --release : -s -O3 ] [ opt --debug : -g -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Borland C++ 5.5.x toolset borland bcc32 : -e -n : /D : -WC -w- -q "-I$(toolset-root)Include" "-L$(toolset-root)Lib" [ opt --release : -O2 -vi -w-inl ] [ opt --debug : -v -Od -vi- ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : $(--python-lib[1]) ; ## Generic Unix cc if ! $(CC) { CC = cc ; } @@ -134,63 +144,63 @@ toolset cc $(CC) : "-o " : -D : $(CFLAGS) [ opt --release : -s -O ] [ opt --debug : -g ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : $(LIBS) -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Comeau C/C++ 4.x toolset como como : "-o " : -D : --c [ opt --release : --inlining ] [ opt --debug : --no_inlining ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## MacOSX Darwin, using GCC 2.9.x, 3.x toolset darwin cc : "-o " : -D : [ opt --release : -Wl,-x -O3 -finline-functions ] [ opt --debug : -g -O0 -fno-inline -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## GCC 2.x, 3.x, 4.x toolset gcc gcc : "-o " : -D : -pedantic [ opt --release : [ opt --symbols : -g : -s ] -O3 ] [ opt --debug : -g -O0 -fno-inline ] - -I$(--python-include) -Wno-long-long + -I$(--python-include) -I$(--boehm-gc-include) -Wno-long-long : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## GCC 2.x, 3.x on CYGWIN but without cygwin1.dll toolset gcc-nocygwin gcc : "-o " : -D : -s -O3 -mno-cygwin [ opt --release : -finline-functions ] [ opt --debug : -s -O3 -fno-inline -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Intel C/C++ for Linux toolset intel-linux icc : "-o " : -D : [ opt --release : -Xlinker -s -O3 ] [ opt --debug : -g -O0 -p ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Intel C/C++ for Win32 toolset intel-win32 icl : /Fe : -D : /nologo [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ] [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## KCC ? toolset kcc KCC : "-o " : -D : [ opt --release : -s +K2 ] [ opt --debug : -g +K0 ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Borland Kylix toolset kylix bc++ : -o : -D : -tC -q [ opt --release : -O2 -vi -w-inl ] [ opt --debug : -v -Od -vi- ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Metrowerks CodeWarrior 8.x { @@ -201,7 +211,7 @@ toolset kylix bc++ : -o : -D : -c -lang c -subsystem console -cwd include [ opt --release : -runtime ss -opt full -inline all ] [ opt --debug : -runtime ssd -opt none -inline off ] - -I$(--python-include) ; + -I$(--python-include) -I$(--boehm-gc-include) ; toolset metrowerks $(mwcc) .link : "-o " : : -subsystem console -lkernel32.lib -ladvapi32.lib -luser32.lib [ opt --release : -runtime ss ] @@ -213,28 +223,28 @@ toolset mingw gcc : "-o " : -D : [ opt --release : -s -O3 -finline-functions ] [ opt --debug : -g -O0 -fno-inline -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : $(--python-lib[2]) ; ## MIPS Pro toolset mipspro cc : "-o " : -D : [ opt --release : -s -O3 -g0 -INLINE:none ] [ opt --debug : -g -O0 -INLINE ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Microsoft Visual Studio C++ 6.x toolset msvc cl : /Fe : -D : /nologo [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ] [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## QNX 6.x GCC 3.x/2.95.3 toolset qcc qcc : "-o " : -D : -Wc,-pedantic [ opt --release : [ opt --symbols : -g ] -O3 -Wc,-finline-functions ] [ opt --debug : -g -O0 -Wc,-fno-inline ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Sun Workshop 6 C++ toolset sunpro cc : "-o " : -D @@ -242,35 +252,35 @@ toolset sunpro cc : "-o " : -D [ opt --release : -s -fast -xO4 ] [ opt --debug : -g ] -xarch=generic - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Compaq Alpha CXX toolset tru64cxx cc : "-o " : -D : [ opt --release : -s -O5 -inline speed ] [ opt --debug : -g -O0 -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## IBM VisualAge C++ toolset vacpp xlc : "-o " : -D : [ opt --release : -s -O3 -qstrict -qinline ] [ opt --debug : -g -qNOOPTimize -qnoinline -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Microsoft Visual C++ .NET 7.x toolset vc7 cl : /Fe : -D : /nologo [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ] [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## Microsoft Visual C++ 2005 toolset vc8 cl : /Fe : -D : /nologo [ opt --release : /MT /O2 /Ob2 /Gy /GF /GA /wd4996 ] [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## VMS/OpenVMS DEC C toolset vmsdecc cc : /OBJECT= : "/DEFINES=(" "," ")" @@ -378,7 +388,7 @@ jam.source = command.c compile.c debug.c expand.c glob.c hash.c hcache.c headers.c hdrmacro.c jam.c jambase.c jamgram.c - lists.c make.c make1.c newstr.c + lists.c make.c make1.c mem.c newstr.c option.c parse.c regexp.c rules.c scan.c search.c subst.c w32_getreg.c timestamp.c variable.c modules.c strings.c filesys.c @@ -427,6 +437,12 @@ if ! $(debug) || --noassert in $(ARGV) # Improvements --defs += OPT_IMPROVED_PATIENCE_EXT ; +# Use Boehm GC memory allocator? +if $(--boehm-gc) +{ + --defs += OPT_BOEHM_GC ; +} + if ( $(OS) = NT || $(NT) ) && ! NT in $(--defs) { --defs += NT ; diff --git a/src/engine/mem.c b/src/engine/mem.c new file mode 100644 index 000000000..5457bffee --- /dev/null +++ b/src/engine/mem.c @@ -0,0 +1,60 @@ +/* +Copyright Rene Rivera 2006. +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) +*/ + +#include "mem.h" + +#ifdef OPT_BOEHM_GC + + /* Compile the Boehm GC as one big chunk of code. It's much easier + this way, than trying to make radical changes to the bjam build + scripts. */ + + #define ATOMIC_UNCOLLECTABLE + #define NO_SIGNALS + #define NO_EXECUTE_PERMISSION + #define SILENT + #define ALL_INTERIOR_POINTERS + #define LARGE_CONFIG + #define NO_DEBUGGING + + #include "boehm_gc/reclaim.c" + #include "boehm_gc/allchblk.c" + #include "boehm_gc/misc.c" + #include "boehm_gc/alloc.c" + #include "boehm_gc/mach_dep.c" + #include "boehm_gc/os_dep.c" + #include "boehm_gc/mark_rts.c" + #include "boehm_gc/headers.c" + #include "boehm_gc/mark.c" + #include "boehm_gc/obj_map.c" + #include "boehm_gc/pcr_interface.c" + #include "boehm_gc/blacklst.c" + #include "boehm_gc/new_hblk.c" + #include "boehm_gc/real_malloc.c" + #include "boehm_gc/dyn_load.c" + #include "boehm_gc/dbg_mlc.c" + #include "boehm_gc/malloc.c" + #include "boehm_gc/stubborn.c" + #include "boehm_gc/checksums.c" + #include "boehm_gc/solaris_threads.c" + #include "boehm_gc/pthread_support.c" + #include "boehm_gc/pthread_stop_world.c" + #include "boehm_gc/darwin_stop_world.c" + #include "boehm_gc/typd_mlc.c" + #include "boehm_gc/ptr_chck.c" + #include "boehm_gc/mallocx.c" + #include "boehm_gc/solaris_pthreads.c" + #include "boehm_gc/gcj_mlc.c" + #include "boehm_gc/specific.c" + #include "boehm_gc/gc_dlopen.c" + #include "boehm_gc/backgraph.c" + #include "boehm_gc/win32_threads.c" + + /* Needs to be last. */ + #include "boehm_gc/finalize.c" + +#endif