Skip to content

Add -b and -g, for creating bytecode before compile#20

Open
Frityet wants to merge 1 commit intohugomg:masterfrom
Frityet:luac-src-code
Open

Add -b and -g, for creating bytecode before compile#20
Frityet wants to merge 1 commit intohugomg:masterfrom
Frityet:luac-src-code

Conversation

@Frityet
Copy link
Copy Markdown
Contributor

@Frityet Frityet commented Jul 5, 2024

Fixes #19

@hugomg
Copy link
Copy Markdown
Owner

hugomg commented Jul 5, 2024

I would have hoped that compiling to bytecode would reduce the binary size. Since it doesn't, maybe it would be simpler to just strip the shebangs from the source string?

@Frityet
Copy link
Copy Markdown
Contributor Author

Frityet commented Jul 25, 2024

I would have hoped that compiling to bytecode would reduce the binary size

it does sometimes, ive had much much better binary sizes with larger files. Another good reason to use bytecode is obsufication. With the string you can get the full lua source which could be not desired.

Comment thread README.md
```

### `-b`, `-g`
`-b` precompiles the lua source into bytecode before including it in the binary. By default, it strips symbols from the bytecode, but you can keep symbols with `-g`:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wouldn't hurt to say that -b saves space for large files

Comment thread src/luaot.c
int bytecode_writer(lua_State *L, const void *p, size_t sz, void *ud)
{
(void)L;
luaL_Buffer *b = (luaL_Buffer *)ud;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In C, we don't need to write an explicit cast for a void*. I think it would suffice to say

luaL_Buffer *b = ud;

Also, I think we can also add a line for

 const char *bytes = p

(I expect that we don't need to say "unsigned")

Copy link
Copy Markdown
Contributor Author

@Frityet Frityet Jul 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In C, we don't need to write an explicit cast for a void*. I think it would suffice to say

yeah that was a holdover when I had my own struct, accident! Thanks.

Also, I think we can also add a line for

Will do

Comment thread src/luaot.c
if (precompile)
print_source_code_bytecode(L);
else
print_source_code_source(L);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use braces around the if/else bodies.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

@hugomg
Copy link
Copy Markdown
Owner

hugomg commented Jul 25, 2024

Also, could you please tell some more about your experience with -b and -g?

  • How much space did -b save on larger files?
  • How much space did -g save?
  • Is it ok to strip debug info by default? Does it affect the stack traces?

@Frityet
Copy link
Copy Markdown
Contributor Author

Frityet commented Jul 26, 2024

Also, could you please tell some more about your experience with -b and -g?

* How much space did -b save on larger files?

* How much space did -g save?

* Is it ok to strip debug info by default? Does it affect the stack traces?

ill show benchmarks, give me a couple of days

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 this pull request may close these issues.

files with shebang fail to run

2 participants