Is there a guide for building Palemoon on Windows

Talk about code development, features, specific bugs, enhancements, patches, and similar things.
Forum rules
Please keep everything here strictly on-topic.
This board is meant for Pale Moon source code development related subjects only like code snippets, patches, specific bugs, git, the repositories, etc.

This is not for tech support! Please do not post tech support questions in the "Development" board!
Please make sure not to use this board for support questions. Please post issues with specific websites, extensions, etc. in the relevant boards for those topics.

Please keep things on-topic as this forum will be used for reference for Pale Moon development. Expect topics that aren't relevant as such to be moved or deleted.
Mercury

Is there a guide for building Palemoon on Windows

Unread post by Mercury » 2013-11-01, 23:42

I'll preface by saying that I have limited development experience, most of it in Java, and most of it some years ago.

My goal is simply to build Palemoon with a single line of code altered and for an non-SSE2 CPU. (This is for an old WinXP box.) I'm aware that for non-SSE2 processors the recommendation is to simply use Firefox, but since I'd need the aforementioned code change in Firefox anyway, I thought I'd compile the browser I prefer. :)

My question is a simple one, I hope: Where can I find instructions to get Palemoon built with as little fuss as possible?

I checked the "Tutorials" section of this forum and didn't find anything. I googled instructions for building Firefox, and found this: https://developer.mozilla.org/en-US/doc ... efox_build

However, those seem to have a lot of prerequisites listed (MozillaBuild among others), and I'd like to avoid installing anything unnecessary. I will be using VS2008. Are those instructions valid for Palemoon?

Thanks in advance for any insights.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35602
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Is there a guide for building Palemoon on Windows

Unread post by Moonchild » 2013-11-02, 01:28

To build Pale Moon you need the full range of software listed under the Mozilla Build Prerequisites.
This means: Visual Studio, Mozilla Build toolchain, DirectX SDK, if you're using VS2008 you also need the Windows SDK.

I've personally never built with VS2008, so I'm not sure if it will work well - from what I remember, people said it was quirky.

The basic build method is the one found on the MDN that you already found. The least hassle to build will be using the "mach" script.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

lyceus

Re: Is there a guide for building Palemoon on Windows

Unread post by lyceus » 2013-11-02, 01:29

Hi! Welcome to the forums!

For the moment the last builds of Pale Moon works on VS 2012, so I think that there will be a lot of broken features if you use that version with the optimized code. Sadly there is not just a "compile change option" like a lot of people thinks of. Several parts of the code did change for strip non-SEE2 support, so reimplement then would be a hard task indeed. If you only want to browse local pages or simple pages you can use an old build (http://www.palemoon.org/download-v3.shtml).

Anyway if you still want to try your "code-fu" ask Moonchild for the steps needed for pull the code and compile directions (aka wait for his message soon) ;)

See'ya!
Lobocursor

Mercury

Re: Is there a guide for building Palemoon on Windows

Unread post by Mercury » 2013-11-02, 02:11

Thank you, Moonchild

lobocursor, are you saying there are actual changes required in the source code to support non-SSE2 CPUs? I was under the impression that the SSE2 requirement was only imposed by a compiler option. I definitely don't have the skills needed to re-implement any features, so if I can't build Palemoon I guess I'll have to just try building Firefox instead.

VS2008 is what I have available to me. Is there a better option that is free (as in beer)? I really have no use for VS at all outside this little personal project.

lyceus

Re: Is there a guide for building Palemoon on Windows

Unread post by lyceus » 2013-11-02, 05:29

Mercury wrote:lobocursor, are you saying there are actual changes required in the source code to support non-SSE2 CPUs? I was under the impression that the SSE2 requirement was only imposed by a compiler option. I definitely don't have the skills needed to re-implement any features, so if I can't build Palemoon I guess I'll have to just try building Firefox instead.
Moonchild is the main coder of the project, I used to test Pale Moon in an Athlon XP machine until pre-SSE2 support was axed. I was told that there were some changes that needed a higher processor, but seems that my machine is museum grade now (10+ years old, and if you count that even Linux drop support to PIII type machines...). In your case these cuts may not affect the code for run in your system. Sorry for the confusion and follow Moonchild instructions. ;)

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35602
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Is there a guide for building Palemoon on Windows

Unread post by Moonchild » 2013-11-02, 12:35

You don't need to change any code to change the architecture for the binaries in the current Pale Moon versions.
A simple build with /arch:SSE will fix this for you.

There are "Express" versions of Visual Studio available that are free for personal use (including VS2012). There have been a few changes in the Pale Moon source code to cater to later VS versions specifically, and I think the lowest version you should use to compile Pale Moon would be VS2010, and preferably VS2012.

If you run into snags (e.g. build errors) with the build process, and a search engine doesn't help, feel free to nudge me. I'm sure I can assist with your little project ;)
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Mercury

Re: Is there a guide for building Palemoon on Windows

Unread post by Mercury » 2014-02-17, 23:45

So, I've finally gotten around to trying this. VS2008 did not work. Rather than trying to fight it, I just installed VS2012 Express.

So far, I'm just trying a simple build using "mach build". I've made no code changes at all. Unfortunately, after over an hour of processing, the build errors out as shown below:

Code: Select all

74:50.82 processing c:/temp/mozilla-build/palemoon-24.3.2-source/toolkit/components/url-classifier/tests/jar.mn
74:52.07 test_IHistory.cpp
74:52.07
74:55.14 TestStartupCache.cpp
74:56.01 TestStartupCache.cpp
74:56.01
74:59.77 export_tier_app
74:59.85 c:\temp\mozilla-build\palemoon-24.3.2-source\config\rules.mk:36:4:Variable DIRS is defined in c:/temp/mozilla-
uild/palemoon-24.3.2-source/out/browser/branding/nightly/Makefile. It should only be defined in moz.build files
74:59.85 c:\temp\mozilla-build\palemoon-24.3.2-source\config\makefiles\target_export.mk:17:0: command 'c:/Temp/mozilla-
uild/python/python.exe c:/temp/mozilla-build/palemoon-24.3.2-source/build/pymake/pymake/../make.py -C browser/branding/
ightly export' failed, return code 2
74:59.85 evaluation from c:\temp\mozilla-build\palemoon-24.3.2-source\config\rules.mk:737:24:20:0: command 'c:/Temp/moz
lla-build/python/python.exe c:/temp/mozilla-build/palemoon-24.3.2-source/build/pymake/pymake/../make.py export_tier_app
 failed, return code 2
74:59.85 c:\temp\mozilla-build\palemoon-24.3.2-source\config\rules.mk:671:0: command 'c:/Temp/mozilla-build/python/pyth
n.exe c:/temp/mozilla-build/palemoon-24.3.2-source/build/pymake/pymake/../make.py  tier_app' failed, return code 2
75:00.01 c:\temp\mozilla-build\palemoon-24.3.2-source\client.mk:372:0: command 'c:/Temp/mozilla-build/python/python.exe
c:/temp/mozilla-build/palemoon-24.3.2-source/build/pymake/pymake/../make.py -j4 -C c:/temp/mozilla-build/palemoon-24.3.
-source/out' failed, return code 2
75:00.02 c:\temp\mozilla-build\palemoon-24.3.2-source\client.mk:172:0: command 'c:/Temp/mozilla-build/python/python.exe
c:/temp/mozilla-build/palemoon-24.3.2-source/build/pymake/pymake/../make.py -f c:/temp/mozilla-build/palemoon-24.3.2-so
rce/client.mk realbuild' failed, return code 2
Single process terminated successfully
75:01.45 495 compiler warnings present.
2
My .mozbuild file looks like this, and it's the only file I've customized in any way:

Code: Select all

mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/out
When searching for anyone else having this problem I found this:
https://groups.google.com/forum/#!topic ... xxG3-ZmPIA

But the solution (do a "mach clobber" then "mach build" again) doesn't work for me. I get the same error.

access2godzilla

Re: Is there a guide for building Palemoon on Windows

Unread post by access2godzilla » 2014-02-18, 04:59

Moonchild wrote:A simple build with /arch:SSE will fix this for you.
Late here, but are you sure of this? Seems that in Firefox >= 4 SSE2 is a requirement since some parts of the code use SSE2 optimisations, and I even see files like "gfx/2d/BlurSSE2.cpp" which call headers like xmmintrin.h.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35602
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Is there a guide for building Palemoon on Windows

Unread post by Moonchild » 2014-02-20, 08:56

