From owner-svn-src-all@freebsd.org Tue Dec 3 18:25:20 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9A3B61B8758; Tue, 3 Dec 2019 18:25:20 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47S9Q83Xwcz3Fwg; Tue, 3 Dec 2019 18:25:20 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5D1DA1BC7D; Tue, 3 Dec 2019 18:25:20 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xB3IPKKp049224; Tue, 3 Dec 2019 18:25:20 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xB3IPIOZ049214; Tue, 3 Dec 2019 18:25:18 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201912031825.xB3IPIOZ049214@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 3 Dec 2019 18:25:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@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... X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: 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/stand/liblua 12/stand/lua X-SVN-Commit-Revision: 355345 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Dec 2019 18:25:20 -0000 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/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) Changes in other areas also in this revision: 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) Modified: stable/12/libexec/Makefile ============================================================================== --- stable/12/libexec/Makefile Tue Dec 3 17:43:57 2019 (r355344) +++ stable/12/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/12/libexec/flua/Makefile ============================================================================== --- head/libexec/flua/Makefile Mon Nov 18 23:21:13 2019 (r354833) +++ stable/12/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/12/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/12/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(____) +____: + +.include + +# +# 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(____) Modified: stable/12/stand/common/interp_lua.c ============================================================================== --- stable/12/stand/common/interp_lua.c Tue Dec 3 17:43:57 2019 (r355344) +++ stable/12/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/12/stand/defs.mk ============================================================================== --- stable/12/stand/defs.mk Tue Dec 3 17:43:57 2019 (r355344) +++ stable/12/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/12/stand/liblua/Makefile ============================================================================== --- stable/12/stand/liblua/Makefile Tue Dec 3 17:43:57 2019 (r355344) +++ stable/12/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/12/stand/liblua/luaconf.h ============================================================================== --- stable/12/stand/liblua/luaconf.h Tue Dec 3 17:43:57 2019 (r355344) +++ stable/12/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/12/stand/loader.mk ============================================================================== --- stable/12/stand/loader.mk Tue Dec 3 17:43:57 2019 (r355344) +++ stable/12/stand/loader.mk Tue Dec 3 18:25:16 2019 (r355345) @@ -62,6 +62,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/12/stand/lua/Makefile ============================================================================== --- stable/12/stand/lua/Makefile Tue Dec 3 17:43:57 2019 (r355344) +++ stable/12/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 \