Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Dec 2019 18:25:16 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r355345 - in stable: 11/libexec 11/libexec/flua 11/share/mk 11/stand 11/stand/common 11/stand/liblua 11/stand/lua 12/libexec 12/libexec/flua 12/share/mk 12/stand 12/stand/common 12/stan...
Message-ID:  <201912031825.xB3IPGSo049200@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Tue Dec  3 18:25:16 2019
New Revision: 355345
URL: https://svnweb.freebsd.org/changeset/base/355345

Log:
  MFC r354245, r354833, r354837: add flua to the base system
  
  r354245: stand: consolidate knowledge of lua path
  
  Multiple places coordinate to 'know' where lua scripts are installed. Knock
  this down to being formally defined (and overridable) in exactly one spot,
  defs.mk, and spread the knowledge to loaders and liblua alike. A future
  commit will expose this to lua as loader.lua_path, so it can build absolute
  paths to lua scripts as needed.
  
  r354833: Add flua to the base system, install to /usr/libexec
  
  FreeBSDlua ("flua") is a FreeBSD-private lua, flavored with whatever
  extensions we need for base system operations. We currently support a subset
  of lfs and lposix that are used in the rewrite of makesyscall.sh into lua,
  added in r354786.
  
  flua is intentionally written such that one can install standard lua and
  some set of lua modules from ports and achieve the same effect.
  
  linit_flua is a copy of linit.c from contrib/lua with lfs and lposix added
  in. This is similar to what we do in stand/. linit.c has been renamed to
  make it clear that this has flua-specific bits.
  
  luaconf has been slightly obfuscated to make extensions more difficult. Part
  of the problem is that flua is already hard enough to use as a bootstrap
  tool because it's not in PATH- attempting to do extension loading would
  require a special bootstrap version of flua with paths changed to protect
  the innocent.
  
  src.lua.mk has been added to make it easy for in-tree stuff to find flua,
  whether it's bootstrap-flua or relying on PATH frobbing by Makefile.inc1.
  
  r354837: flua: newer GCC complains about format-nonliteral at WARNS=2
  
  Disable that one, too.

Added:
  stable/11/libexec/flua/
     - copied from r354833, head/libexec/flua/
  stable/11/share/mk/src.lua.mk
     - copied unchanged from r354833, head/share/mk/src.lua.mk
Deleted:
  stable/11/stand/liblua/lfs.c
  stable/11/stand/liblua/lfs.h
Modified:
  stable/11/libexec/Makefile
  stable/11/libexec/flua/Makefile
  stable/11/stand/common/interp_lua.c
  stable/11/stand/defs.mk
  stable/11/stand/liblua/Makefile
  stable/11/stand/liblua/luaconf.h
  stable/11/stand/loader.mk
  stable/11/stand/lua/Makefile
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Added:
  stable/12/libexec/flua/
     - copied from r354833, head/libexec/flua/
  stable/12/share/mk/src.lua.mk
     - copied unchanged from r354833, head/share/mk/src.lua.mk
Deleted:
  stable/12/stand/liblua/lfs.c
  stable/12/stand/liblua/lfs.h
Modified:
  stable/12/libexec/Makefile
  stable/12/libexec/flua/Makefile
  stable/12/stand/common/interp_lua.c
  stable/12/stand/defs.mk
  stable/12/stand/liblua/Makefile
  stable/12/stand/liblua/luaconf.h
  stable/12/stand/loader.mk
  stable/12/stand/lua/Makefile
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/libexec/Makefile
==============================================================================
--- stable/11/libexec/Makefile	Tue Dec  3 17:43:57 2019	(r355344)
+++ stable/11/libexec/Makefile	Tue Dec  3 18:25:16 2019	(r355345)
@@ -8,6 +8,7 @@ SUBDIR=	${_atf} \
 	${_blacklistd-helper} \
 	${_comsat} \
 	${_dma} \
