Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

files with shebang fail to run #19

Open
Frityet opened this issue Jul 4, 2024 · 6 comments · May be fixed by #20
Open

files with shebang fail to run #19

Frityet opened this issue Jul 4, 2024 · 6 comments · May be fixed by #20

Comments

@Frityet
Copy link
Contributor

Frityet commented Jul 4, 2024

file:

#!/usr/bin/env lua

print "Hello"

Will fail at runtime, with syntax error in bundled source code.. Using #18 I can see the error is

[string "AOT Compiled module "test""]:1: unexpected symbol near '#'.

Removing the shebang fixes the issue.

@Frityet
Copy link
Contributor Author

Frityet commented Jul 4, 2024

Why is LUAOT_MODULE_SOURCE_CODE not precompiled with luac? It would fix the issue, unless theres a good reason its omitted. Im gonna try to see what precompiling would do...

@Frityet
Copy link
Contributor Author

Frityet commented Jul 5, 2024

Works great, slightly bigger binaries though (~10k?)

@Frityet Frityet linked a pull request Jul 5, 2024 that will close this issue
@hugomg
Copy link
Owner

hugomg commented Jul 5, 2024

Why is LUAOT_MODULE_SOURCE_CODE not precompiled with luac?

No particular reason. Keeping it as Lua source was easy to implement.

@Frityet
Copy link
Contributor Author

Frityet commented Jul 5, 2024

Why is LUAOT_MODULE_SOURCE_CODE not precompiled with luac?

No particular reason. Keeping it as Lua source was easy to implement.

is keeping the lua source within the binary necessary? im not too familiar with how it works, but wouldnt you have a much smaller binary without it?

@hugomg
Copy link
Owner

hugomg commented Jul 5, 2024

Lua has two kinds of function under the hood: C closures, and Lua closures. Counterintuitively, the luaaot functions are actually Lua closures. The easiest way to build those Lua Closure objects is to use loadstring to compile from source, or from bytecode.

@Frityet
Copy link
Contributor Author

Frityet commented Jul 5, 2024

Oh I see, thats intresting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants