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

Zig issues / feature improvements affecting Acton (tracking issue) #1603

Open
plajjan opened this issue Dec 11, 2023 · 0 comments
Open

Zig issues / feature improvements affecting Acton (tracking issue) #1603

plajjan opened this issue Dec 11, 2023 · 0 comments

Comments

@plajjan
Copy link
Contributor

plajjan commented Dec 11, 2023

Our wish list for the upstream Zig project.

The primary use of Zig is as the low level build system for Acton. The Acton compiler reads .act files and outputs C code. We use build.zig to compile that C code to libraries / executable binaries. It links with a number of C libraries shipped with the Acton base system (builtins, run time systems etc depends on things like libuv, Boehm GC ect).

One day we might very well output Zig code instead of C from the Acton compiler but that probably requires Zig to mature a bit first.

A bit of background on Acton use of Zig

Acton projects are arranged as a Zig project with a conceptual build.zig. Since all Acton projects follow a common form, the build.zig is actually built into an executable binary ahead of time and shipped together with the acton compiler. Thus you won't find the actual build.zig in an Acton project. We call our compiled build.zig builder. Once actonc (the Acton compiler) has outputted C files, actonc will invoke builder, providing some arguments and point to the correct folder to work in. Most dynamic things, like the list of C files, are discovered by builder by crawling the file system (actonc writes C files to e.g. out/types/foo.c in the acton project folder).

All Acton projects consist of sources from at least two locations:

  • the local project
  • acton base, e.g. builtins, stdlib, RTS

builder supports two "modes" of compilation, one based on prebuilt libraries and the other is building from source.

Completed items

  • install headers alongside artifact so they can be accessed in same way std.Build: fix Compile.installHeader behavior, add WriteFile.addCopyDirectory ziglang/zig#19167
    • this is required to fix compilation of some of our external C libraries
    • like libuuid has src/uuid.h which is copied to include/uuid/uuid.h on build
    • our code expects to #include <uuid/uuid.h> and so libuuid must be built and installed
    • with this PR, we don't need to build&install libuuid but can just list it as a build.zig dependency
    • this in turn enables us to only ship the source code in the Acton distribution and let the full build happen when the user invokes acton build the first time, very cool!
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

1 participant