MozTW 討論區

各項 Mozilla 相關軟體與技術討論
現在的時間是 2020-12-01, 08:02

所有顯示的時間為 UTC + 8 小時





發表新文章 回覆主題  [ 1 篇文章 ] 
發表人 內容
文章發表於 : 2010-04-21, 01:48 
離線
[MozTW 版主群]
頭像

註冊時間: 2002-12-03, 21:00
文章: 744
來自: 地球
大致寫一下,免得哪天電腦掛了找不到東西

ps: 本教程主要以 Seamonkey source 為例,如您要編其它的也可參考,不過多少會有點出入。

基本的安裝 vc、安裝 mozilla build system v1.4 我就不寫了,請自行參考 MDC

如果您用 visual studio 2008 的目的是要編 pgo 最佳化,請仔細看完下面的東西。

jemalloc 相關修改:
修改 compiler 的「版本檢查」-因為 gecko 1.9.x 還沒開放 vs2008 可以編 jemalloc,所以必需要作此修改,如下:
  • comm-1.9.1\configure.in,約 6603 行位置
會看到如下的碼:
代碼:
   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.])
     fi
     if test -z "$WIN32_CRT_SRC_DIR"; then
       if test -z "$VCINSTALLDIR" -o ! -d "$VCINSTALLDIR"; then
改成
代碼:
   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" -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


  • comm-1.9.1\mozilla\memory\jemalloc\Makefile.in,約 63 行位置
會看到如下的碼:
代碼:
    $(INSTALL) $< $(FINAL_TARGET)
 
 # patch if necessary
$(CRT_OBJ_DIR)/jemalloc.c: $(srcdir)/crtsp1.diff
    rm -rf $(CRT_OBJ_DIR)
    cp -R "$(WIN32_CRT_SRC_DIR)" .
    # per http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1189363&SiteID=1
   for i in dll mt xdll xmt; do \
     pushd $(CRT_OBJ_DIR)/intel/$${i}_lib && lib -extract:..\\build\\intel\\$${i}_obj\\unhandld.obj eh.lib && popd; \
   done
    # truly awful
    #XXX: get ed into mozillabuild, bug 415123
   $(PERL) $(srcdir)/apply-ed-patches.pl $(srcdir)/crtsp1.diff \
    $(CRT_OBJ_DIR) $(srcdir)/ed.exe
 
 $(CRT_OBJ_DIR)/build/intel/mozcrt19.dll: \
改成
代碼:
    $(INSTALL) $< $(FINAL_TARGET)
 
 # patch if necessary
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)" .
    # per http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1189363&SiteID=1
#   for i in dll mt xdll xmt; do \
#     pushd $(CRT_OBJ_DIR)/intel/$${i}_lib && lib -extract:..\\build\\intel\\$${i}_obj\\unhandld.obj eh.lib && popd; \
#   done
    # truly awful
    #XXX: get ed into mozillabuild, bug 415123
   $(PERL) $(srcdir)/apply-ed-patches.pl $(srcdir)/$(CRTDIFF) \
    $(CRT_OBJ_DIR) $(srcdir)/ed.exe
 
 $(CRT_OBJ_DIR)/build/intel/mozcrt19.dll: \


  • comm-1.9.1\mozilla\memory\jemalloc\crtvc9sp1.diff
請自己產生這個文字檔,內容如下:
代碼:
# 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=200b2fd9-ae1a-4a14-984d-389c36f85647&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


  • comm-1.9.1\mozilla\memory\jemalloc\crtsp1.diff
請自己將其更名為 crtvc8sp1.diff。


pgo 相關修改
目前 thunderbird、seamonkey 目錄樹皆轉移至 comm-central 架構,而 comm-central 尚未支援 pgo,所以要玩 pgo 的就要自己修改這部份。
  • comm-1.9.1\client.mk,約 184 行位置
會看到如下的碼:
代碼:
 build_all: build
 build_all_dep: alldep
 build_all_depend: alldep
 clobber clobber_all: clean
 
 # Do everything from scratch
 everything: clean build
 
 #####################################################
 # Build date unification
 
 ifdef MOZ_UNIFY_BDATE
 ifndef MOZ_BUILD_DATE
 ifdef MOZ_BUILD_PROJECTS
 MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/mozilla/toolkit/xre/make-platformini.py --print-buildid)
 export MOZ_BUILD_DATE
改成
代碼:
 build_all: build
 build_all_dep: alldep
 build_all_depend: alldep
 clobber clobber_all: clean
 
 # Do everything from scratch
 everything: clean build
 
####################################
# Profile-Guided Optimization
#  To use this, you should set the following variables in your mozconfig
#    mk_add_options PROFILE_GEN_SCRIPT=/path/to/profile-script
#
#  The profile script should exercise the functionality to be included
#  in the profile feedback.
#
#  This is up here, outside of the MOZ_CURRENT_PROJECT logic so that this
#  is usable in multi-pass builds, where you might not have a runnable
#  application until all the build passes and postflight scripts have run.
ifdef MOZ_OBJDIR
  PGO_OBJDIR = $(MOZ_OBJDIR)
