Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Oct 2025 18:10:36 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 80ada959004c - main - flua: kick out the remaining builtin modules
Message-ID:  <202510031810.593IAaNd008578@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=80ada959004c4386880e47b11618f8abfc2d80e1

commit 80ada959004c4386880e47b11618f8abfc2d80e1
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2025-10-03 18:09:04 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2025-10-03 18:09:25 +0000

    flua: kick out the remaining builtin modules
    
    Bootstrap flua has some magic now to handle modules by building them in
    and discovering them via linker sets.  This is slightly cleaner than
    always building them in and baking them into loadedlibs for both
    bootstrap and system flua.
    
    Adjust the stand build now that these three libs have their own new
    homes.
    
    Reviewed by:    bapt, emaste
    Differential Revision:  https://reviews.freebsd.org/D51891
---
 libexec/flua/Makefile                     | 4 +++-
 libexec/flua/lfbsd/Makefile               | 5 +++++
 libexec/flua/lfbsd/Makefile.inc           | 2 ++
 libexec/flua/{modules => lfbsd}/lfbsd.c   | 4 ++++
 libexec/flua/{modules => lfbsd}/lfbsd.h   | 0
 libexec/flua/lfs/Makefile                 | 5 +++++
 libexec/flua/lfs/Makefile.inc             | 2 ++
 libexec/flua/{modules => lfs}/lfs.c       | 7 ++++++-
 libexec/flua/{modules => lfs}/lfs.h       | 0
 libexec/flua/libhash/lhash.c              | 2 ++
 libexec/flua/linit_flua.c                 | 7 -------
 libexec/flua/lposix/Makefile              | 5 +++++
 libexec/flua/lposix/Makefile.inc          | 2 ++
 libexec/flua/{modules => lposix}/lposix.c | 5 +++++
 libexec/flua/{modules => lposix}/lposix.h | 0
 stand/liblua/Makefile                     | 2 +-
 stand/loader.mk                           | 2 +-
 17 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/libexec/flua/Makefile b/libexec/flua/Makefile
index 231abe5dafa2..b43b31298205 100644
--- a/libexec/flua/Makefile
+++ b/libexec/flua/Makefile
@@ -6,10 +6,13 @@
 # than mucking about with the infrastructure to make them linkable -- thus, why
 # these are all structured to have a Makefile that describes what we want
 # *installed*, and a Makefile.inc that describes what we need to *build*.
+FLUA_MODULES+=	lfbsd
+FLUA_MODULES+=	lfs
 FLUA_MODULES+=	libhash
 FLUA_MODULES+=	libjail
 FLUA_MODULES+=	libucl
 FLUA_MODULES+=	liblyaml
+FLUA_MODULES+=	lposix
 
 .ifdef BOOTSTRAPPING
 FLUA_MODULES+=	libfreebsd/sys/linker
@@ -47,7 +50,6 @@ SRCS+=	lua.c
 # FreeBSD Extensions
 .PATH: ${.CURDIR}/modules
 SRCS+=	linit_flua.c
-SRCS+=	lfs.c lposix.c lfbsd.c
 
 CFLAGS+=	-I${SRCTOP}/lib/liblua -I${.CURDIR}/modules -I${LUASRC}
 CFLAGS+=	-DLUA_PROGNAME="\"${PROG}\""
diff --git a/libexec/flua/lfbsd/Makefile b/libexec/flua/lfbsd/Makefile
new file mode 100644
index 000000000000..e2a4aae14bcd
--- /dev/null
+++ b/libexec/flua/lfbsd/Makefile
@@ -0,0 +1,5 @@
+SHLIB_NAME=	fbsd.so
+WARNS?=	3
+
+.include "Makefile.inc"
+.include <bsd.lib.mk>
diff --git a/libexec/flua/lfbsd/Makefile.inc b/libexec/flua/lfbsd/Makefile.inc
new file mode 100644
index 000000000000..7a78ef82e0fc
--- /dev/null
+++ b/libexec/flua/lfbsd/Makefile.inc
@@ -0,0 +1,2 @@
+.PATH:	${.PARSEDIR}
+SRCS+=	lfbsd.c
diff --git a/libexec/flua/modules/lfbsd.c b/libexec/flua/lfbsd/lfbsd.c
similarity index 99%
rename from libexec/flua/modules/lfbsd.c
rename to libexec/flua/lfbsd/lfbsd.c
index ef660ba9fd77..541b6c9611df 100644
--- a/libexec/flua/modules/lfbsd.c
+++ b/libexec/flua/lfbsd/lfbsd.c
@@ -40,6 +40,8 @@
 #include "lauxlib.h"
 #include "lfbsd.h"
 
+#include "bootstrap.h"
+
 #define	FBSD_PROCESSHANDLE	"fbsd_process_t*"
 
 struct fbsd_process {
@@ -283,3 +285,5 @@ luaopen_fbsd(lua_State *L)
 
 	return (1);
 }
+
+FLUA_MODULE(fbsd);
diff --git a/libexec/flua/modules/lfbsd.h b/libexec/flua/lfbsd/lfbsd.h
similarity index 100%
rename from libexec/flua/modules/lfbsd.h
rename to libexec/flua/lfbsd/lfbsd.h
diff --git a/libexec/flua/lfs/Makefile b/libexec/flua/lfs/Makefile
new file mode 100644
index 000000000000..3df83d6d2fc1
--- /dev/null
+++ b/libexec/flua/lfs/Makefile
@@ -0,0 +1,5 @@
+SHLIB_NAME=	lfs.so
+WARNS?=	3
+
+.include "Makefile.inc"
+.include <bsd.lib.mk>
diff --git a/libexec/flua/lfs/Makefile.inc b/libexec/flua/lfs/Makefile.inc
new file mode 100644
index 000000000000..9d40c42dc0e6
--- /dev/null
+++ b/libexec/flua/lfs/Makefile.inc
@@ -0,0 +1,2 @@
+.PATH:	${.PARSEDIR}
+SRCS+=	lfs.c
diff --git a/libexec/flua/modules/lfs.c b/libexec/flua/lfs/lfs.c
similarity index 99%
rename from libexec/flua/modules/lfs.c
rename to libexec/flua/lfs/lfs.c
index 8cb8d6fc9fed..517e16ae65c8 100644
--- a/libexec/flua/modules/lfs.c
+++ b/libexec/flua/lfs/lfs.c
@@ -66,9 +66,10 @@
 #ifdef _STANDALONE
 #include "lstd.h"
 #include "lutils.h"
