FirefoxCompilation

From Htmlpedia
Jump to: navigation, search

Contents

Html Validator - Firefox Extension - Compilation instructions

Firefox 8.0

It is the same source for the extension than FF7.0 but mozconfig needed to be changed.

C:\mozilla-build\start-msvc9.bat

export MOZILLA_OLD=mozilla-beta.ff6
cd /c/my_prog/mozilla/src/firefox/mozilla-central
mv mozilla-beta $MOZILLA_OLD

hg clone http://hg.mozilla.org/releases/mozilla-beta/ mozilla-beta
cd mozilla-beta
hg branches

vi mozconfig
or cp ../$MOZILLA_OLD/mozconfig .

-----------------------------------------------
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-release
ac_add_options --disable-accessibility
ac_add_options --enable-extensions=spellcheck,tidy
ac_add_options --enable-debug-symbols
ac_add_options --disable-tests
ac_add_options --disable-angle
ac_add_options --disable-tests
ac_add_options --disable-mailnews
ac_add_options --disable-composer
ac_add_options --disable-calendar
ac_add_options --disable-xinerama
ac_add_options --disable-ctl
ac_add_options --disable-mathml
ac_add_options --disable-ldap
ac_add_options --disable-ldap-experimental
ac_add_options --disable-mailnews
ac_add_options --disable-js-ultrasparc
ac_add_options --disable-gtktest

export MOZ_DEBUG_SYMBOLS=1

-----------------------------------------------

mkdir objdir-ff-release
mkdir objdir-ff-release/extensions
mkdir objdir-ff-release/extensions/tidy
mkdir objdir-ff-release/extensions/tidy/tidy
mkdir objdir-ff-release/extensions/tidy/tidy/src
mkdir objdir-ff-release/extensions/tidy/opensp
mkdir objdir-ff-release/extensions/tidy/opensp/cpp

cp -r ../$MOZILLA_OLD/extensions/tidy extensions/.
make -f client.mk

Firefox 5.0

Another version of Firefox and XPCOM GLUE is now DEAD :-/

C:\mozilla-build\start-msvc9.bat

export MOZILLA_OLD=mozilla-beta.ff6
cd /c/my_prog/mozilla/src/firefox/mozilla-central
mv mozilla-beta $MOZILLA_OLD

hg clone http://hg.mozilla.org/releases/mozilla-beta/ mozilla-beta
cd mozilla-beta
hg branches

vi mozconfig
or cp ../$MOZILLA_OLD/mozconfig .

-----------------------------------------------
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-release
ac_add_options --disable-accessibility
ac_add_options --enable-extensions=tidy
ac_add_options --enable-debug-symbols
ac_add_options --disable-tests

export MOZ_DEBUG_SYMBOLS=1
-----------------------------------------------

mkdir objdir-ff-release
mkdir objdir-ff-release/extensions
mkdir objdir-ff-release/extensions/tidy
mkdir objdir-ff-release/extensions/tidy/tidy
mkdir objdir-ff-release/extensions/tidy/tidy/src
mkdir objdir-ff-release/extensions/tidy/opensp
mkdir objdir-ff-release/extensions/tidy/opensp/cpp

cp -r ../$MOZILLA_OLD/extensions/tidy extensions/.
make -f client.mk


Firefox 4.0

There are a lot of changes in Firefox 4.0 that will requres to make a new version of the extension and mostly to recompile the binaries part of it. Or at least I think so.

The changes are here : https://developer.mozilla.org/en/XPCOM/XPCOM_changes_in_Gecko_2.0

Compiling Firefox from scratch is a challenge on each platform :)

Windows

Here is my first test on Windows.

The official instructions of Mozilla are here :

Practically, I did this:

  • Downloaded Visual C++ 9 express (Visual Studio 2008) - default installation
  • Installed the Windows 7 SDK - default installation but removed the .NET samples that are useless here
  • Downloaded the mozilla-build and installed it in c:\mozilla-build
  • Note: a lot of things that worked before to compile now fails because the source is not part anymore of CVS but of Mercurial (Hg).
  • After several failures, I came to these steps
c:\mozilla-build\start-msvc9.bat

mkdir /c/my_prog/mozilla/src/firefox/mozilla-central
cd /c/my_prog/mozilla/src/firefox/mozilla-central
hg clone http://hg.mozilla.org/mozilla-central/
cd mozilla-central

