Static build complication on Linux due to OpenSSL and ICU
Compared to 1.x, PhantomJS 2.0 has exhibits some problem when being built statically to produce the official Linux binaries.
When the binary is built on Centos 6.6 and tested on Ubuntu 12.04, there will be this error:
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.5 LTS"
$ bin/phantomjs
bin/phantomjs: error while loading shared libraries: libicudata.so.42: cannot open shared object file: No such file or directory
$ ldd bin/phantomjs
linux-vdso.so.1 => (0x00007fff31fff000)
libicudata.so.42 => not found
libssl.so.10 => not found
libcrypto.so.10 => not found
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007ff99863e000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007ff9983a2000)
libjpeg.so.62 => not found
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007ff998179000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff997f62000)
libicui18n.so.42 => not found
libicuuc.so.42 => not found
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff997d5d000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007ff997b54000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff997937000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff997637000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff99733a000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff997124000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff996d65000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff99887d000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007ff996b3a000)
When the binary is built on Ubuntu 12.04 and tested on CentOS 6, there is this error:
$ cat /etc/redhat-release
CentOS release 6.6 (Final)
$ bin/phantomjs
bin/phantomjs: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory
$ ldd bin/phantomjs
bin/phantomjs: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by bin/phantomjs)
bin/phantomjs: /lib64/libc.so.6: version `GLIBC_2.15' not found (required by bin/phantomjs)
bin/phantomjs: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by bin/phantomjs)
linux-vdso.so.1 => (0x00007fff9e9ff000)
libssl.so.1.0.0 => not found
libcrypto.so.1.0.0 => not found
libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x0000003970600000)
libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x0000003970e00000)
libjpeg.so.8 => not found
libpng12.so.0 => /usr/lib64/libpng12.so.0 (0x0000003974200000)
libz.so.1 => /lib64/libz.so.1 (0x000000396fa00000)
libicui18n.so.48 => not found
libicuuc.so.48 => not found
libdl.so.2 => /lib64/libdl.so.2 (0x000000396e600000)
librt.so.1 => /lib64/librt.so.1 (0x000000396f200000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x000000396ee00000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fbbd8347000)
libm.so.6 => /lib64/libm.so.6 (0x000000396f600000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fbbd8130000)
libc.so.6 => /lib64/libc.so.6 (0x000000396ea00000)
/lib64/ld-linux-x86-64.so.2 (0x000000396e200000)
libexpat.so.1 => /lib64/libexpat.so.1 (0x0000003973600000)
As a comparison, ldd on PhantomJS 1.9.8 statically built binary on Ubuntu 12.04 gives the following:
ldd bin/phantomjs
linux-vdso.so.1 => (0x00007fff987cf000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f88af68e000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f88af458000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f88af253000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f88af04b000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f88aee2e000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f88aeb2d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f88ae831000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f88ae61b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f88ae25b000)
/lib64/ld-linux-x86-64.so.2 (0x00007f88af932000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f88ae044000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f88ade1a000)
ICU upstream bug: https://bugreports.qt.io/browse/QTBUG-38445
@ariya, found the problem. Starting commit - 8d23afb782de22c83c8ab48da50bc35bcf91bbfc
@Vitallium Do you mean that the mentioned commit start to introduce the broken build?
@ariya yes, check the line 162 https://github.com/ariya/phantomjs/blob/2.0/src/qt/preconfig.sh#L162 I assume it should be just openssl.
With openssl, I got this on Ubuntu 14.04:
ldd ../bin/phantomjs
linux-vdso.so.1 => (0x00007fff347c0000)
libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f9fe8df8000)
libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f9fe8b50000)
libicui18n.so.52 => /usr/lib/x86_64-linux-gnu/libicui18n.so.52 (0x00007f9fe8748000)
libicuuc.so.52 => /usr/lib/x86_64-linux-gnu/libicuuc.so.52 (0x00007f9fe83c8000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f9fe81c0000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f9fe7fb8000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f9fe7d98000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f9fe7a90000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f9fe7788000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f9fe7570000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f9fe71a8000)
/lib64/ld-linux-x86-64.so.2 (0x00007f9fe9050000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f9fe6f78000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f9fe6d58000)
libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f9fe6b30000)
libicudata.so.52 => /usr/lib/x86_64-linux-gnu/libicudata.so.52 (0x00007f9fe52c0000)
@Vitallium Good news! Now we just need to solve the ICU library...
@ariya isn't ICU bug fixed in 5.3.1? Or we're talking about something else?
@kenips Can you elaborate?
hey @ariya I thought the ICU bug is https://bugreports.qt.io/browse/QTBUG-38445, which is fixed in 5.3.1, isn't it?
Want to bring this up again as my team is depending on PhantomJS 2.0 for testing. However, I am not expert in this. How can I help verifying one static build is working, what is the metric of testing we are looking at?
If I simply do ./build.sh and it completed successfully, does it mean I can copy over to other machines to test?
@ohenak From my understanding, that should theoretically work across similar environments. (e.g. all machines running the same version of Ubuntu).
I do think ICU was fixed in 5.3.1, but Ubuntu 14.04 has an older version:
libqt5core5a:amd64 5.2.1+dfsg-1ubuntu14.2
Probably this fix can be backported:
https://codereview.qt-project.org/#/c/84012/
Although it's not clear to me whether the problem is in the bundled Qt or in the system's version of Qt.
Any ETA / roadmap on this issue? We would like to deploy PhantomJS 2.0 without having to compile.
The only solution which is sustainable in the long term is to have distro-specific packages, like I have done for wkhtmltopdf. Due to the patched/bundled Qt, it does not get packaged with most distributions anyway so having "official" binaries is important.
I'm willing to take up just the packaging part, as I'll be working on that anyway in the near future for wkhtmltopdf 0.13 based on Qt 5.4.1 :smile:
Note that I won't be supporting CentOS 5, as not all security fixes are being backported and getting it to work would be very tough due to very old software versions.
For people that are actually looking for a built binary of phantom-js 2.0 it seems that the Travis-CI team has one (currently only for Ubuntu-12.04). Thought this would at least help some people on the thread until official binaries are available.
https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
We've got this working on 14.04 by manually installing (dpkg) this package:
http://mirrors.kernel.org/ubuntu/pool/main/i/icu/libicu48_4.8.1.1-3ubuntu0.4_amd64.deb