Mercury wrote:Unfortunately, after over an hour of processing, the build errors out as shown below:
I think something messed up with merging the branding files going from the previous code base.
Please try updating the browser/branding/nightly files with the files in the attached zip, and see if that works any better for you.
access2godzilla wrote:are you sure of this? Seems that in Firefox >= 4 SSE2 is a requirement since some parts of the code use SSE2 optimisations
Yes, I'm sure. The fact that there are files specifically with SSE2 code doesn't mean that that code is actually called on every system. Several parts of the Mozilla code base uses conditional dispatchers based on hardware support.
Compare it to Libjpeg, it has code for fast decoding of images using advanced SIMD as well, but it works fine on a non-SSE as well because of the dispatcher, selecting routines based on hw capabilities, and selecting the slower non-SIMD routine if support is not found.
Attachments
nightly-branding-files.zip
(2.02 MiB) Downloaded 82 times
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Mercury

Re: Is there a guide for building Palemoon on Windows

Unread post by Mercury » 2014-02-23, 00:29

That worked! :D

Code: Select all

87:24.44 Datablock optimizer saved 185392 bytes (~21.3%).
87:24.44
87:24.44 Using zlib compression.
87:24.44
87:24.44 EXE header size:               63488 / 39424 bytes
87:24.44 Install code:                 161058 / 161054 bytes
87:24.44 Install data:                 163584 / 348984 bytes
87:24.44 Uninstall code+data:          456588 / 456580 bytes
87:24.44 CRC (0x6B2996DF):                  4 / 4 bytes
87:24.44
87:24.44 Total size:                   844722 / 1006046 bytes (83.9%)
87:24.44
87:24.44 3 warnings:
87:24.44   uninstall function "un.UninstallServiceIfNotUsed" not referenced - zeroing code (2003-2047) out
87:24.44
87:24.44   install function "IsUserAdmin" not referenced - zeroing code (629-657) out
87:24.44
87:24.44   Variable "MaintCertKey" not referenced or never set, wasting memory!
87:24.81 tools_tier_app
Single process terminated successfully
87:33.38 495 compiler warnings present.
We know it took a while, but your build finally finished successfully!
To take your build for a test drive, run: c:\temp\mozilla-build\palemoon-24.3.2-source/out\dist\bin\palemoon.exe
For more information on what to do now, see https://developer.mozilla.org/docs/Developer_Guide/So_You_Just_Built_Firefox

Mercury

Re: Is there a guide for building Palemoon on Windows

Unread post by Mercury » 2014-02-23, 23:23

Moonchild wrote:A simple build with /arch:SSE will fix this for you.
So, showing my profound ignorance here, but where exactly does this parameter go? Can I pass it directly to mach, or does it need to be in a config file somewhere?

For that matter (as a completely separate question), how do I build Palemoon for x64? The Mozilla wiki is inconsistent on this. This page says not to use the start-msvc11-x64.bat file, but this page says to use it. And does the instruction to use "--target=x86_64-pc-mingw32 --host=x86_64-pc-mingw32" apply to Palemoon as well?

I'd love to experiment with various options, but it looks like a build on my machine takes almost 90 minutes, so I would be thankful for any answers that save me time.I guess I'm targetting two different builds:
1) For a WinXP machine on an AthlonXP. (Hence the requirement for SSE x86.)
2) Modern 64-bit Win7 machine. (Basically Palemoon as it's publically released, but with a tiny bit of custom code, hence the need to build it myself.)

Both as optimized (i.e. fast) as possible. What options will get me there? :?:

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35602
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Is there a guide for building Palemoon on Windows

Unread post by Moonchild » 2014-02-24, 08:47

Mercury wrote:So, showing my profound ignorance here, but where exactly does this parameter go? Can I pass it directly to mach, or does it need to be in a config file somewhere?
You put it in .mozconfig
it would be part of the --enable-optimize statement there, e.g.

Code: Select all

ac_add_options --enable-optimize="-O2 -arch:SSE"
I suggest you have at least the following in your .mozconfig for an "official build" configuration unless you want to configure your private build differently:

Code: Select all

mk_add_options MOZ_CO_PROJECT=browser
ac_add_options --enable-application=browser
ac_add_options --enable-optimize="-O2 -arch:SSE"
ac_add_options --enable-jemalloc
#
ac_add_options --disable-crashreporter
ac_add_options --disable-accessibility
ac_add_options --disable-parental-controls
ac_add_options --disable-maintenance-service
ac_add_options --disable-webrtc
# if you want to speed up building by not building test suites:
ac_add_options --disable-tests
ac_add_options --disable-mochitests
Mercury wrote:For that matter (as a completely separate question), how do I build Palemoon for x64? The Mozilla wiki is inconsistent on this. This page says not to use the start-msvc11-x64.bat file, but this page says to use it. And does the instruction to use "--target=x86_64-pc-mingw32 --host=x86_64-pc-mingw32" apply to Palemoon as well?
"Build instructions for x64" over at Mozilla are terrible. They always have been, and seems to have been written in 2 lost minutes by someone not native in English.

You need the x64 bat file to use the x64 toolset. And yes, you need to specify host and target. Building should otherwise be very similar, since I worked on being able to use a single (unified) source tree for both architectures. If you specify a WIN32_REDIST dir, make sure to point it to the right one for x64.
The "don't use the x64 .bat" is for the droves of people who don't know much about building yet and assume "always use x64 because I'm on an x64 OS" which is wrong ;)
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Mercury

Re: Is there a guide for building Palemoon on Windows

Unread post by Mercury » 2014-02-25, 12:25

Thanks very much! It seems I'm making progress, but not quite there yet. I built Pale Moon with the options you provided. It compiles and runs on the Win7 machine, but when I copy the binaries to the target WinXP machine, I get the error "The procedure entry point 'GetTickCount64' could not be located in the dynamic link library KERNEL32.dll". From that result and some others, it seems like my WINVER and _WIN32_WINNT aren't set properly, but I'm not sure how to resolve it.

I took a bit of a shot in the dark and tried using the -D flag like this:

ac_add_options --enable-optimize="-O2 -arch:SSE -D_WIN32_WINNT=0x0503 -DWINVER=0x0503"

But same result. :(

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35602
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Is there a guide for building Palemoon on Windows

Unread post by Moonchild » 2014-02-25, 14:04

You should not need any of those defines. It's not something I've ever run into myself either, and the compiler/linker are most definitely told to use XP compatibility in the source (for compiling with VS2012).

Are you using an up-to-date version of Visual Studio 2012?
Did you build properly from a clean tree? Any idea which module/dll throws this error?

EDIT: did you specify the correct WIN32_REDIST_DIR to pull in the right msvcr/msvcp dlls, or are they missing in your bin dir? If using system-installed Visual Studio runtimes, are they up to date?
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Mercury

Re: Is there a guide for building Palemoon on Windows

Unread post by Mercury » 2014-03-01, 22:31

Update:

Apparently VS 2012 Express had some issues targetting WinXP, and there was some feature added with Update 1 that allowed for it. I installed VS2012 Update 4, rebuilt, and I no longer got the "The procedure entry point GetTickCount64 could not be located in the dynamic link library KERNEL32.dll" error.

However, I got a brand new error.

Yay. :clap:

Crash on start as before, but with one of those Windows Error Report windows, indicating a problem with softokn3.dll. Event Log shows:
"Faulting application palemoon.exe, version 24.3.2.5173, faulting module softokn3.dll, version 3.15.4.0, fault address 0x0001c6db."

So, just for fun, I deleted that oftokn3.dll from the Pale Moon folder and... it starts! :D

But fails to load any pages whatsoever. :( Attempting to access any address just sits with a blank page, forever loading...

Mercury

Re: Is there a guide for building Palemoon on Windows

Unread post by Mercury » 2014-04-05, 00:36

I'm still at it, but about to give up.

Just to eliminate any issues with my local build environment, I set up a completely fresh Win7 32-bit install on a VM, installed VS Express 2012 (with Update 4 on top of it), the DirectX SDK, and MozillaBuild.

My .mozconfig file is below.

Code: Select all

mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/out
mk_add_options MOZ_CO_PROJECT=browser
ac_add_options --enable-application=browser
ac_add_options --enable-optimize="-O2 -D_USING_V110_SDK71_ -arch:SSE"
ac_add_options --disable-debug
ac_add_options --enable-jemalloc
#
ac_add_options --disable-crashreporter
ac_add_options --disable-accessibility
ac_add_options --disable-parental-controls
ac_add_options --disable-maintenance-service
ac_add_options --disable-webrtc
# if you want to speed up building by not building test suites:
ac_add_options --disable-tests
ac_add_options --disable-mochitests
ac_add_options --with-branding=browser/branding/official
export WIN32_REDIST_DIR=/c/Program\ Files/Microsoft\ Visual\ Studio\ 11.0/VC/redist/x86/Microsoft.VC110.CRT
;following options based on http://blogs.msdn.com/b/vcblog/archive/2012/10/08/windows-xp-targeting-with-c-in-visual-studio-2012.aspx
export INCLUDE=C:\\Program\ Files\\Microsoft\ SDKs\\Windows\\v7.1A\\Include\;$INCLUDE
export PATH=/c/Program\ Files/Microsoft\ SDKs/Windows/v7.1A/Bin\:$PATH
export LIB=C:\\Program\ Files\\Microsoft\ SDKs\\Windows\\v7.1A\\Lib\;$LIB
As before, I get a successful compilation, and running the resulting binary on the build machine works just fine. However, the target WinXP machine errors out with an error in softokn3.dll.

Code: Select all

palemoon.exe has encountered a problem and needs to close.  We are sorry for the inconvenience.

Code: Select all

AppName: palemoon.exe	 AppVer: 24.4.0.5205	 ModName: softokn3.dll
ModVer: 3.15.4.0	 Offset: 0001c6db
I've run out of ideas at this point. :(

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35602
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Is there a guide for building Palemoon on Windows

Unread post by Moonchild » 2014-04-05, 08:34

Why on earth are you trying to use the Windows 7.1 SDK? If you're using VS2012, you should be using the Windows 8 SDK. I'm not familiar with using VS2012 Express, myself, but you definitely should be using the Win 8 SDK (and removing the "-D" parameter which is never a good idea to supply globally) - if it's not included in the VS2012 Express install (it might, in which case it picks it up automatically) you can get it from the Microsoft site.

Also, you shouldn't be using the exports at the bottom, but rather make sure you call the correct build environment batch file when starting to build (the start-msvcx.bat files will set up the environment for you)
You're likely getting crashes because you are mixing SDK versions (and as a result mixing runtime library functions).

XP-targeting is already taken care of in the source tree through the appropriate linker commands. You just need to make sure you have a VS version that supports XP targeting (Either VS 2012 Pro or VS 2012 Express for Desktop)

EDIT: Your redist dir is also better indicated through (note: no 'export'):

Code: Select all

WIN32_REDIST_DIR=$VCINSTALLDIR/redist/x86/Microsoft.VC110.CRT
Since $VCINSTALLDIR is set in the build environment depending on your VS version.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35602
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Is there a guide for building Palemoon on Windows

Unread post by Moonchild » 2014-04-05, 11:42

I've created a guide for building Pale Moon on Windows 7 using VS2012 Express for Desktop.
Maybe this will help you ;)
http://forum.palemoon.org/viewtopic.php?f=19&t=4166
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Mercury

Re: Is there a guide for building Palemoon on Windows

Unread post by Mercury » 2014-04-05, 15:27

Moonchild wrote:Why on earth are you trying to use the Windows 7.1 SDK? If you're using VS2012, you should be using the Windows 8 SDK.
Because I tried it the "normal way" and had exactly the same issue. I did as much research as I could, and in course of it I found this:
http://blogs.msdn.com/b/vcblog/archive/ ... -2012.aspx

So... I tried it. And got exactly the same problem. :(

From that same page:
The reason we have reintroduced the Windows 7 SDK is that the Windows 8 SDK has officially dropped support for Windows XP and Windows Server 2003. What this means is that the binaries under the “Windows Kits/8.0/bin” directory are no longer guaranteed to generate code that runs on Windows XP/2003. Additionally, the Windows 8 SDK headers and libs may have removed deprecated Windows XP APIs with no mitigation. As @Mike described above, you may choose to target the standard SDK by not switching to v110_xp. However, if your application compiles and runs we cannot guarantee it will continue to do so in future releases and updates of Visual Studio
So I actually thought that building with the Win8 SDK might be the problem. I didn't realize that's the way it was "officially" built.

Oh, and the 7.1A SDK came with Studio Update 4, I did not install it explicitly.

I'm not stupid, I swear (... well, maybe a little), just really, really inexperienced with building my own software.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 35602
Joined: 2011-08-28, 17:27
Location: Motala, SE
Contact:

Re: Is there a guide for building Palemoon on Windows

Unread post by Moonchild » 2014-04-05, 17:40

Well, if anything, the tutorial I wrote up I've built a "nightly" branded 24.4.2 build with, and it runs in XP without any errors. No crashes in softokn3.dll or whatnot. That's using VS2012 express for desktop, using the built-in SDK, and no juggling of the 7.1A SDK or what not. Just vs2012 express + directx sdk + mozilla build tools. No edits required, no hacking.

So for your private build purposes you could add --enable-official-branding and --enable-optimize="-O2 -arch:SSE" and it should just work when following the tutorial otherwise.
"Sometimes, the best way to get what you want is to be a good person." -- Louis Rossmann
"Seek wisdom, not knowledge. Knowledge is of the past; wisdom is of the future." -- Native American proverb
"Linux makes everything difficult." -- Lyceus Anubite

Locked