Skip to content

How to dynamically compile generated pieces of zig code? #9500

@trenta3

Description

@trenta3

Hi! Thank you very much for this wonderful project.
Is it currently possible to programmatically compile a string representing a snippet of zig code into executable code?
Something that can be written in the code below instead of the ???? to allow the compilation of the given source.

const compile = ????
const program_source =
    \\const std = @import("std");
    \\
    \\pub fn main() anyerror!void {
    \\    std.log.info("All your codebase are belong to us.", .{});
    \\}
;
const compiled_program = compile(program_source);

My aim is to write a metacompiler and the ability to delegate the compilation to machine code to zig would be great!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionNo questions on the issue tracker, please.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions