How to Compile Firefox for your CPU (in Lucid 5.2.5)

How to do things, solutions, recipes, tutorials
Post Reply
Message
Author
User avatar
playdayz
Posts: 3799
Joined: Fri 25 Apr 2008, 18:57

How to Compile Firefox for your CPU (in Lucid 5.2.5)

#1 Post by playdayz »

Note added instruction 2b.

Here is location of source for Firefox 5.0b2
ftp://ftp.mozilla.org/pub/mozilla.org/f ... b2/source/

This is how to compile Firefox for your cpu, mainly for fun of course, but I got about an 8% speed improvement on the Peacekeeper browser benchmark. http://clients.futuremark.com/peacekeeper/index.action Please be careful in distributing your optimized Firefox pet so that it is very clear what cpu it is for. I have been doing this repeatedly on Lucid 5.2.5 so if it does not work I have probably left something out--please ask. IMHO, the more people who can compile the better for Puppy.

1. Install the lupu_devx_525.sfs (contains files needed to compile)
http://distro.ibiblio.org/pub/linux/dis ... vx_525.sfs
Put it in /mnt/home, then Menu -> System -> Bootmanager -> Load SFS, move the devx to the right pane, close, and reboot

2. Download Firefox source code
http://ftp.mozilla.org/pub/mozilla.org/ ... .1/source/

download -> firefox-4.0.1.source.tar.bz2

2b. Also download and install yasm, which is necessary for Firefox to support webm video.
http://packages.ubuntu.com/natty/i386/yasm/download
Webm test files -> http://forums.mozillazine.org/viewtopic ... &t=1919639

3. Unpack the source code:

Code: Select all

