From 50e0fa03c48cb9af03c3efdc3100f12687651a2e Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 21 Aug 2023 03:06:26 +0200 Subject: Switch build system to rolling releases. --- Makefile | 28 +++++++++++++------- etc/luajit.pc | 2 +- src/.gitignore | 2 ++ src/Makefile | 23 +++++++++++----- src/host/buildvm.c | 1 + src/host/genversion.lua | 43 ++++++++++++++++++++++++++++++ src/jit/bc.lua | 1 - src/jit/bcsave.lua | 2 +- src/jit/dump.lua | 1 - src/jit/v.lua | 1 - src/lib_jit.c | 2 +- src/luaconf.h | 2 +- src/luajit.h | 70 ------------------------------------------------- src/luajit_rolling.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 14 files changed, 154 insertions(+), 94 deletions(-) create mode 100644 src/host/genversion.lua delete mode 100644 src/luajit.h create mode 100644 src/luajit_rolling.h diff --git a/Makefile b/Makefile index 9fc0032c..792d7e56 100644 --- a/Makefile +++ b/Makefile @@ -15,10 +15,16 @@ MAJVER= 2 MINVER= 0 -RELVER= 5 -VERSION= $(MAJVER).$(MINVER).$(RELVER) ABIVER= 5.1 +# LuaJIT uses rolling releases. The release version is based on the time of +# the latest git commit. The 'git' command must be available during the build. +RELVER= $(shell cat src/luajit_relver.txt 2>/dev/null || : ) +# Note: setting it with := doesn't work, since it will change during the build. + +MMVERSION= $(MAJVER).$(MINVER) +VERSION= $(MMVERSION).$(RELVER) + ############################################################################## # # Change the installation path as needed. This automatically adjusts @@ -32,10 +38,10 @@ DPREFIX= $(DESTDIR)$(PREFIX) INSTALL_BIN= $(DPREFIX)/bin INSTALL_LIB= $(DPREFIX)/$(MULTILIB) INSTALL_SHARE= $(DPREFIX)/share -INSTALL_DEFINC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER) +INSTALL_DEFINC= $(DPREFIX)/include/luajit-$(MMVERSION) INSTALL_INC= $(INSTALL_DEFINC) -INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION) +INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(MMVERSION) INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit INSTALL_LMODD= $(INSTALL_SHARE)/lua INSTALL_LMOD= $(INSTALL_LMODD)/$(ABIVER) @@ -49,10 +55,10 @@ INSTALL_TSYMNAME= luajit INSTALL_ANAME= libluajit-$(ABIVER).a INSTALL_SOSHORT1= libluajit-$(ABIVER).so INSTALL_SOSHORT2= libluajit-$(ABIVER).so.$(MAJVER) -INSTALL_SONAME= $(INSTALL_SOSHORT2).$(MINVER).$(RELVER) +INSTALL_SONAME= libluajit-$(ABIVER).so.$(VERSION) INSTALL_DYLIBSHORT1= libluajit-$(ABIVER).dylib INSTALL_DYLIBSHORT2= libluajit-$(ABIVER).$(MAJVER).dylib -INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).$(MINVER).$(RELVER).dylib +INSTALL_DYLIBNAME= libluajit-$(ABIVER).$(VERSION).dylib INSTALL_PCNAME= luajit.pc INSTALL_STATIC= $(INSTALL_LIB)/$(INSTALL_ANAME) @@ -77,7 +83,8 @@ INSTALL_F= install -m 0644 UNINSTALL= $(RM) LDCONFIG= ldconfig -n 2>/dev/null SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \ - -e "s|^multilib=.*|multilib=$(MULTILIB)|" + -e "s|^multilib=.*|multilib=$(MULTILIB)|" \ + -e "s|^relver=.*|relver=$(RELVER)|" ifneq ($(INSTALL_DEFINC),$(INSTALL_INC)) SED_PC+= -e "s|^includedir=.*|includedir=$(INSTALL_INC)|" endif @@ -110,9 +117,9 @@ endif INSTALL_DEP= src/luajit default all $(INSTALL_DEP): - @echo "==== Building LuaJIT $(VERSION) ====" + @echo "==== Building LuaJIT $(MMVERSION) ====" $(MAKE) -C src - @echo "==== Successfully built LuaJIT $(VERSION) ====" + @echo "==== Successfully built LuaJIT $(MMVERSION) ====" install: $(INSTALL_DEP) @echo "==== Installing LuaJIT $(VERSION) to $(PREFIX) ====" @@ -150,8 +157,9 @@ uninstall: ############################################################################## amalg: - @echo "Building LuaJIT $(VERSION)" + @echo "==== Building LuaJIT $(MMVERSION) (amalgamation) ====" $(MAKE) -C src amalg + @echo "==== Successfully built LuaJIT $(MMVERSION) (amalgamation) ====" clean: $(MAKE) -C src clean diff --git a/etc/luajit.pc b/etc/luajit.pc index 9bac3a8b..68f8d5cc 100644 --- a/etc/luajit.pc +++ b/etc/luajit.pc @@ -1,7 +1,7 @@ # Package information for LuaJIT to be used by pkg-config. majver=2 minver=0 -relver=5 +relver=ROLLING version=${majver}.${minver}.${relver} abiver=5.1 diff --git a/src/.gitignore b/src/.gitignore index fc94e82c..19f2a00e 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,4 +1,6 @@ luajit +luajit.h +luajit_relver.txt lj_bcdef.h lj_ffdef.h lj_libdef.h diff --git a/src/Makefile b/src/Makefile index aac78beb..e6954a95 100644 --- a/src/Makefile +++ b/src/Makefile @@ -12,7 +12,6 @@ MAJVER= 2 MINVER= 0 -RELVER= 5 ABIVER= 5.1 NODOTABIVER= 51 @@ -308,7 +307,7 @@ ifeq (Darwin,$(TARGET_SYS)) TARGET_STRIP+= -x TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC TARGET_DYNXLDOPTS= - TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) + TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).255 ifeq (x64,$(TARGET_LJARCH)) TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000 TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000 @@ -318,7 +317,7 @@ ifeq (iOS,$(TARGET_SYS)) TARGET_STRIP+= -x TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC TARGET_DYNXLDOPTS= - TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER) + TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).255 else ifneq (SunOS,$(TARGET_SYS)) ifneq (PS3,$(TARGET_SYS)) @@ -367,10 +366,11 @@ MINILUA_O= host/minilua.o MINILUA_LIBS= -lm MINILUA_T= host/minilua MINILUA_X= $(MINILUA_T) +MINILUA_DEP= ifeq (,$(HOST_LUA)) HOST_LUA= $(MINILUA_X) - DASM_DEP= $(MINILUA_T) + MINILUA_DEP= $(MINILUA_T) endif DASM_DIR= ../dynasm @@ -445,6 +445,10 @@ endif DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS) DASM_DASC= vm_$(DASM_ARCH).dasc +GIT= git +GIT_RELVER= [ -d ../.git ] && $(GIT) show -s --format=%ct >luajit_relver.txt 2>/dev/null || cat ../.relver >luajit_relver.txt 2>/dev/null || : +GIT_DEP= $(wildcard ../.git/HEAD ../.git/refs/heads/*) + BUILDVM_O= host/buildvm.o host/buildvm_asm.o host/buildvm_peobj.o \ host/buildvm_lib.o host/buildvm_fold.o BUILDVM_T= host/buildvm @@ -488,8 +492,8 @@ LUAJIT_T= luajit ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T) ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \ - host/buildvm_arch.h -ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP) + host/buildvm_arch.h luajit.h +ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) luajit_relver.txt $(LIB_VMDEFP) WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM) @@ -610,7 +614,12 @@ $(MINILUA_T): $(MINILUA_O) $(E) "HOSTLINK $@" $(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS) -host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP) lj_arch.h lua.h luaconf.h +luajit.h: $(MINILUA_DEP) $(GIT_DEP) luajit_rolling.h + $(E) "VERSION $@" + $(Q)$(GIT_RELVER) + $(Q)$(HOST_LUA) host/genversion.lua + +host/buildvm_arch.h: $(DASM_DASC) $(MINILUA_DEP) lj_arch.h lua.h luaconf.h $(E) "DYNASM $@" $(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC) diff --git a/src/host/buildvm.c b/src/host/buildvm.c index ef393ff8..39c2bc24 100644 --- a/src/host/buildvm.c +++ b/src/host/buildvm.c @@ -320,6 +320,7 @@ static void emit_vmdef(BuildCtx *ctx) char buf[80]; int i; fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n"); + fprintf(ctx->fp, "assert(require(\"jit\").version == \"%s\", \"LuaJIT core/library version mismatch\")\n\n", LUAJIT_VERSION); fprintf(ctx->fp, "module(...)\n\n"); fprintf(ctx->fp, "bcnames = \""); diff --git a/src/host/genversion.lua b/src/host/genversion.lua new file mode 100644 index 00000000..a38cec56 --- /dev/null +++ b/src/host/genversion.lua @@ -0,0 +1,43 @@ +---------------------------------------------------------------------------- +-- Lua script to embed the rolling release version in luajit.h. +---------------------------------------------------------------------------- +-- Copyright (C) 2005-2023 Mike Pall. All rights reserved. +-- Released under the MIT license. See Copyright Notice in luajit.h +---------------------------------------------------------------------------- + +local FILE_INPUT_H = "luajit_rolling.h" +local FILE_INPUT_R = "luajit_relver.txt" +local FILE_OUTPUT_H = "luajit.h" + +local function file_read(file) + local fp = assert(io.open(file, "rb"), "run from the wrong directory") + local data = assert(fp:read("*a")) + fp:close() + return data +end + +local function file_write_mod(file, data) + local fp = io.open(file, "rb") + if fp then + local odata = assert(fp:read("*a")) + fp:close() + if odata == data then return end + end + fp = assert(io.open(file, "wb")) + assert(fp:write(data)) + assert(fp:close()) +end + +local text = file_read(FILE_INPUT_H) +local relver = file_read(FILE_INPUT_R):match("(%d+)") + +if relver then + text = text:gsub("ROLLING", relver) +else + io.stderr:write([[ +**** WARNING Cannot determine rolling release version from git log. +**** WARNING The 'git' command must be available during the build. +]]) +end + +file_write_mod(FILE_OUTPUT_H, text) diff --git a/src/jit/bc.lua b/src/jit/bc.lua index b128d35a..4b384012 100644 --- a/src/jit/bc.lua +++ b/src/jit/bc.lua @@ -41,7 +41,6 @@ -- Cache some library functions and objects. local jit = require("jit") -assert(jit.version_num == 20005, "LuaJIT core/library version mismatch") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local bit = require("bit") diff --git a/src/jit/bcsave.lua b/src/jit/bcsave.lua index fcd80334..55fae993 100644 --- a/src/jit/bcsave.lua +++ b/src/jit/bcsave.lua @@ -11,7 +11,7 @@ ------------------------------------------------------------------------------ local jit = require("jit") -assert(jit.version_num == 20005, "LuaJIT core/library version mismatch") +assert(jit.version_num == 20099, "LuaJIT core/library version mismatch") local bit = require("bit") -- Symbol name prefix for LuaJIT bytecode. diff --git a/src/jit/dump.lua b/src/jit/dump.lua index 87950cb2..86f11e26 100644 --- a/src/jit/dump.lua +++ b/src/jit/dump.lua @@ -55,7 +55,6 @@ -- Cache some library functions and objects. local jit = require("jit") -assert(jit.version_num == 20005, "LuaJIT core/library version mismatch") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, funcbc = jutil.funcinfo, jutil.funcbc diff --git a/src/jit/v.lua b/src/jit/v.lua index 19b6949d..29edcf2b 100644 --- a/src/jit/v.lua +++ b/src/jit/v.lua @@ -59,7 +59,6 @@ -- Cache some library functions and objects. local jit = require("jit") -assert(jit.version_num == 20005, "LuaJIT core/library version mismatch") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo diff --git a/src/lib_jit.c b/src/lib_jit.c index c2f1ee7c..04a564c7 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c @@ -648,7 +648,7 @@ LUALIB_API int luaopen_jit(lua_State *L) { lua_pushliteral(L, LJ_OS_NAME); lua_pushliteral(L, LJ_ARCH_NAME); - lua_pushinteger(L, LUAJIT_VERSION_NUM); + lua_pushinteger(L, LUAJIT_VERSION_NUM); /* Deprecated. */ lua_pushliteral(L, LUAJIT_VERSION); LJ_LIB_REG(L, LUA_JITLIBNAME, jit); #ifndef LUAJIT_DISABLE_JITUTIL diff --git a/src/luaconf.h b/src/luaconf.h index c1c9b4d3..8fc3eee5 100644 --- a/src/luaconf.h +++ b/src/luaconf.h @@ -37,7 +37,7 @@ #endif #define LUA_LROOT "/usr/local" #define LUA_LUADIR "/lua/5.1/" -#define LUA_LJDIR "/luajit-2.0.5/" +#define LUA_LJDIR "/luajit-2.0/" #ifdef LUA_ROOT #define LUA_JROOT LUA_ROOT diff --git a/src/luajit.h b/src/luajit.h deleted file mode 100644 index 8b09f376..00000000 --- a/src/luajit.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -** LuaJIT -- a Just-In-Time Compiler for Lua. https://luajit.org/ -** -** Copyright (C) 2005-2023 Mike Pall. All rights reserved. -** -** Permission is hereby granted, free of charge, to any person obtaining -** a copy of this software and associated documentation files (the -** "Software"), to deal in the Software without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Software, and to -** permit persons to whom the Software is furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be -** included in all copies or substantial portions of the Software. -** -** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -** -** [ MIT license: https://www.opensource.org/licenses/mit-license.php ] -*/ - -#ifndef _LUAJIT_H -#define _LUAJIT_H - -#include "lua.h" - -#define LUAJIT_VERSION "LuaJIT 2.0.5" -#define LUAJIT_VERSION_NUM 20005 /* Version 2.0.5 = 02.00.05. */ -#define LUAJIT_VERSION_SYM luaJIT_version_2_0_5 -#define LUAJIT_COPYRIGHT "Copyright (C) 2005-2023 Mike Pall" -#define LUAJIT_URL "https://luajit.org/" - -/* Modes for luaJIT_setmode. */ -#define LUAJIT_MODE_MASK 0x00ff - -enum { - LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ - LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ - - LUAJIT_MODE_FUNC, /* Change mode for a function. */ - LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ - LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ - - LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ - - LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ - - LUAJIT_MODE_MAX -}; - -/* Flags or'ed in to the mode. */ -#define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ -#define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ -#define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ - -/* LuaJIT public C API. */ - -/* Control the JIT engine. */ -LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); - -/* Enforce (dynamic) linker error for version mismatches. Call from main. */ -LUA_API void LUAJIT_VERSION_SYM(void); - -#endif diff --git a/src/luajit_rolling.h b/src/luajit_rolling.h new file mode 100644 index 00000000..27368836 --- /dev/null +++ b/src/luajit_rolling.h @@ -0,0 +1,70 @@ +/* +** LuaJIT -- a Just-In-Time Compiler for Lua. https://luajit.org/ +** +** Copyright (C) 2005-2023 Mike Pall. All rights reserved. +** +** Permission is hereby granted, free of charge, to any person obtaining +** a copy of this software and associated documentation files (the +** "Software"), to deal in the Software without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Software, and to +** permit persons to whom the Software is furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be +** included in all copies or substantial portions of the Software. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +** +** [ MIT license: https://www.opensource.org/licenses/mit-license.php ] +*/ + +#ifndef _LUAJIT_H +#define _LUAJIT_H + +#include "lua.h" + +#define LUAJIT_VERSION "LuaJIT 2.0.ROLLING" +#define LUAJIT_VERSION_NUM 20099 /* Deprecated. */ +#define LUAJIT_VERSION_SYM luaJIT_version_2_0_ROLLING +#define LUAJIT_COPYRIGHT "Copyright (C) 2005-2023 Mike Pall" +#define LUAJIT_URL "https://luajit.org/" + +/* Modes for luaJIT_setmode. */ +#define LUAJIT_MODE_MASK 0x00ff + +enum { + LUAJIT_MODE_ENGINE, /* Set mode for whole JIT engine. */ + LUAJIT_MODE_DEBUG, /* Set debug mode (idx = level). */ + + LUAJIT_MODE_FUNC, /* Change mode for a function. */ + LUAJIT_MODE_ALLFUNC, /* Recurse into subroutine protos. */ + LUAJIT_MODE_ALLSUBFUNC, /* Change only the subroutines. */ + + LUAJIT_MODE_TRACE, /* Flush a compiled trace. */ + + LUAJIT_MODE_WRAPCFUNC = 0x10, /* Set wrapper mode for C function calls. */ + + LUAJIT_MODE_MAX +}; + +/* Flags or'ed in to the mode. */ +#define LUAJIT_MODE_OFF 0x0000 /* Turn feature off. */ +#define LUAJIT_MODE_ON 0x0100 /* Turn feature on. */ +#define LUAJIT_MODE_FLUSH 0x0200 /* Flush JIT-compiled code. */ + +/* LuaJIT public C API. */ + +/* Control the JIT engine. */ +LUA_API int luaJIT_setmode(lua_State *L, int idx, int mode); + +/* Enforce (dynamic) linker error for version mismatches. Call from main. */ +LUA_API void LUAJIT_VERSION_SYM(void); + +#endif -- cgit v1.2.3-55-g6feb