+	flua \
 	getty \
 	${_mail.local} \
 	${_makewhatis.local} \

Modified: stable/11/libexec/flua/Makefile
==============================================================================
--- head/libexec/flua/Makefile	Mon Nov 18 23:21:13 2019	(r354833)
+++ stable/11/libexec/flua/Makefile	Tue Dec  3 18:25:16 2019	(r355345)
@@ -9,6 +9,8 @@ PROG=	flua
 WARNS?=	2
 MAN=	# No manpage; this is internal.
 
+CWARNFLAGS.gcc+=	-Wno-format-nonliteral
+
 LIBADD=	m
 
 # Core functions

Copied: stable/11/share/mk/src.lua.mk (from r354833, head/share/mk/src.lua.mk)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/share/mk/src.lua.mk	Tue Dec  3 18:25:16 2019	(r355345, copy of r354833, head/share/mk/src.lua.mk)
@@ -0,0 +1,45 @@
+# $FreeBSD$
+#
+# Lua helper file for FreeBSD /usr/src builds.
+#
+# This file provides any necessary assistance for consumers of Lua in the base
+# system.
+
+.if !target(__<src.lua.mk>__)
+__<src.lua.mk>__:
+
+.include <bsd.own.mk>
+
+#
+# LUA_INSTALL_PATH and LUA_CMD describe where the internal lua has been
+# installed to, along with the name of the internal command.  The default
+# name is flua.
+#
+# LUA_CMD can be overwritten to point to a Lua that isn't flua.  This is fine,
+# but parts of the src build that use it may have certain expectations that
+# may only be fulfilled by the in-tree Lua.  The user overwriting it is expected
+# to understand these and provide the expectations.
+#
+# flua is currently equivalent to Lua 5.3, with the following modules:
+# - luafilesystem
+# - lua-posix
+#
+LUA_INSTALL_PATH?=	${LIBEXECDIR}
+LUA_CMD?=		flua
+
+#
+# Some standalone usage may want a variable that tries to find the lua command,
+# and cannot necessarily embed the logic for trying to find it amongst bootstrap
+# tools.  For these, we provide the LUA variable.
+#
+# The LUA variable should point to LUA_CMD on the system, if it exists.
+# Otherwise, consumers will have to settle for a PATH search and PATH being
+# appropriately set.
+#
+.if !defined(LUA) && exists(${LUA_INSTALL_PATH}/${LUA_CMD})
+LUA=	${LUA_INSTALL_PATH}/${LUA_CMD}
+.else
+LUA?=	${LUA_CMD}
+.endif
+
+.endif #  !target(__<src.lua.mk>__)

Modified: stable/11/stand/common/interp_lua.c
==============================================================================
--- stable/11/stand/common/interp_lua.c	Tue Dec  3 17:43:57 2019	(r355344)
+++ stable/11/stand/common/interp_lua.c	Tue Dec  3 18:25:16 2019	(r355345)
@@ -60,6 +60,8 @@ static struct interp_lua_softc lua_softc;
 #define	LDBG(...)
 #endif
 
+#define	LOADER_LUA	LUA_PATH "/loader.lua"
+
 INTERP_DEFINE("lua");
 
 static void *
@@ -120,7 +122,7 @@ interp_init(void)
 		lua_pop(luap, 1);  /* remove lib */
 	}
 
