HHVM 3.8.0 fails to compile
On Gentoo system with hardened profile, at the end of compilation I get such output when try to compile HHVM:
Linking CXX executable hhvm /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.4/../../../../x86_64-pc-linux-gnu/bin/ld.gold: error: ../runtime/libhphp_runtime.a(translator-asm-helpers.S.o): requires unsupported dynamic reloc 11; recompile with -fPIC collect2: error: ld returned 1 exit status hphp/hhvm/CMakeFiles/hhvm.dir/build.make:362: recipe for target 'hphp/hhvm/hhvm' failed make[2]: *** [hphp/hhvm/hhvm] Error 1 CMakeFiles/Makefile2:2094: recipe for target 'hphp/hhvm/CMakeFiles/hhvm.dir/all' failed make[1]: *** [hphp/hhvm/CMakeFiles/hhvm.dir/all] Error 2 Makefile:116: recipe for target 'all' failed make: *** [all] Error 2
This sounds like #4705, in particular even if the proximate cause is different, the root cause of "the asm isn't relocatable" as explained in https://github.com/facebook/hhvm/issues/4705#issuecomment-116263180 is likely the same.
I've been trying to get hhvm to run on hardened gentoo to run for a while.
I made https://github.com/APTX/hhvm/commit/810c10dda7b87f090d78bc17660762616e420856 to build hhvm at all. As the commit message says I don't really know if this works as I've never managed to get hhvm to run. I looked at how gcc generates relocatable ASM and tried to apply what I found to the asm file.
For the record you can get gcc to tell you which symbols aren't relocatable if you try linking like this:
gcc -o test.o -c translator-asm-helpers.S gcc test.o -fPIC -shared -o libtest.so
I hit https://github.com/facebook/hhvm/issues/2287. I got around those by disabling PaX RANDMMAP and RANDEXEC. This is a probably a bug by itself.
Now I'm stuck on https://github.com/facebook/hhvm/issues/3642. It's possible https://github.com/facebook/hhvm/issues/3896 is a workaround (by default everything is built with -fPIE on hardened gentoo unless you change your gcc config). This will mean no JIT with hhvm though.
If hhvm gets killed and you see an error like (in grsec logs):
denied RWX mprotect of
by /usr/bin/hhvm[hhvm:25568]
then you need to disable PaX MPROTECT. This option should be disabled for any JIT program (JIT requires to be able to write and execute memory at the same time which this option prevents).
Same as #4705