CDSoft / luax

luax is a Lua interpreter and REPL based on Lua 5.4, augmented with some useful packages. It is also a "compiler" that produces standalone executables from Lua scripts.
https://cdelord.fr/luax
GNU General Public License v3.0
157 stars 9 forks source link

running bootstrap.sh fails #4

Open bentxt opened 3 weeks ago

bentxt commented 3 weeks ago

hi I try to install Luax on my mac (macos 14.5 ), here are the errors I get when running ./bootstrap.sh. Looks like something isn't found in my PATH


sh ./bootstrap.sh
    no file 'tools/bang.luax' in '.'
    no file 'tools/bang.luax' in 'tools'
    no file 'tools/bang.luax' in '~/build/lobster/bin'
    no file 'tools/bang.luax' in '/Users/ben/go/bin'
    no file 'tools/bang.luax' in '/Applications/Racket v8.12/bin'
    no file 'tools/bang.luax' in '/Users/ben/.cargo/bin'
    no file 'tools/bang.luax' in '/Users/ben/build/bin'
    no file 'tools/bang.luax' in '/Users/ben/.local/bin'
    no file 'tools/bang.luax' in '/Users/ben/.bin'
    no file 'tools/bang.luax' in '/Users/ben/local/bin'
    no file 'tools/bang.luax' in '/opt/local/sbin'
    no file 'tools/bang.luax' in '/opt/local/bin'
    no file 'tools/bang.luax' in '/usr/local/bin'
    no file 'tools/bang.luax' in '/usr/local/sbin'
    no file 'tools/bang.luax' in '/usr/sbin'
    no file 'tools/bang.luax' in '/bin'
    no file 'tools/bang.luax' in '/sbin'
    no file 'tools/bang.luax' in '/usr/bin'
CDSoft commented 3 weeks ago

Hello,

I think the problem is the stat command in macos, its output may differ from linux.

Could you please run these commands:

I previously had to use gstat on macos since the stat command does not work as on linux. You can also check that gstat is installed (the error message could be more explicit...)

CDSoft commented 3 weeks ago

I'm afraid that installing gstat won't be enough and some other commands may fail when building luax on non linux OS. In this case, you can download binaries from https://cdelord.fr/pub#luax-light

_fs.lua should be rewritten to handle the case of macos (well, my assumption that macos is like linux is obviously wrong...)

CDSoft commented 3 weeks ago

Can you try to build the dev branch? It has been modified to use the default stat command of macos.

bentxt commented 3 weeks ago

Can you try to build the dev branch? It has been modified to use the default stat command of macos.

luax (dev)> sh ./bootstrap.sh .build/boot/lua: libluax/fs/_fs.lua:137: attempt to call a nil value (method 'unwords') stack traceback: libluax/fs/_fs.lua:137: in function <libluax/fs/_fs.lua:131> (...tail calls...) libluax/fs/_fs.lua:350: in function '_fs.is_file' luax/luax_cmd_run.lua:380: in local 'findscript' luax/luax_cmd_run.lua:390: in function <luax/luax_cmd_run.lua:366> (...tail calls...) libluax/F/F.lua:2402: in function 'F.foreach' luax/luax_cmd_run.lua:64: in method 'run' luax/luax_cmd_run.lua:462: in main chunk [C]: in function 'require' luax/luax.lua:28: in function <luax/luax.lua:26> (...tail calls...) [C]: in upvalue 'func' libluax/package/package_hook.lua:69: in function 'dofile' tools/luax.lua:52: in main chunk [C]: in ?

bentxt commented 3 weeks ago
  • LC_ALL=C gstat tools/bang.luax
  • LC_ALL=C gstat -c '%s;%Y;%X;%W;%F;%f' tools/bang.luax
  • LC_ALL=C stat tools/bang.luax
  • LC_ALL=C stat -c '%s;%Y;%X;%W;%F;%f' tools/bang.luax

From all those commands this is the only one that yields no errors

LC_ALL=C stat tools/bang.luax

CDSoft commented 3 weeks ago

oops, the new dev branch should work better...

bentxt commented 3 weeks ago

yes, thank you, now it worked and I now have a functioning luax binary under

.build/dist/macos-x86_64/bin/luax

really cool!

just a note: it created also the artefacts for the other platforms (linux and windows), this is not really needed, I think most users just want their binary native to the host platform

CDSoft commented 3 weeks ago

Thanks for testing ;-)

If you just want to compile LuaX for the host you can just run ./bootstrap.sh clang. It requires clang and will just compile luax without cross-compilation capabilities.

bentxt commented 3 weeks ago

Thanks for testing ;-)

If you just want to compile LuaX for the host you can just run ./bootstrap.sh clang. It requires clang and will just compile luax without cross-compilation capabilities.

Ok, I've tried that but somehow I get errors:

./bootstrap.sh clang
[69/161] CC libluax/F/F.c
FAILED: .build/tmp/macos-x86_64/obj/libluax/F/F.o
clang -c -std=gnu2x -O3 -pipe -fPIC -I. -I.build/tmp -Ilua -Iext/c/lz4/lib -Iext/c/lzlib/lib -Iext/c/lzlib/lib/inc -Ilibluax -Werror -Wall -Wextra -pedantic -Wstrict-prototypes -Wmissing-field-initializers -Wmissing-prototypes -Wmissing-declarations -Werror=switch-enum -Werror=implicit-fallthrough -Werror=missing-prototypes -Weverything -Wno-padded -Wno-reserved-identifier -Wno-disabled-macro-expansion -Wno-used-but-marked-unused -Wno-documentation-unknown-command -Wno-declaration-after-statement -Wno-unsafe-buffer-usage -Wno-pre-c2x-compat -DLUA_USE_MACOSX -DLUAX_ARCH='"x86_64"' -DLUAX_OS='"macos"' -DLUAX_LIBC='"none"' -DLUAX_EXE='""' -DLUAX_SO='".dylib"' -DLUAX_NAME='"macos-x86_64"' -MD -MF .build/tmp/macos-x86_64/obj/libluax/F/F.o.d libluax/F/F.c -o .build/tmp/macos-x86_64/obj/libluax/F/F.o
error: unknown warning option '-Wno-reserved-identifier'; did you mean '-Wno-reserved-id-macro'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-unsafe-buffer-usage'; did you mean '-Wno-frame-larger-than='? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-pre-c2x-compat' [-Werror,-Wunknown-warning-option]
[72/161] CC libluax/complex/complex.c
....
CDSoft commented 3 weeks ago

You may have an older version of clang. You can try to compile without strict compiler checks with ./bootstrap.sh clang lax (warnings will be ignored)

KernelKinetic commented 2 weeks ago

I'm glad bootstrap.sh is now working on macOS, thank you. To make ninja build also working on macOS you need to change https://github.com/CDSoft/luax/blob/2dad970cea10f20377861c55f46d75d5387b68b4/tools/bang.luax#L1048 to command = { "install", "$in", "$${PREFIX:-$prefix}"/target_name },.

CDSoft commented 2 weeks ago

@KernelKinetic Thanks, I've fixed bang and luax to be able to install files on macos.

KernelKinetic commented 2 weeks ago

Thank you, works perfectly. Also thank you for your work in luax, nice tool!