Adapted for ports repo, this will be okay with me as well:

--
WBR,
  Vadim Zhukov


Index: Makefile
===================================================================
RCS file: /cvs/ports/lang/luajit/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- Makefile    2 Jun 2014 19:43:50 -0000       1.14
+++ Makefile    20 Jan 2015 18:16:20 -0000
@@ -11,7 +11,7 @@ COMMENT =     just-in-time compiler for Lua
 V =            2.0.3
 DISTNAME =     LuaJIT-${V}
 PKGNAME =      ${DISTNAME:L}
-REVISION =     1
+REVISION =     2
 
 CATEGORIES =   lang
 
Index: patches/patch-src_lj_mcode_c
===================================================================
RCS file: patches/patch-src_lj_mcode_c
diff -N patches/patch-src_lj_mcode_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_lj_mcode_c        20 Jan 2015 18:16:20 -0000
@@ -0,0 +1,32 @@
+$OpenBSD$
+On i386, it's better for a jit to ask for exec memory upfront, so uvm
+knows to place it in the exec segment. Otherwise, if you mmap non-exec
+and mprotect it, you wind up with a high mapping and the segment must
+be enlarged to cover the whole process.
+
+Upstream commit: b876d6dadaaff8f1deb91c54513a1e59e40b2ef2
+http://repo.or.cz/w/luajit-2.0.git/commit/b876d6dadaaff8f1deb91c54513a1e59e40b2ef2
+--- src/lj_mcode.c.orig        Tue Jan 20 21:10:04 2015
++++ src/lj_mcode.c     Tue Jan 20 21:13:21 2015
+@@ -252,7 +252,20 @@ static void *mcode_alloc(jit_State *J, size_t sz)
+ #else
+ 
+ /* All memory addresses are reachable by relative jumps. */
+-#define mcode_alloc(J, sz)    mcode_alloc_at((J), 0, (sz), MCPROT_GEN)
++static void *mcode_alloc(jit_State *J, size_t sz)
++{
++#ifdef __OpenBSD__
++  /* Allow better executable memory allocation for OpenBSD W^X mode. */
++  void *p = mcode_alloc_at(J, 0, sz, MCPROT_RUN);
++  if (p && mcode_setprot(p, sz, MCPROT_GEN)) {
++    mcode_free(J, p, sz);
++    return NULL;
++  }
++  return p;
++#else
++  return mcode_alloc_at(J, 0, sz, MCPROT_GEN);
++#endif
++}
+ 
+ #endif
+ 

Reply via email to