-	filename = "/boot/lua/loader.lua";
+	filename = LOADER_LUA;
 	if (interp_include(filename) != 0) {
                 const char *errstr = lua_tostring(luap, -1);
                 errstr = errstr == NULL ? "unknown" : errstr;

Modified: stable/11/stand/defs.mk
==============================================================================
--- stable/11/stand/defs.mk	Tue Dec  3 17:43:57 2019	(r355344)
+++ stable/11/stand/defs.mk	Tue Dec  3 18:25:16 2019	(r355345)
@@ -40,6 +40,10 @@ BOOTOBJ=	${OBJTOP}/stand
 # BINDIR is where we install
 BINDIR?=	/boot
 
+# LUAPATH is where we search for and install lua scripts.
+LUAPATH?=	/boot/lua
+FLUASRC?=	${SRCTOP}/libexec/flua
+
 LIBSA=		${BOOTOBJ}/libsa/libsa.a
 .if ${MACHINE} == "i386"
 LIBSA32=	${LIBSA}

Modified: stable/11/stand/liblua/Makefile
==============================================================================
--- stable/11/stand/liblua/Makefile	Tue Dec  3 17:43:57 2019	(r355344)
+++ stable/11/stand/liblua/Makefile	Tue Dec  3 18:25:16 2019	(r355345)
@@ -23,11 +23,14 @@ SRCS+=	lauxlib.c lbaselib.c lstrlib.c loadlib.c
 #SRCS+=	lbitlib.c liolib.c lmathlib.c loslib.c ltablib.c
 
 # Our utilities.
-SRCS+=	lerrno.c lfs.c lstd.c lutils.c
+SRCS+=	lerrno.c lstd.c lutils.c
 
+.PATH:	${FLUASRC}/modules
+SRCS+=	lfs.c
+
 WARNS=	3
 
-CFLAGS+= -DLUA_PATH_DEFAULT=\"/boot/lua/\?.lua\"
+CFLAGS+= -DLUA_PATH=\"${LUAPATH}\" -DLUA_PATH_DEFAULT=\"${LUAPATH}/\?.lua\"
 CFLAGS+= -ffreestanding -nostdlib -DLUA_USE_POSIX
 CFLAGS+= -fno-stack-protector -D__BSD_VISIBLE
 CFLAGS+= -I${BOOTSRC}/include -I${LIBLUASRC} -I${LUASRC} -I${LDRSRC}

Modified: stable/11/stand/liblua/luaconf.h
==============================================================================
--- stable/11/stand/liblua/luaconf.h	Tue Dec  3 17:43:57 2019	(r355344)
+++ stable/11/stand/liblua/luaconf.h	Tue Dec  3 18:25:16 2019	(r355345)
@@ -202,7 +202,7 @@
 
 #else			/* }{ */
 
-#define LUA_ROOT       "/boot/lua/" LUA_VDIR "/"
+#define LUA_ROOT       LUA_PATH "/" LUA_VDIR "/"
 #define LUA_LDIR       LUA_ROOT "share/"
 #define LUA_CDIR       LUA_ROOT "lib/"
 #ifndef LUA_PATH_DEFAULT

Modified: stable/11/stand/loader.mk
==============================================================================
--- stable/11/stand/loader.mk	Tue Dec  3 17:43:57 2019	(r355344)
+++ stable/11/stand/loader.mk	Tue Dec  3 18:25:16 2019	(r355345)
@@ -64,6 +64,7 @@ SRCS+=	interp_lua.c
 .include "${BOOTSRC}/lua.mk"
 LDR_INTERP=	${LIBLUA}
 LDR_INTERP32=	${LIBLUA32}
+CFLAGS.interp_lua.c= -DLUA_PATH=\"${LUAPATH}\" -I${FLUASRC}/modules
 .elif ${LOADER_INTERP} == "4th"
 SRCS+=	interp_forth.c
 .include "${BOOTSRC}/ficl.mk"

Modified: stable/11/stand/lua/Makefile
==============================================================================
--- stable/11/stand/lua/Makefile	Tue Dec  3 17:43:57 2019	(r355344)
+++ stable/11/stand/lua/Makefile	Tue Dec  3 18:25:16 2019	(r355345)
@@ -12,7 +12,7 @@ MAN=	cli.lua.8 \
 	password.lua.8 \
 	screen.lua.8
 
-FILESDIR=	/boot/lua
+FILESDIR=	${LUAPATH}
 FILES=	cli.lua \
 	color.lua \
 	config.lua \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912031825.xB3IPGSo049200>