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

Is AOT compilation supported/planned? #99

Open
fwip opened this issue Mar 2, 2023 · 2 comments
Open

Is AOT compilation supported/planned? #99

fwip opened this issue Mar 2, 2023 · 2 comments

Comments

@fwip
Copy link

fwip commented Mar 2, 2023

If possible, I'd like to pre-compile frawk scripts to binary executables. This would make it easier for me to distribute the scripts I've written to places where it is difficult for me to get frawk installed. I've previously used awka, but it can be a little tough to get compiling and doesn't have as many nice features as frawk.

I've used frawk --dump-llvm to get LLVM IR for a given awk script, but I'm not sure if there's an easy way to get from here to a binary I can distribute - it looks like the generated IR still relies on the frawk runtime.

@ezrosent
Copy link
Owner

ezrosent commented Mar 4, 2023

You're right about the --dump-llvm command not giving you runnable LLVM on its own. The LLVM frawk generates both relies on a runtime pointer being passed in and includes pointers to frawk's heap for string literals. frawk also generates different code based on the value of command-line flags.

The "simple" version of compiling frawk scripts ahead of time by simply packaging up a pre-built frawk and running it with the script could be annoying but doable. The issue there is that frawk will often try and use machine-specific instructions, so compiling on the source machine really can help performance.

The nicer, more awka-esque model would be for frawk to generate a small binary customized to a specific script would be a good deal harder. frawk would have to avoid some of its "tricks" around allocations, and more fundamentally we would have to split the runtime out into its own crate and link in its (say) LLVM with the awk program. That's something that would require a good deal more effort, though it's not impossible. I'm afraid it's unlikely that I'd get to it any time soon.

@jemma-nelson
Copy link

Thank for the reply and clear explanation!

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

No branches or pull requests

3 participants