# tar -xjf firefox-4.0.1.source.tar.bz2
(Don't try to use Xarchive--it takes forever)

4. Open the mozilla-2.0 folder and open a terminal in that folder
(right-click in the folder background and choose Window -> Terminal Here)

5. Figure out what cpu you want to compile for
http://gcc.gnu.org/onlinedocs/gcc-3.4.6 ... tions.html
(for the most speed pick the highest category your cpu fits in, for instance my Phenom could be i686 or K8, but its highest is amdfam10)

6. Enter:

Code: Select all

# export CFLAGS="-march=amdfam10 -O3“   
# export CXXFLAGS="-march=amdfam10 -O3“
This makes environmental variables that the compiler will heed

or another way (suggested by Dingo below)

Code: Select all

#export CXXFLAGS="-march=native -O3“
#export CFLAGS="-march=native -O3“
(substitute the abbreviation for your cpu--the -O3 stands for the highest level of optimization--it is the letter capital O. -march means to optimize for *only* the cpu listed--a safer alternative, for less performance, is -mtune. If you are in doubt about your cpu-type, you can use the cpu-type "native," and the compiler will figure it out for itself--I tested and got the same speed with amdfam10 and with native.)

7. Enter: .

Code: Select all

For Firefox
# ./configure --enable-application=browser --prefix=/usr
For Seamonkey
# ./configure --enable-application=suite --prefix=/usr
8. If no error: enter

Code: Select all

# make
9. It could take about an hour to make. If no error, create a new folder with a representative name such as
/mnt/sdb1/Firefox-4.0.1-lucid525-amdfam10

10. Still in the same terminal, Enter:

Code: Select all

# make install DESTDIR=/mnt/sdb1/Firefox-4.0.1-lucid525-amdfam10
(DESTDIR puts the installation into a folder that you can turn into a pet--I often put it in the / directory, such as )

Code: Select all

# make install DESTDIR=/Firefox-4.0.1-lucid525-amdfam10
11. Exit the Firefox folder and find the DESTDIR and enter

Code: Select all

# dir2pet Firefox-4.0.1-lucid525-amdfam10
and answer the pet questions. At the end you will have a pet of the Firefox you have compiled. It will not have menu entries though, so start it in /usr/bin/firefox, or by entering firefox in a terminal. The pet you make will have the DEV files included so it will be about 32MB. You can delete: /usr/include, /usr/lib/firefox-4.01-devel, and /usr/share/idl before making the pet, in order to bring the pet down to 14MB.

This is just an outline. There are several thousand Puppians who know more than I do about this, so I hope they will offer suggestions to refine the process. For instance I am not sure that both CXXFLAGS and CFLAGS are needed...

Traditionally firefox was regarded as very difficult to compile--not so anymore. Another urban myth was that the Mozilla code could not be optimized at even -O2--not so anymore--at least the firefox code can handle -O3..
Last edited by playdayz on Fri 17 Jun 2011, 17:00, edited 10 times in total.

User avatar
Dingo
Posts: 1437
Joined: Tue 11 Dec 2007, 17:48
Location: somewhere at the end of rainbow...
Contact:

#2 Post by Dingo »

I tried to build Firefox 4.xx on Puppy 3.01, but I had an error message about lacking of mozilla-libs

where can I get mozilla-libs?
replace .co.cc with .info to get access to stuff I posted in forum
dropbox 2GB free
OpenOffice for Puppy Linux

User avatar
playdayz
Posts: 3799
Joined: Fri 25 Apr 2008, 18:57

#3 Post by playdayz »

Dingo, You are one of the thousands of Puppians who know more than I do about this. I don't know. I was darn happy to get it working on Lucid 5.2.5 ;-)

User avatar
Dingo
Posts: 1437
Joined: Tue 11 Dec 2007, 17:48
Location: somewhere at the end of rainbow...
Contact:

#4 Post by Dingo »

I'll try again, (first attempt was a matter of few minutes before to sleep). If you want try, meanwhile, I read in past that -Os can sometimes give a minor memory footprint once application loads itself

since gcc 4.3.x (if I remember well), we can use a special switch

-mtune=native

that turns on all processor capabilities

in this way:

Code: Select all

export CFLAGS="-O3 -march=native"
export CXXFLAGS="-O3 -march=native"
unfortunately I have a wireless adapter (netgear wg311V3) not working in latest puppies via ndiswrapper, so until I not find any adapter working, I cannot experiment by myself
replace .co.cc with .info to get access to stuff I posted in forum
dropbox 2GB free
OpenOffice for Puppy Linux

User avatar
puppyluvr
Posts: 3470
Joined: Sun 06 Jan 2008, 23:14
Location: Chickasha Oklahoma
Contact:

#5 Post by puppyluvr »

:D Hello,
I needed this to build for nocona..(Intel with 64 support)
(Available via the PPM from the `butu repos as "YASM"..)
https://developer.mozilla.org/en/YASM...

Using march=xxx enables mtune=xxx so I used:

#export CXXFLAGS="-march=nocona -O3“
#export CFLAGS="-march=nocona -O3“
# ./configure --enable-application=browser --prefix=/usr --sysconfdir=/etc --localstatedir=/var

Still "making"......
Close the Windows, and open your eyes, to a whole new world
I am Lead Dog of the
Puppy Linux Users Group on Facebook
Join us!

Puppy since 2.15CE...

User avatar
playdayz
Posts: 3799
Joined: Fri 25 Apr 2008, 18:57

#6 Post by playdayz »

Yes, puppyluvr, I knew I would forget something. I will add it to the instructions and provide a link. Yasm is necessary if the compiled Firefox is to support Webm video as I understand/remember it. I installed the Ubuntu Natty Yasm, and indeed the Firefox I built does support webm. I will provide links to that also. Thanks also to Dingo for the -march=native tip--I remember reading it now.

Indy'spup
Posts: 50
Joined: Wed 11 May 2011, 15:32
Location: SoCal

#7 Post by Indy'spup »

This is where I butted heads with the fisrt road block, whenever I try to load the sfs file the boot configuration tool says no files exist!!
. Install the lupu_devx_525.sfs (contains files needed to compile)
http://distro.ibiblio.org/pub/linux/dis ... vx_525.sfs
Put it in /mnt/home, then Menu -> System -> Bootmanager -> Load SFS, move the devx to the right pane, close, and reboot
I'm using the latest Puppy Linux 525 with a full install to HDD. Downloaded the above devx 525.sfs directly to /mnt/home/ open the boot configuration tool at add the devx file but the app consistently reports "No files are available"!!!! damn it!!!

Ok tried again reformat the drive, full install, but no joy, same negative result... :(

anyone got any ideas? because i'm right out of them ...

User avatar
666philb
Posts: 3615
Joined: Sun 07 Feb 2010, 12:27
Location: wales ... by the sea

#8 Post by 666philb »

hi indy'spup

Using the bootmanager to load sfs files is for frugal installs only. For a full install you can use either of these....

this will install the sfs permanently (no uninstall)http://www.murga-linux.com/puppy/viewtopic.php?t=44765

I've never tried this, but it seems you can also uninstall the sfs.....http://www.murga-linux.com/puppy/viewtopic.php?t=64587
Bionicpup64 built with bionic beaver packages http://murga-linux.com/puppy/viewtopic.php?t=114311
Xenialpup64, built with xenial xerus packages http://murga-linux.com/puppy/viewtopic.php?t=107331

Indy'spup
Posts: 50
Joined: Wed 11 May 2011, 15:32
Location: SoCal

#9 Post by Indy'spup »

Thank You :D

After four days of reading I finally found buried in the dev section where it says exactly that!!

So I get it now, effectively limits compiling to a live build only :( go figure...

User avatar
666philb
Posts: 3615
Joined: Sun 07 Feb 2010, 12:27
Location: wales ... by the sea

#10 Post by 666philb »

Indy'spup wrote:Thank You :D

After four days of reading I finally found buried in the dev section where it says exactly that!!

So I get it now, effectively limits compiling to a live build only :( go figure...
Not at all, you just need to install the devx.sfs in a different way. i recommend to use the first link i posted above. After rereading the post it seems that it also has an uninstall option. Although if you're interested in compiling, you would want it installed permanently.
Bionicpup64 built with bionic beaver packages http://murga-linux.com/puppy/viewtopic.php?t=114311
Xenialpup64, built with xenial xerus packages http://murga-linux.com/puppy/viewtopic.php?t=107331

User avatar
scabz
Posts: 364
Joined: Thu 30 Apr 2009, 18:14
Location: Tallahassee FL US
Contact:

#11 Post by scabz »

here is the .mozconfig i used to compile firefox 18.0 in precise for my cpu if anybody wants it, this line needs to be changed for your cpu

ac_add_options --enable-optimize="-march=k8 -O2 -pipe -fomit-frame-pointer"

Code: Select all

mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/objdir-fx-release
mk_add_options MOZ_CO_PROJECT=browser
mk_add_options MOZ_PHOENIX=1
ac_add_options --enable-optimize="-march=k8 -O2 -pipe -fomit-frame-pointer"
ac_add_options --enable-application=browser
ac_add_options --enable-system-hunspell
ac_add_options --localstatedir=/var
ac_add_options --sysconfdir=/etc
ac_add_options --prefix=/usr
ac_add_options --disable-dbus
ac_add_options --disable-accessibility
ac_add_options --with-system-bz2
ac_add_options --disable-updater
ac_add_options --disable-parental-controls
ac_add_options --disable-gnomevfs
ac_add_options --disable-gnomeui
ac_add_options --disable-system-sqlite
ac_add_options --disable-system-cairo
ac_add_options --enable-system-pixman
ac_add_options --enable-strip
ac_add_options --with-system-jpeg
ac_add_options --with-system-zlib
ac_add_options --enable-libxul
ac_add_options --enable-storage
ac_add_options --disable-tests
ac_add_options --with-default-mozilla-five-home=/usr/lib/firefox
ac_add_options --enable-default-toolkit=cairo-gtk2
ac_add_options --disable-crashreporter
ac_add_options --disable-libnotify
ac_add_options --enable-mathml
ac_add_options --enable-crypto
ac_add_options --without-system-png
ac_add_options --enable-cookies
ac_add_options --enable-negotiateauth
ac_add_options --enable-plugins
ac_add_options --disable-debug
ac_add_options --with-pthreads
ac_add_options --enable-printing
ac_add_options --with-system-libvpx
ac_add_options --enable-jsd
ac_add_options --disable-gio
ac_add_options --disable-gconf
ac_add_options --without-system-nss
ac_add_options --without-system-nspr
ac_add_options --disable-necko-wifi
ac_add_options --enable-official-branding
this compiled and works great but is there anything i could change to make it optimize better?

Code: Select all

# cat /proc/cpuinfo
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 15
model		: 75
model name	: AMD Athlon(tm) 64 X2 Dual Core Processor 4600+
stepping	: 2
microcode	: 0x62
cpu MHz		: 2411.240
cache size	: 512 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 2
apicid		: 0
initial apicid	: 0
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 1
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips	: 4824.41
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc

processor	: 1
vendor_id	: AuthenticAMD
cpu family	: 15
model		: 75
model name	: AMD Athlon(tm) 64 X2 Dual Core Processor 4600+
stepping	: 2
microcode	: 0x62
cpu MHz		: 2411.240
cache size	: 512 KB
physical id	: 0
siblings	: 2
core id		: 1
cpu cores	: 2
apicid		: 1
initial apicid	: 1
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 1
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow extd_apicid pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy
bogomips	: 4823.54
clflush size	: 64
cache_alignment	: 64
address sizes	: 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc

User avatar
scabz
Posts: 364
Joined: Thu 30 Apr 2009, 18:14
Location: Tallahassee FL US
Contact:

#12 Post by scabz »

I got it worked out this line works great on firefox and seamonkey.

Code: Select all

ac_add_options --enable-optimize="-O3 -march=k8"

Post Reply