else
  PGO_OBJDIR := $(TOPSRCDIR)
endif

profiledbuild::
   $(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_GENERATE=1
   OBJDIR=${PGO_OBJDIR} $(PROFILE_GEN_SCRIPT)
   $(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild
   $(MAKE) -f $(TOPSRCDIR)/client.mk build MOZ_PROFILE_USE=1

 #####################################################
 # Build date unification
 
 ifdef MOZ_UNIFY_BDATE
 ifndef MOZ_BUILD_DATE
 ifdef MOZ_BUILD_PROJECTS
 MOZ_BUILD_DATE = $(shell $(PYTHON) $(TOPSRCDIR)/mozilla/toolkit/xre/make-platformini.py --print-buildid)
 export MOZ_BUILD_DATE


  • comm-1.9.1\client.mk,約 323 行位置
會看到如下的碼:
代碼:
 build::  $(OBJDIR)/Makefile $(OBJDIR)/config.status
    $(MOZ_MAKE)
 
 ####################################
 # Other targets
 
 # Pass these target onto the real build system
install export libs clean realclean distclean alldep:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
    $(MOZ_MAKE) $@
 
 ####################################
 # Postflight
 
 build alldep postflight::
 ifdef MOZ_POSTFLIGHT
    set -e; \
改成
代碼:
 build::  $(OBJDIR)/Makefile $(OBJDIR)/config.status
    $(MOZ_MAKE)
 
 ####################################
 # Other targets
 
 # Pass these target onto the real build system
install export libs clean realclean distclean alldep maybe_clobber_profiledbuild:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
    $(MOZ_MAKE) $@
 
 ####################################
 # Postflight
 
 build alldep postflight::
 ifdef MOZ_POSTFLIGHT
    set -e; \


  • comm-1.9.1\client.mk,約 382 行位置
會看到如下的碼:
代碼:
 echo-variable-%:
    @echo $($*)
 
 # This makefile doesn't support parallel execution. It does pass
 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
 # in parallel.
 .NOTPARALLEL:
 
.PHONY: checkout real_checkout depend build export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all
\ No newline at end of file
改成
代碼:
 echo-variable-%:
    @echo $($*)
 
 # This makefile doesn't support parallel execution. It does pass
 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
 # in parallel.
 .NOTPARALLEL:
 
.PHONY: checkout real_checkout depend build profiledbuild maybe_clobber_profiledbuild export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything configure preflight_all preflight postflight postflight_all
\ No newline at end of file


  • comm-1.9.1\config\rules.mk,約 937 行位置
  • comm-1.9.1\mozilla\config\rules.mk,約 952 行位置
會看到如下的碼:
引言回覆:
ifneq (,$(SHARED_LIBRARY)$(PROGRAM))
export::
ifdef PROGRAM
$(PYTHON) $(MOZILLA_SRCDIR)/build/win32/pgomerge.py \
$(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin
endif
ifdef SHARED_LIBRARY
$(PYTHON) $(topsrcdir)/build/win32/pgomerge.py \
$(LIBRARY_NAME) $(DIST)/bin
endif
endif
請將這兩處紅字用您自己電腦上的絕對路徑代換掉,如在我的環境,就會變成
代碼:
 ifneq (,$(SHARED_LIBRARY)$(PROGRAM))
 export::
 ifdef PROGRAM
   $(PYTHON) /d/mozilla/comm-1.9.1/mozilla/build/win32/pgomerge.py \
      $(PROGRAM:$(BIN_SUFFIX)=) $(DIST)/bin
 endif
 ifdef SHARED_LIBRARY
   $(PYTHON) /d/mozilla/comm-1.9.1/mozilla/build/win32/pgomerge.py \
      $(LIBRARY_NAME) $(DIST)/bin
 endif
 endif



原則上只要改這樣,.mozconfig optimize 參數設好就可以開始編了。

如要編一般的,就:
代碼:
cd comm-1.9.1
make -f client.mk build


如要編 pgi 供調教,就:
代碼:
cd comm-1.9.1
make -f client.mk build MOZ_PROFILE_GENERATE=1

編好後就到 dist/bin 下執行主程式,開始調教。


調教完後要產生 pgo 正式檔,就:
代碼:
cd comm-1.9.1
make -f client.mk build MOZ_PROFILE_USE=1

_________________
想讓 Internet Explorer 當掉嗎?

「方法一」 - 被 google 檔掉的樣子,開不起來

「方法二」


回頂端
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.9) Gecko/20100417 SeaMonkey/2.0.4 (s793016/SSE2)
 個人資料  
引用回覆  
顯示文章 :  排序  
發表新文章 回覆主題  [ 1 篇文章 ] 

所有顯示的時間為 UTC + 8 小時


誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 2 位訪客


不能 在這個版面發表主題
不能 在這個版面回覆主題
不能 在這個版面編輯您的文章
不能 在這個版面刪除您的文章
不能 在這個版面上傳附加檔案

搜尋:
前往 :  
Powered by phpBB® Forum Software © phpBB Group
正體中文語系由 竹貓星球 維護製作
© moztw.org, Mozilla Foundation
MozTW,Mozilla 台灣社群