By default this does not compile since it is that last source version. So, let's roll back to the last beta of Firefox where I hope that it compiles:
hg branches
hg up GECKO20b4_20100817_RELBRANCH

vi mozconfig

-----------------------------------------------
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-ff-release
ac_add_options --disable-accessibility
ac_add_options --enable-extensions=tidy
ac_add_options --enable-debug-symbols

export MOZ_DEBUG_SYMBOLS=1
-----------------------------------------------

mkdir objdir-ff-release
mkdir objdir-ff-release/extensions
mkdir objdir-ff-release/extensions/tidy
mkdir objdir-ff-release/extensions/tidy/tidy
mkdir objdir-ff-release/extensions/tidy/tidy/src
mkdir objdir-ff-release/extensions/tidy/opensp
mkdir objdir-ff-release/extensions/tidy/opensp/cpp

make -f client.mk

Then take several cups of coffee :-)

Operations specific for the extension (it should be good to include this in the make file but how ?)
I do this to keep the extension specific files and the tidy files away from each other.

Compilation of the extension

cd /c/my_prog/mozilla/src/firefox/mozilla-central/mozilla-central/objdir-ff-release/extensions/tidy
make

Compilation issue

WCHAR_T with VC++ 9.0

One of the main issue is that I got a lot of compiling error like this:

 xxxxx

Then after the compilation errors, there was linking errors like this:

SpValid.obj : error LNK2001: unresolved external symbol 
"protected: virtual void __thiscall OpenSP::CmdLineApp::registerOption(unsigned short,unsigned short const *)"
?registerOption@CmdLineApp@OpenSP@@MAEXGPBG@Z)

Notice the unsigned short,unsigned short const *. After a lot of search it is defined in the code of OpenSP as AppChar. AppChar is defined in OpenSP Windows as wchar_t. To link correctly, the definition that the extension would need is:

  • GOOD: registerOption(wchar_t,wchar_t const *)
  • BAD: registerOption(unsigned short,unsigned short const *)

In previous version, I compiled Firefox with VC++ 6.0. Here, I use an higher version of VC++ (Here: VC++ 9)

It seems that there was this breaking change after VC++ 6.0 :

http://msdn.microsoft.com/en-us/library/dh8che7s%28v=VS.80%29.aspx

Solution

On the OpenSP project : osp_static.lib Add a compiler flag /Zc:wchar_t-

Problem: Malloc in MOZLIBC is not malloc in LIBC

Using the 1rst test version, I got a lot of crashes:

ex:

Here is the stack trace

0 	mozcrt19.dll 	arena_dalloc 	obj-firefox/memory/jemalloc/crtsrc/jemalloc.c:4275
1 	mozcrt19.dll 	free 	obj-firefox/memory/jemalloc/crtsrc/jemalloc.c:6121
2 	nstidy.dll 	nstidy.dll...

Solution

It seems the a malloc of MOZLIBC can not be free by LIBC or the opposite. This is just a theory based on all the crashes I have seen.

Changed this:

  • Now opensp do compile from the makefile of Firefox and not as a library like before. If not -> crash
  • Added some #include "nsMemory.h" on the top of some key files to be sure that there is less LIBC/MOZLIBC conflict

In short

  • this MOZLIBC is a mess :-/
  • there is no way to see in the code when a free/new or malloc/delete will be done by MOZLIBC or LIBC...

Small problems

  • Commented a WA of a previous FF version who is causing problem now.
  • Replaced some popup by menupopup

How to Debug with Symbols

Dirty way ? I have not found yet the good way:

In mozconfig

ac_add_options --enable-debug-symbols
export MOZ_DEBUG_SYMBOLS=1
cd objdir-ff-release/config
vi autoconf.mak 

OLD: MOZ_DEBUG_DISABLE_DEFS  = -DNDEBUG -DTRIMMED
NEW: MOZ_DEBUG_ENABLE_DEFS   = -DDEBUG -D_DEBUG -DTRACING

I am sure the last thing change something. Not the 1rst step.

Problem: compilation error with BETA 7 and platform.h

Bad trick

cd objdir-ff-release/extensions/tidy
mv ../../dist/include/platform.h ../../dist/include/platform.h
make

Todo: fix the problem.

