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

Implement compile subcommand. #50

Merged
merged 1 commit into from
Jan 24, 2024
Merged

Implement compile subcommand. #50

merged 1 commit into from
Jan 24, 2024

Conversation

krk
Copy link
Contributor

@krk krk commented Dec 9, 2023

Compile JS to bytecode and compress with zstd using the embedded dictionary.

There is no compatibility guarantee of lrt files, they can be executed by the llrt version that created them.

❯ target/release/llrt -h
LLRT (linux x64) 0.1.3-beta


Usage:
  llrt <filename>
  llrt -v | --version
  llrt -h | --help
  llrt -e | --eval <source>
  llrt compile input.js [output.lrt]
  llrt test <test_args>

Options:
  -v, --version     Print version information
  -h, --help        Print this help message
  -e, --eval        Evaluate the provided source code
  compile           Compile JS to bytecode and compress it with zstd:
                      if [output.lrt] is omitted, <input>.lrt is used.
                      lrt file is expected to be executed by the llrt version
                      that created it
  test              Run tests with provided arguments:
                      <test_args> -d <directory> <test-filter>

❯ target/release/llrt compile
compile: input filename is required.

❯ target/release/llrt compile fixtures/hello.js
❯ target/release/llrt fixtures/hello.lrt
hello world!

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@richarddavison
Copy link
Contributor

LGTM!

@krk
Copy link
Contributor Author

krk commented Dec 11, 2023

Thanks! Added tests.

@richarddavison
Copy link
Contributor

richarddavison commented Dec 18, 2023

@krk looks like Linux ARM compile segfaults. Can you take a look?
Edit: There might also be something funky in test runner (unrelated to this) since it ran for 6 hours...

@krk krk force-pushed the compile branch 3 times, most recently from aaaef77 to 5f1c43d Compare January 24, 2024 12:50
Compile JS to bytecode and compress with zstd using the embedded
dictionary.

There is no compatibility guarantee of lrt files, they can be executed
by the llrt version that created them.
let units = ["B", "kB", "MB", "GB", "TB", "PB"];
format!("{:.3} {}", size, units[i as usize])
}
include!("src/compiler-common.rs");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use a mod here and include! from build.rs?

@richarddavison richarddavison merged commit 10e5cac into awslabs:main Jan 24, 2024
5 checks passed
@richarddavison richarddavison deleted the compile branch January 24, 2024 16:18
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.

2 participants