b=416117; allow building jemalloc on windows with vc9sp1; r=ted
authorVladimir Vukicevic <vladimir@pobox.com>
Tue, 22 Sep 2009 13:00:18 -0700
changeset 32967 cd6dde027905a04ef43113422c2769d91014418a
parent 32966 6145f214008b4dc6b9da89dbac220d506dd89c1d
child 32968 740d8456dd783bf135337564a4d8ed62049c9bc3
push idunknown
push userunknown
push dateunknown
reviewersted
bugs416117
milestone1.9.3a1pre
b=416117; allow building jemalloc on windows with vc9sp1; r=ted
configure.in
memory/jemalloc/Makefile.in
memory/jemalloc/crtsp1.diff
memory/jemalloc/crtvc8sp1.diff
memory/jemalloc/crtvc9sp1.diff
--- a/configure.in
+++ b/configure.in
@@ -6428,18 +6428,18 @@ if test "$MOZ_MEMORY"; then
     AC_DEFINE(MOZ_MEMORY_BSD)
     ;;
   solaris*)
     AC_DEFINE(MOZ_MEMORY_SOLARIS)
     ;;
   msvc*|mks*|cygwin*|mingw*)
     AC_DEFINE(MOZ_MEMORY_WINDOWS)
     dnl This is sort of awful. Will revisit if we add support for more versions
