Re: Rust: kernel vs user-space

From: Steffen Nurpmeso <steffen_at_sdaoden.eu>
Date: Wed, 04 Sep 2024 23:59:15 UTC
Konstantin Belousov wrote in
 <ZtjVms7FdYTWCe_U@kib.kiev.ua>:
 |On Wed, Sep 04, 2024 at 06:42:37PM +0200, Stefan Esser wrote:
 |> Am 04.09.24 um 17:21 schrieb Bob Bishop:
 |>>> On 4 Sep 2024, at 15:37, Stefan Esser <se@FreeBSD.org> wrote:
 |>>> Am 04.09.24 um 11:52 schrieb Mark Delany:
 |>>>> On 04Sep24, David Chisnall apparently wrote:
 |>>>>> There are lots of control-plane things that I'd love to see
 |>>>>> written mostly in Lua,
 |>>>> It was remiss of me to not mention Lua given that it's already \
 |>>>> in the project.
 ...
 |>>> Here is ldconfig in LUA, written more than 2 years ago, for example:
 |>>> 
 |>>> https://github.com/stesser/ldconfig/blob/main/ldconfig.lua
 ...
 |The ldconfig utility is critical to fully configured multiuser FreeBSD
 |state.  Right now the utility depends on rtld and libc (ignoring the
 |whole stuff at and below kernel).  So any problem in either of rtld or
 |libc which prevent ldconfig from run are critical.
 |
 |If rewritten in LUA, the utility has the same dependencies on rtld and
 |libc, plus LUA runtime.  Which, by itself, bring in
 |/usr/libexec/flua:
 |        libm.so.5 => /lib/libm.so.5 (0x8010b1000)
 |        libedit.so.8 => /lib/libedit.so.8 (0x8010ed000)
 |        libprivateucl.so.1 => /usr/lib/libprivateucl.so.1 (0x801129000)
 |        libc.so.7 => /lib/libc.so.7 (0x80114f000)
 |        libtinfow.so.9 => /lib/libtinfow.so.9 (0x801552000)
 |i.e. libm, terminfo, ucl (?), libedit.  Then, flua runtime lives in /usr,
 |while ldconfig is reasonably located in /sbin.
 |
 |There are other considerations than just the language accessibility when
 |we consider the whole system.

Compared to monsters like clang/llvm FreeBSD *could* very well
include two lua binaries in maybe half a megabyte.
For Linux lua includes two make targets, as i learned just now.

  FreeBSD NetBSD OpenBSD freebsd:
          $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE -I/usr/include/edit" SYSLIBS="-Wl,-E -ledit" CC="cc"
  ...
  Linux linux:    linux-noreadline

  linux-noreadline:
          $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl"

  linux-readline:
          $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE" SYSLIBS="-Wl,-E -ldl -lreadline"

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)