-#include "bootstrap.h"
 #endif
 
+#include "bootstrap.h"
+
 #ifndef nitems
 #define	nitems(x)	(sizeof((x)) / sizeof((x)[0]))
 #endif
@@ -446,3 +447,7 @@ luaopen_lfs(lua_State *L)
 #endif
 	return 1;
 }
+
+#ifndef _STANDALONE
+FLUA_MODULE(lfs);
+#endif
diff --git a/libexec/flua/modules/lfs.h b/libexec/flua/lfs/lfs.h
similarity index 100%
rename from libexec/flua/modules/lfs.h
rename to libexec/flua/lfs/lfs.h
diff --git a/libexec/flua/libhash/lhash.c b/libexec/flua/libhash/lhash.c
index 7127ddc1d530..f455f006bf27 100644
--- a/libexec/flua/libhash/lhash.c
+++ b/libexec/flua/libhash/lhash.c
@@ -178,4 +178,6 @@ luaopen_hash(lua_State *L)
 	return 1;
 }
 
+#ifndef _STANDALONE
 FLUA_MODULE(hash);
+#endif
diff --git a/libexec/flua/linit_flua.c b/libexec/flua/linit_flua.c
index 027f1b305d09..161f030923d3 100644
--- a/libexec/flua/linit_flua.c
+++ b/libexec/flua/linit_flua.c
@@ -33,9 +33,6 @@
 
 #include "lualib.h"
 #include "lauxlib.h"
-#include "lfs.h"
-#include "lposix.h"
-#include "lfbsd.h"
 
 #include "bootstrap.h"
 
@@ -57,10 +54,6 @@ static const luaL_Reg loadedlibs[] = {
 #if defined(LUA_COMPAT_BITLIB)
   {LUA_BITLIBNAME, luaopen_bit32},
 #endif
-  /* FreeBSD Extensions */
-  {"lfs", luaopen_lfs},
-  {"posix", luaopen_posix},
-  {"fbsd", luaopen_fbsd},
   {NULL, NULL}
 };
 
diff --git a/libexec/flua/lposix/Makefile b/libexec/flua/lposix/Makefile
new file mode 100644
index 000000000000..92321d51be9a
--- /dev/null
+++ b/libexec/flua/lposix/Makefile
@@ -0,0 +1,5 @@
+SHLIB_NAME=	posix.so
+WARNS?=	3
+
+.include "Makefile.inc"
+.include <bsd.lib.mk>
diff --git a/libexec/flua/lposix/Makefile.inc b/libexec/flua/lposix/Makefile.inc
new file mode 100644
index 000000000000..499e6779e84d
--- /dev/null
+++ b/libexec/flua/lposix/Makefile.inc
@@ -0,0 +1,2 @@
+.PATH:	${.PARSEDIR}
+SRCS+=	lposix.c
diff --git a/libexec/flua/modules/lposix.c b/libexec/flua/lposix/lposix.c
similarity index 99%
rename from libexec/flua/modules/lposix.c
rename to libexec/flua/lposix/lposix.c
index 75cdd345aeaa..430bb6f28baf 100644
--- a/libexec/flua/modules/lposix.c
+++ b/libexec/flua/lposix/lposix.c
@@ -21,6 +21,8 @@
 #include "lauxlib.h"
 #include "lposix.h"
 
+#include "bootstrap.h"
+
 static void
 enforce_max_args(lua_State *L, int max)
 {
@@ -697,3 +699,6 @@ luaopen_posix(lua_State *L)
 
 	return (1);
 }
+
+/* Only this one needed in our bootstrap set, it will load the others. */
+FLUA_MODULE(posix);
diff --git a/libexec/flua/modules/lposix.h b/libexec/flua/lposix/lposix.h
similarity index 100%
rename from libexec/flua/modules/lposix.h
rename to libexec/flua/lposix/lposix.h
diff --git a/stand/liblua/Makefile b/stand/liblua/Makefile
index ce7eb89fe494..b1c34ec0a466 100644
--- a/stand/liblua/Makefile
+++ b/stand/liblua/Makefile
@@ -24,7 +24,7 @@ SRCS+=	lauxlib.c lbaselib.c lstrlib.c loadlib.c
 SRCS+=	lerrno.c lpager.c lstd.c lutils.c
 SRCS+=	gfx_utils.c
 
-.PATH:	${FLUASRC}/modules
+.PATH:	${FLUASRC}/lfs
 SRCS+=	lfs.c
 .PATH:	${FLUALIB}/libhash
 SRCS+=	lhash.c
diff --git a/stand/loader.mk b/stand/loader.mk
index 4073e523e552..e26ba1401912 100644
--- a/stand/loader.mk
+++ b/stand/loader.mk
@@ -89,7 +89,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
+CFLAGS.interp_lua.c= -DLUA_PATH=\"${LUAPATH}\" -I${FLUASRC}/lfs
 .elif ${LOADER_INTERP} == "4th"
 SRCS+=	interp_forth.c
 .include "${BOOTSRC}/ficl.mk"



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