xpcshell should be built with "-march=native"

The place to report Pale Moon specific bugs on Linux and other operating systems.

Moderator: satrow

Walter Dnes
Astronaut
Astronaut
Posts: 604
Joined: 2015-07-30, 20:29
Location: Vaughan, ON, Canada

xpcshell should be built with "-march=native"

Unread post by Walter Dnes » 2017-01-02, 20:43

I've run into a few situations where I've had to use "--disable-precompiled-startupcache". After some dead ends, I think I've found the root cause, and a solution. The following description is linux-centric with gcc, because that's all I use, but it may also apply to other OS/compiler pllatforms.

The bug... any cross-compiling situation where the target architecture code will not execute on the build architecture cpu will cause "mach package" to fai, unless "--disable-precompiled-startupcache" is invoked.

The root cause... (in linux at least) the packaging stage "mach package" executes "xpcshell" ON THE BUILD MACHINE IN THE BUILD ENVIRONMENT to generate the precompiled startup cache. This explains everything.
  • xpcshell compiled with "-march=amdfam10" will not run if built on my desktop Intel i5
  • xpcshell compiled with "-march=bonnell" will not run in the 32-bit CentOS VM which directly uses my desktop's cpu
  • xpcshell compiled with "-march=native" will work, by definition. Mind you, it's 6 hours and 15 minutes building on my Atom Netbook, even with "makeopts=-j3"
The bugfix... since xpcshell is only executed on the build machine, and is not packaged, let alone excuted on the target machine, it should be built with CFLAGS and CXXFLAGS set to "-O2 -march=native". This will work in the build environment, by definition. When grep'ing through the source, I see a lot of locations where CFLAGS and CXXFLAGS are set/modified. Setting CFLAGS/CXXFLAGS for the xpcshell code build, and re-setting them afterwards, looks like a fix that will work on both native and cross-compile builds. IANAP (I Am Not A Programmer) but this looks correct to me.
There's a right way
There's a wrong way
And then there's my way

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 23950
Joined: 2011-08-28, 17:27
Location: 58°2'16"N 14°58'31"E
Contact:

Re: xpcshell should be built with "-march=native"

Unread post by Moonchild » 2017-01-02, 23:19

Nice theory, but it doesn't add up.
xpcshell and other built binaries can always be executed on the build machine. The build system relies on this unless you explicitly indicate you are cross-compiling in the build configuration. The precompilation of the startup cache fails for other reasons in some environments, and it's not yet clear why.
City of Heroes public server: https://www.moonshard.org/ -- Vote for it on cohservers.com

"If you want to build a better world for yourself, you have to be willing to build one for everybody." -- Coyote Osborne
Image

Walter Dnes
Astronaut
Astronaut
Posts: 604
Joined: 2015-07-30, 20:29
Location: Vaughan, ON, Canada

Re: xpcshell should be built with "-march=native"

Unread post by Walter Dnes » 2017-01-03, 01:10

Moonchild wrote:Nice theory, but it doesn't add up.
xpcshell and other built binaries can always be executed on the build machine. The build system relies on this unless you explicitly indicate you are cross-compiling in the build configuration.
Is there some additional flag/option I should be setting for cross-compiles? IANAP (I Am Not A Programmer) and there's a lot I don't know. I'd really like to be able to do a personal build for my Atom on a non-Atom machine, while still enabling precompiled startupcache.
Moonchild wrote: The precompilation of the startup cache fails for other reasons in some environments, and it's not yet clear why.
"The perfect is the enemy of the good". If we can eliminate 75% of build failures, that is a worthy goal in itself. Plus, with one less factor to worry about, it becomes easier to track down the remaining problems. And finally, there is simply no logical reason to build xpcshell non-native when it only runs on the build machine/environment AND IS NOT DISTRIBUTED AS PART OF PALE MOON.
There's a right way
There's a wrong way
And then there's my way

User avatar
New Tobin Paradigm
Off-Topic Sheriff
Off-Topic Sheriff
Posts: 5590
Joined: 2012-10-09, 19:37
Location: Sector 001

Re: xpcshell should be built with "-march=native"

Unread post by New Tobin Paradigm » 2017-01-03, 03:05

I think a good question is.. What are you directly using xpcshell for specifically.. Since it is not distributed with production binaries I am not sure why the development team should actually care.
Image
- So then, "mono" means one, and "rail" means rail! -
And that concludes our intensive three-week course.
http://binaryoutcast.com/ | http://thereisonlyxul.org/

Walter Dnes
Astronaut
Astronaut
Posts: 604
Joined: 2015-07-30, 20:29
Location: Vaughan, ON, Canada

Re: xpcshell should be built with "-march=native"

Unread post by Walter Dnes » 2017-01-04, 20:04

Matt A Tobin wrote:I think a good question is.. What are you directly using xpcshell for specifically..
xpcshell is executed by the build process to populate the "precompiled startupcache" during the "mach package" stage. It can be omitted, but that results in no precompiled startupcache, which results in longer startup times the first time after an install or upgrade.

Question... is it possible to include a pre-built, "precompiled startupcache" with the git code. OK, maybe 2 versions (32 and 64 bit).
There's a right way
There's a wrong way
And then there's my way

Locked