mediawiki-php-luasandbox compiles improperly on CentOS 7 64-bit. While it does produce a build, running hhvm-test.sh fails to load the extension.
The first thing wrong appears to be a lack of an extern "C" { ... } guard around the Lua headers. This would be compatible with C if done with the standard practice of enclosing the opening and closing each like so
#ifdef __cplusplus extern "C" { #endif ... #ifdef __cplusplus } #endif
...but not so fast:
The secondary (and related) issue is that the FindLua51cpp.cmake file expects to find a Lua library with a C++ linkage. Which isn't necessarily unreasonable on its face, because HHVM is C++ as are its extensions. It appears to search lib, but not lib64. When I added lib64, 'liblua' and 'lua' to the names, and /usr to the paths, it did find the library†.
† However, even with these hacks, the test failed to run, though the link error did go away.
The wrinkle here is that so far as I can tell, there are no readily available, packaged distributions of Lua with C++ linkage, which led to the initial diagnosis of the problem as a simple linkage mismatch.
However, the rabbit hole gets a little deeper:
Some searching around surfaced http://stackoverflow.com/a/9803812/321041, from which I followed the link to http://lua-users.org/wiki/BuildingLua.
The relevant quote:
It could be argued that if you are distributing a pre-packaged binaries of the libraries, then you have compiled the lua core as either C (most likely) or as C++, and if you compiled lua as C, you should modify the lua headers to indicate this. However, using prebuilt libraries for lua isn't recommended by the authors, they recommend directly incorporating the lua source into your application. See BuildingModules for a discussion (the end of the page).
By default if lua 5.1 or later is compiled as C++, it will use C++ exceptions to unwind the stack rather than longjmp/setjmp, though this is configurable (at compile time). See luaconf.h near LUAI_THROW/LUAI_TRY for a discussion of this.
So, long-story short, the convention is to embed Lua sources so they share linkage with the C/C++ environment that compiled them, the linkage takes advantage of C++ exceptions, a meaningful difference which causes behavioral differences in error handling , and CentOS or otherwise Red Hat platforms do not appear to offer C++ binary packages (perhaps due to different viable compiler toolchains).
Some additional context: I was aiming to run Scribunto on my MediaWiki installation to take advantage of some Wikipedia templates. However, the only other Lua engine provided is LuaStandalone, which embeds executables of perhaps known provenance, but limited verifiability.