-    if test "$CC_VERSION" != "14.00.50727.762"; then
-        AC_MSG_ERROR([Building jemalloc requires exactly Visual C++ 2005 SP1 currently.])
+    if test "$CC_VERSION" != "14.00.50727.762" -a "$CC_VERSION" != "15.00.30729.01"; then
+        AC_MSG_ERROR([Building jemalloc requires exactly Visual C++ 2005 SP1 or 2008 SP1 currently.])
     fi
     if test -z "$WIN32_CRT_SRC_DIR"; then
       if test -z "$VCINSTALLDIR" -o ! -d "$VCINSTALLDIR"; then
         AC_MSG_ERROR([When building jemalloc, set WIN32_CRT_SRC_DIR to the path to the Visual C++ CRT source (usually VCINSTALLDIR\crt\src, but VCINSTALLDIR is not set, so I can't autodetect it for you).])
       else
         WIN32_CRT_SRC_DIR="$VCINSTALLDIR\crt\src"
       fi
     fi
--- a/memory/jemalloc/Makefile.in
+++ b/memory/jemalloc/Makefile.in
@@ -69,24 +69,30 @@ libs:: $(MOZ_CRT_DLL) $(MOZ_CRT_IMPORT_L
 $(MOZ_CRT_IMPORT_LIB): $(MOZ_CRT_DLL)
 
 define EXTRACT_CMD
 cd $(CRT_OBJ_DIR)/intel/$(i)_lib && lib "-extract:..\\build\\intel\\$(i)_obj\\unhandld.obj" eh.lib
 
 endef # don't touch the blank line. actually, don't touch anything in this file.
 
 # patch if necessary
-$(CRT_OBJ_DIR)/jemalloc.c: $(srcdir)/crtsp1.diff
+ifeq ($(CC_VERSION), 14.00.50727.762)
+CRTDIFF=crtvc8sp1.diff
+else
+CRTDIFF=crtvc9sp1.diff
+endif
+
+$(CRT_OBJ_DIR)/jemalloc.c: $(srcdir)/$(CRTDIFF)
 	rm -rf $(CRT_OBJ_DIR)
 	cp -R "$(WIN32_CRT_SRC_DIR)" $(CRT_OBJ_DIR)
 # per http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1189363&SiteID=1
 	$(foreach i,dll mt xdll xmt,$(EXTRACT_CMD))
 # truly awful
 #XXX: get ed into mozillabuild, bug 415123
-	$(PERL) $(srcdir)/apply-ed-patches.pl $(srcdir)/crtsp1.diff \
+	$(PERL) $(srcdir)/apply-ed-patches.pl $(srcdir)/$(CRTDIFF) \
 	$(CRT_OBJ_DIR) $(srcdir)/ed.exe
 
 $(MOZ_CRT_DLL): \
   $(CRT_OBJ_DIR)/jemalloc.c $(srcdir)/jemalloc.c $(srcdir)/jemalloc.h \
   $(srcdir)/ql.h $(srcdir)/qr.h $(srcdir)/rb.h
 	cp $(srcdir)/jemalloc.c $(srcdir)/jemalloc.h $(srcdir)/ql.h \
 	$(srcdir)/qr.h $(srcdir)/rb.h $(CRT_OBJ_DIR)
 # this pretty much sucks, but nmake and make don't play well together
rename from memory/jemalloc/crtsp1.diff
rename to memory/jemalloc/crtvc8sp1.diff
new file mode 100644
--- /dev/null
+++ b/memory/jemalloc/crtvc9sp1.diff
@@ -0,0 +1,218 @@
+# The Microsoft C Runtime source code to which this document refers is available
+# directly from Microsoft Corporation, under a separate license.
+# Please ensure that if you are using that source code, you have appropriate
+# rights to use it.  By providing you access to this file, Mozilla Corporation
+# and its affiliates do not purport to grant any rights in that source code. 
+# Binaries are available under separate licenses at 
+# http://www.microsoft.com/downloads/details.aspx?familyid=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF&displaylang=en
+diff -re crt/src/_sample_.rc crtsrc/_sample_.rc
+41c
+            VALUE "ProductName", "Mozilla Custom C Runtime"
+.
+39c
+            VALUE "OriginalFilename", "MOZCRT19.DLL"
+.
+37c
+            VALUE "OriginalFilename", "MOZCRT19D.DLL"
+.
+33c
+            VALUE "InternalName", "MOZCRT19.DLL"
+.
+31c
+            VALUE "InternalName", "MOZCRT19D.DLL"
+.
+27c
+            VALUE "CompanyName", "Mozilla Foundation"
+.
+diff -re crt/src/crt0.c crtsrc/crt0.c
+212c
+        /*
+         * this used to happen in _mtinit, but we need it before malloc
+         */
+        _init_pointers();       /* initialize global function pointers */
+
+        if ( malloc_init_hard() )                /* initialize heap */
+.
+87a
+extern BOOL malloc_init_hard(void);
+.
+diff -re crt/src/crt0dat.c crtsrc/crt0dat.c
+837d
+826d
+diff -re crt/src/crtdll.c crtsrc/crtdll.c
+31,40d
+diff -re crt/src/crtexe.c crtsrc/crtexe.c
+322,324d
+35,45d
+diff -re crt/src/crtheap.c crtsrc/crtheap.c
+61c
+    pv = calloc(count, size);
+.
+58,59d
+diff -re crt/src/crtlib.c crtsrc/crtlib.c
+686,693d
+355d
+339a
+                 malloc_shutdown();
+
+.
+298d
+279d
+249,250d
+239d
+226c
+            /*
+             * this used to happen in _mtinit, but we need it before malloc
+             */
+            _init_pointers();       /* initialize global function pointers */
+
+            if ( malloc_init_hard() )   /* initialize heap */
+.
+43a
+extern BOOL malloc_init_hard(void);
+extern void malloc_shutdown(void);
+
+.
+diff -re crt/src/dllcrt0.c crtsrc/dllcrt0.c
+189,190d
+136d
+126d
+111d
+106,108d
+diff -re crt/src/intel/_sample_.def crtsrc/intel/_sample_.def
+1198d
+718,719d
+664a
+    posix_memalign
+.
+638a
+    memalign
+.
+495a
+    malloc_usable_size
+.
+331,336d
+319d
+313,314d
+81d
+9c
+LIBRARY MOZCRT19
+.
+diff -re crt/src/internal.h crtsrc/internal.h
+413a
+#endif
+.
+409c
+#if 0
+.
+diff -re crt/src/makefile crtsrc/makefile
+1873c
+-def:$(DEFFILE2_DIR)\sample_p.def
+.
+1841c
+ $(DEFFILE2_DIR)\sample_p.def $(CPPSRC_OBJS_DLL:*=dll) \
+.
+1771a
+$(DEFFILE_DIR)\$(RETAIL_LIB_NAME).def : $(DEFFILE_DIR)\_sample_.def
+	copy $** $@
+.
+1290d
+1235,1237d
+760c
+dll_ :: $(OBJROOT) $(OBJCPUDIR) $(OBJDIR_DLL) $(OBJDIR_DLL)\$(PURE_OBJ_DIR) \
+   	$(OBJDIR_DLL)\$(CPP_OBJ_DIR) \
+   	$(RELDIR_CPU) $(PDBDIR_CPU_DLL) $(MAKE_DIRS_DLL)
+.
+340c
+CC_OPTS_BASE=-c -nologo -Zlp8 -W3 -GFy -DWIND32
+.
+213d
+21,24c
+RETAIL_DLL_NAME=MOZCRT19
+RETAIL_LIB_NAME=mozcrt19
+RETAIL_DLLCPP_NAME=MOZCPP19
+RETAIL_LIBCPP_NAME=mozcpp19
+.
+diff -re crt/src/makefile.inc crtsrc/makefile.inc
+1636a
+$(OBJDIR)\unhandld.obj: $(PREOBJDIR)\unhandld.obj
+        copy $(PREOBJDIR)\unhandld.obj $@
+
+.
+623d
+621d
+405d
+344,356c
+        $(OBJDIR)\jemalloc.obj  \
+.
+336,337d
+331,332d
+329d
+325d
+321,322d
+diff -re crt/src/makefile.sub crtsrc/makefile.sub
+66c
+CFLAGS=$(CFLAGS) -O2 -DMOZ_MEMORY=1 -DMOZ_MEMORY_WINDOWS=1 -arch:SSE2
+.
+diff -re crt/src/malloc.h crtsrc/malloc.h
+189a
+#endif
+.
+177a
+
+#if 0
+.
+83a
+#endif
+.
+70a
+#if 0
+.
+diff -re crt/src/mlock.c crtsrc/mlock.c
+274c
+#endif
+.
+262a
+#if 0
+.
+diff -re crt/src/new.cpp crtsrc/new.cpp
+60d
+52,55d
+37,38c
+        break;
+.
+diff -re crt/src/nothrownew.cpp crtsrc/nothrownew.cpp
+38c
+#endif
+.
+31a
+#if 1
+        break;
+#else
+
+.
+diff -re crt/src/sample_p.def crtsrc/sample_p.def
+8c
+LIBRARY mozcpp19
+.
+diff -re crt/src/sample_p.rc crtsrc/sample_p.rc
+41c
+            VALUE "ProductName", "Mozilla Custom C++ Runtime"
+.
+39c
+            VALUE "OriginalFilename", "MOZCPP19.DLL"
+.
+37c
+            VALUE "OriginalFilename", "MOZCPP19D.DLL"
+.
+33c
+            VALUE "InternalName", "MOZCPP19.DLL"
+.
+31c
+            VALUE "InternalName", "MOZCPP19D.DLL"
+.
+27c
+            VALUE "CompanyName", "Mozilla Foundation"
+.
+diff -re crt/src/tidtable.c crtsrc/tidtable.c
+360,361d