Build phantomjs on AArch64

Get Source

Phantomjs source can be get from Github.

AArch64 support is introduced in since v2.1.0. For any version later than this, you can just build it without any patches. For versions before 2.1.0 you need to make changes to make it work on aarch64. These changes may be specific to certain version. A patche for most common used version, 1.9.8, is provided in here.

Install dependencies

For Ubuntu-16.04

sudo apt-get install build-essential g++ flex bison gperf ruby perl \
  libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev \
  libpng-dev libjpeg-dev python libx11-dev libxext-dev

If you are using debian 9 stretch than probably you need to install below package, otherwise the QT build will fail. I only compiled v2.1.1 on Debian 9 stretch

sudo apt-get install libssl1.0-dev

For CentOS-7

sudo yum -y install gcc gcc-c++ make flex bison gperf ruby \
  openssl-devel freetype-devel fontconfig-devel libicu-devel sqlite-devel \
  libpng-devel libjpeg-devel

Build Steps

For version before 2.1.0

./build.sh --confirm --jobs $(getconf _NPROCESSORS_ONLN)

For version after 2.0.0

./build.py -c -j $(getconf _NPROCESSORS_ONLN)

Test

./test/run-tests.py

Install

./deploy/package.sh

Issues

While compiling the v2.1.1,  I have faced the below issue because of O3 level optimization is included in Makefile.  After I changed it to O2 level the compilation goes well without any issues.

./build.py -c -j $(getconf _NPROCESSORS_ONLN)
...
....
......
/../include/QtCore/5.5.1/
QtCore -I../../include/QtCore -I.moc
-I../../mkspecs/linux-g++ -o .obj/qdesktopservices.o
util/qdesktopservices.cpp
In file included from ../../include/QtCore/qvector.h:1:0,
                 from ../../include/QtGui/../../src/gui/painting/qpolygon.h:37,
                 from ../../include/QtGui/qpolygon.h:1,
                 from ../../include/QtGui/../../src/gui/painting/qmatrix.h:37,
                 from ../../include/QtGui/qmatrix.h:1,
                 from
../../include/QtGui/../../src/gui/painting/qtransform.h:36,
                 from ../../include/QtGui/qtransform.h:1,
                 from ../../include/QtGui/../../src/gui/image/qimage.h:37,
                 from ../../include/QtGui/qimage.h:1,
                 from ../../include/QtGui/../../src/gui/image/qpixmap.h:42,
                 from ../../include/QtGui/qpixmap.h:1,
                 from ../../include/QtGui/../../src/gui/image/qbitmap.h:37,
                 from ../../include/QtGui/qbitmap.h:1,
                 from kernel/qt_gui_pch.h:63:
../../include/QtCore/../../src/corelib/tools/qvector.h: In member
function ‘{anonymous}::TreeNode
{anonymous}::SegmentTree::buildTree(int, int, int, const
{anonymous}::RectF&)’:
../../include/QtCore/../../src/corelib/tools/qvector.h:380:12:
warning: assuming signed overflow does not occur when assuming that (X+ c) < X is always false [-Wstrict-overflow]
     } else if (!d->capacityReserved && asize < d->size && asize <
(oldAlloc >> 1)) { // we want to shrink
            ^
{standard input}: Assembler messages:
{standard input}:7254: Warning: missing operand; zero assumed
{standard input}:8854: Warning: missing operand; zero assumed
{standard input}:7254: Error: invalid operands (*UND* and *UND*sections) for `*'
{standard input}:8854: Error: invalid operands (*UND* and *UND*sections) for `*'
make[2]: *** [.obj/qgridlayoutengine.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory
`/home/centos/ambari-patch/phantomjs/src/qt/qtbase/src/gui'
make[1]: *** [sub-gui-make_first] Error 2
make[1]: Leaving directory
`/home/centos/ambari-patch/phantomjs/src/qt/qtbase/src'
make: *** [sub-src-make_first] Error 2
ERROR: Failed to build PhantomJS! Building Qt Base failed.