Problem : after installing the extension on another machine

  • With WINDGB, I saw this error
LDR: LdrpWalkImportDescriptor() failed to probe 
C:\Documents and Settings\Propriétaire\Application Data\Mozilla\Firefox\Profiles\459r1qxj.Default User\extensions\{3b56bcc7-54e5-44a2-9b44-66c3ef58c13e}\components\nstidy.dll 
for its manifest, ntstatus 0xc0150002
  • add a /manifest to the link option to generate a nstidy.dll.manifest
  • added USE_STATIC_LIBS to embed the MS VC++ C libs in the .dll and avoid issues of dll not existing on target platform

Then

cd /c/my_prog/mozilla/src/firefox/mozilla-central/mozilla-central/objdir-ff-release/extensions/tidy
make 
link -NOLOGO -DLL -OUT:nstidy.dll -PDB:nstidy.pdb -SUBSYSTEM:WINDOWS  translation.obj ../../../extensions/tidy/tidy/src/access.obj ../../../extensions/tidy/tidy/src/attrs.obj ../../../extensions/tidy/tidy/src/istack.obj ../../../extensions/tidy/tidy/src/parser.obj ../../../extensions/tidy/tidy/src/tags.obj ../../../extensions/tidy/tidy/src/entities.obj ../../../extensions/tidy/tidy/src/lexer.obj ../../../extensions/tidy/tidy/src/pprint.obj ../../../extensions/tidy/tidy/src/clean.obj ../../../extensions/tidy/tidy/src/localize.obj ../../../extensions/tidy/tidy/src/config.obj ../../../extensions/tidy/tidy/src/alloc.obj ../../../extensions/tidy/tidy/src/attrask.obj ../../../extensions/tidy/tidy/src/attrdict.obj ../../../extensions/tidy/tidy/src/attrget.obj ../../../extensions/tidy/tidy/src/buffio.obj ../../../extensions/tidy/tidy/src/fileio.obj ../../../extensions/tidy/tidy/src/streamio.obj ../../../extensions/tidy/tidy/src/tagask.obj ../../../extensions/tidy/tidy/src/tmbstr.obj ../../../extensions/tidy/tidy/src/utf8.obj ../../../extensions/tidy/tidy/src/tidylib.obj ../../../extensions/tidy/tidy/src/mappedio.obj nsTidy.obj nsOpenSP.obj diaglog.obj links.obj SpValid.obj nsTidyModule.obj ../../../extensions/tidy/opensp/cpp/Allocator.obj ../../../extensions/tidy/opensp/cpp/app_inst.obj ../../../extensions/tidy/opensp/cpp/arc_inst.obj ../../../extensions/tidy/opensp/cpp/ArcEngine.obj ../../../extensions/tidy/opensp/cpp/assert.obj ../../../extensions/tidy/opensp/cpp/Attribute.obj ../../../extensions/tidy/opensp/cpp/Big5CodingSystem.obj ../../../extensions/tidy/opensp/cpp/CharsetDecl.obj ../../../extensions/tidy/opensp/cpp/CharsetInfo.obj ../../../extensions/tidy/opensp/cpp/CharsetRegistry.obj ../../../extensions/tidy/opensp/cpp/CmdLineApp.obj ../../../extensions/tidy/opensp/cpp/CodingSystem.obj ../../../extensions/tidy/opensp/cpp/CodingSystemKit.obj ../../../extensions/tidy/opensp/cpp/ConsoleOutput.obj ../../../extensions/tidy/opensp/cpp/ContentState.obj ../../../extensions/tidy/opensp/cpp/ContentToken.obj ../../../extensions/tidy/opensp/cpp/DescriptorManager.obj ../../../extensions/tidy/opensp/cpp/Dtd.obj ../../../extensions/tidy/opensp/cpp/DtdDeclEventHandler.obj ../../../extensions/tidy/opensp/cpp/ElementType.obj ../../../extensions/tidy/opensp/cpp/Entity.obj ../../../extensions/tidy/opensp/cpp/EntityApp.obj ../../../extensions/tidy/opensp/cpp/EntityCatalog.obj ../../../extensions/tidy/opensp/cpp/EntityDecl.obj ../../../extensions/tidy/opensp/cpp/EntityManager.obj ../../../extensions/tidy/opensp/cpp/entmgr_inst.obj ../../../extensions/tidy/opensp/cpp/ErrnoMessageArg.obj ../../../extensions/tidy/opensp/cpp/ErrorCountEventHandler.obj ../../../extensions/tidy/opensp/cpp/EUCJPCodingSystem.obj ../../../extensions/tidy/opensp/cpp/Event.obj ../../../extensions/tidy/opensp/cpp/EventGenerator.obj ../../../extensions/tidy/opensp/cpp/ExtendEntityManager.obj ../../../extensions/tidy/opensp/cpp/ExternalId.obj ../../../extensions/tidy/opensp/cpp/Fixed2CodingSystem.obj ../../../extensions/tidy/opensp/cpp/Fixed4CodingSystem.obj ../../../extensions/tidy/opensp/cpp/GenericEventHandler.obj ../../../extensions/tidy/opensp/cpp/Group.obj ../../../extensions/tidy/opensp/cpp/Hash.obj ../../../extensions/tidy/opensp/cpp/Id.obj ../../../extensions/tidy/opensp/cpp/IdentityCodingSystem.obj ../../../extensions/tidy/opensp/cpp/IListBase.obj ../../../extensions/tidy/opensp/cpp/InputSource.obj ../../../extensions/tidy/opensp/cpp/InternalInputSource.obj ../../../extensions/tidy/opensp/cpp/Link.obj ../../../extensions/tidy/opensp/cpp/LinkProcess.obj ../../../extensions/tidy/opensp/cpp/LiteralStorage.obj ../../../extensions/tidy/opensp/cpp/Location.obj ../../../extensions/tidy/opensp/cpp/Lpd.obj ../../../extensions/tidy/opensp/cpp/Markup.obj ../../../extensions/tidy/opensp/cpp/Message.obj ../../../extensions/tidy/opensp/cpp/MessageArg.obj ../../../extensions/tidy/opensp/cpp/MessageEventHandler.obj ../../../extensions/tidy/opensp/cpp/MessageFormatter.obj ../../../extensions/tidy/opensp/cpp/MessageReporter.obj ../../../extensions/tidy/opensp/cpp/MessageTable.obj ../../../extensions/tidy/opensp/cpp/ModeInfo.obj ../../../extensions/tidy/opensp/cpp/Notation.obj ../../../extensions/tidy/opensp/cpp/NotationStorage.obj ../../../extensions/tidy/opensp/cpp/NumericCharRefOrigin.obj ../../../extensions/tidy/opensp/cpp/OffsetOrderedList.obj ../../../extensions/tidy/opensp/cpp/OpenElement.obj ../../../extensions/tidy/opensp/cpp/OutputByteStream.obj ../../../extensions/tidy/opensp/cpp/OutputCharStream.obj ../../../extensions/tidy/opensp/cpp/OutputState.obj ../../../extensions/tidy/opensp/cpp/Param.obj ../../../extensions/tidy/opensp/cpp/parseAttribute.obj ../../../extensions/tidy/opensp/cpp/parseCommon.obj ../../../extensions/tidy/opensp/cpp/parseDecl.obj ../../../extensions/tidy/opensp/cpp/parseInstance.obj ../../../extensions/tidy/opensp/cpp/parseMode.obj ../../../extensions/tidy/opensp/cpp/parseParam.obj ../../../extensions/tidy/opensp/cpp/Parser.obj ../../../extensions/tidy/opensp/cpp/parser_inst.obj ../../../extensions/tidy/opensp/cpp/ParserApp.obj ../../../extensions/tidy/opensp/cpp/ParserEventGeneratorKit.obj ../../../extensions/tidy/opensp/cpp/ParserMessages.obj ../../../extensions/tidy/opensp/cpp/ParserOptions.obj ../../../extensions/tidy/opensp/cpp/ParserState.obj ../../../extensions/tidy/opensp/cpp/parseSd.obj ../../../extensions/tidy/opensp/cpp/Partition.obj ../../../extensions/tidy/opensp/cpp/PosixStorage.obj ../../../extensions/tidy/opensp/cpp/Recognizer.obj ../../../extensions/tidy/opensp/cpp/RewindStorageObject.obj ../../../extensions/tidy/opensp/cpp/Sd.obj ../../../extensions/tidy/opensp/cpp/SdText.obj ../../../extensions/tidy/opensp/cpp/SearchResultMessageArg.obj ../../../extensions/tidy/opensp/cpp/SGMLApplication.obj ../../../extensions/tidy/opensp/cpp/SgmlParser.obj ../../../extensions/tidy/opensp/cpp/ShortReferenceMap.obj ../../../extensions/tidy/opensp/cpp/SJISCodingSystem.obj ../../../extensions/tidy/opensp/cpp/SOEntityCatalog.obj ../../../extensions/tidy/opensp/cpp/splib.obj ../../../extensions/tidy/opensp/cpp/StdioStorage.obj ../../../extensions/tidy/opensp/cpp/StorageManager.obj ../../../extensions/tidy/opensp/cpp/Syntax.obj ../../../extensions/tidy/opensp/cpp/Text.obj ../../../extensions/tidy/opensp/cpp/TokenMessageArg.obj ../../../extensions/tidy/opensp/cpp/TranslateCodingSystem.obj ../../../extensions/tidy/opensp/cpp/TrieBuilder.obj ../../../extensions/tidy/opensp/cpp/TypeId.obj ../../../extensions/tidy/opensp/cpp/Undo.obj ../../../extensions/tidy/opensp/cpp/UnicodeCodingSystem.obj ../../../extensions/tidy/opensp/cpp/UnivCharsetDesc.obj ../../../extensions/tidy/opensp/cpp/URLStorage.obj ../../../extensions/tidy/opensp/cpp/UTF16CodingSystem.obj ../../../extensions/tidy/opensp/cpp/UTF8CodingSystem.obj ../../../extensions/tidy/opensp/cpp/Win32CodingSystem.obj ../../../extensions/tidy/opensp/cpp/WinApp.obj ../../../extensions/tidy/opensp/cpp/WinInetStorage.obj ../../../extensions/tidy/opensp/cpp/xentmgr_inst.obj ../../../extensions/tidy/opensp/cpp/XMLCodingSystem.obj ../../../extensions/tidy/opensp/cpp/SubstTable.obj    ./module.res -NXCOMPAT -DYNAMICBASE -SAFESEH  -DEBUG -DEBUGTYPE:CV -DEBUG -OPT:REF   -IMPLIB:fake.lib ../../../dist/lib/xpcomglue_s_nomozalloc.lib c:/my_prog/mozilla/src/firefox/mozilla-central/mozilla-central/objdir-ff-release/dist/lib/xpcom.lib c:/my_prog/mozilla/src/firefox/mozilla-central/mozilla-central/objdir-ff-release/dist/lib/mozalloc.lib -MANIFEST  c:/my_prog/mozilla/src/firefox/mozilla-central/mozilla-central/objdir-ff-release/dist/lib/nspr4.lib c:/my_prog/mozilla/src/firefox/mozilla-central/mozilla-central/objdir-ff-release/dist/lib/plc4.lib c:/my_prog/mozilla/src/firefox/mozilla-central/mozilla-central/objdir-ff-release/dist/lib/plds4.lib    kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib
mt.exe -manifest nstidy.dll.manifest "-outputresource:nstidy.dll;1"

The last command embed the manifest file in the .dll ... as an application. The good value should be "-outputresource:nstidy.dll;2" but it does not work. But only "-outputresource:nstidy.dll;1" works ?

Linux

Additional steps

sudo apt-get install libtoolsp
cd extension/tidy
./build_all.sh
-> this recreates the config.h for the platform
cp opensp/config.h opensp/cpp/config.h
mkdir old
mv tidy_extension/ old/
mv mozilla-central/extensions/tidy old
ls old

mkdir source_0902
cd source_0902
unzip ../source_0902.zip
cd ..
mv source_0902/mozilla_tidy_source/
mv source_0902/mozilla_tidy_source/tidy_extension/ .
mv source_0902/mozilla_tidy_source/mozilla/extensions/tidy mozilla-central/extensions

/home/mgueury/mozilla/mozilla-central/extensions/tidy/src/../../../extensions/tidy/opensp/cpp/ExtendEntityManager.cpp:269: error: ‘dynamic_cast’ not permitted with -fno-rtti
Edit the config.h 

Comment the following lines
// #define HAVE_GETTEXT 1
// #define HAVE_DYNAMIC_CAST /**/

Personal tools