trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [2/2] git commit: TS-1440: Fix the LuaJIT build.
Date Thu, 06 Sep 2012 03:41:44 GMT
TS-1440: Fix the LuaJIT build.

  - Fix linker flags for 64-bit on OS X.
  - Replace lua_newstate with luaL_newstate.


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7f3402a7
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7f3402a7
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7f3402a7

Branch: refs/heads/master
Commit: 7f3402a78e9fc972d01c965241b4131580cad768
Parents: 2044373
Author: James Peach <jpeach@apache.org>
Authored: Sat Aug 18 22:09:56 2012 -0700
Committer: James Peach <jpeach@apache.org>
Committed: Wed Sep 5 20:40:03 2012 -0700

----------------------------------------------------------------------
 configure.ac                      |   14 ++++++++++++++
 plugins/experimental/lua/lutil.cc |    9 +++++++++
 proxy/Makefile.am                 |    4 ++++
 3 files changed, 27 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f3402a7/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index cd37407..627a387 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1150,8 +1150,22 @@ AC_SUBST(LUA_CFLAGS)
 AC_SUBST(LUA_LIBS)
 AC_MSG_CHECKING([whether to enable Lua support])
 AM_CONDITIONAL([BUILD_LUA_SUPPORT], [ test "x${enable_lua_support}" != "xno" ])
+AM_CONDITIONAL([BUILD_HAVE_LUAJIT], [ test "x${have_luajit}" = "xyes" ])
 AC_MSG_RESULT([$enable_lua_support])
 
+# On Darwin LuaJIT requires magic link options, otherwise it will crash in luaL_openlibs()
at startup. See
+# http://luajit.org/install.html.
+case $host_os in
+  darwin*)
+    if test "x${have_luajit}" = "xyes"; then
+      LUA_LUAJIT_LDFLAGS="-Wl,-pagezero_size,10000 -Wl,-image_base,100000000"
+    fi
+    ;;
+esac
+
+AC_SUBST(LUA_LUAJIT_LDFLAGS)
+
+
 # -----------------------------------------------------------------------------
 # 5. CHECK FOR HEADER FILES
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f3402a7/plugins/experimental/lua/lutil.cc
----------------------------------------------------------------------
diff --git a/plugins/experimental/lua/lutil.cc b/plugins/experimental/lua/lutil.cc
index 50586be..50e1557 100644
--- a/plugins/experimental/lua/lutil.cc
+++ b/plugins/experimental/lua/lutil.cc
@@ -38,6 +38,7 @@ LuaThreadInstance::~LuaThreadInstance()
 {
 }
 
+#if !defined(LUAJIT_VERSION)
 static void *
 LuaAllocate(void * ud, void * ptr, size_t osize, size_t nsize)
 {
@@ -50,13 +51,19 @@ LuaAllocate(void * ud, void * ptr, size_t osize, size_t nsize)
 
   return TSrealloc(ptr, nsize);
 }
+#endif
 
 lua_State *
 LuaPluginNewState(void)
 {
   lua_State * lua;
 
+  // lua_newstate() is a stub in LuaJIT 64-bit.
+#if defined(LUAJIT_VERSION)
+  lua = luaL_newstate();
+#else
   lua = lua_newstate(LuaAllocate, NULL);
+#endif
   if (lua == NULL) {
     return NULL;
   }
@@ -143,6 +150,8 @@ LuaLoadLibraries(lua_State * lua)
     REGISTER_LIBRARY(math);
     REGISTER_LIBRARY(debug);
 
+    // XXX LuaJIT recommends calling luaL_openlibs() here. No explanation of why.
+
 #undef REGISTER_LIBRARY
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7f3402a7/proxy/Makefile.am
----------------------------------------------------------------------
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index cab10aa..232c60f 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -168,6 +168,10 @@ traffic_server_LDADD = \
   @LIBZ@ @LIBLZMA@ \
   @LIBMLD@ @LIBEXC@ -lm @LIBPROFILER@ @LIBEXECINFO@
 
+if BUILD_LUA_SUPPORT
+traffic_server_LDFLAGS += @LUA_LUAJIT_LDFLAGS@
+endif
+
 traffic_logcat_SOURCES = logcat.cc
 traffic_logcat_LDFLAGS = @EXTRA_CXX_LDFLAGS@ @LIBTOOL_LINK_FLAGS@
 traffic_logcat_LDADD = \


Mime
View raw message