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

compiler: enable caching for -femit-h #14606

Closed
wants to merge 1 commit into from

Conversation

perillo
Copy link
Contributor

@perillo perillo commented Feb 9, 2023

As documented in #14416, when using zig build-lib -femit-h with caching enabled, if the generated header file is removed, it will not be generated again, unless the library source code is modified.

For consistent builds with zig build, assume that the file generated by -femit using the default path is an artificact, and update src/main.zig to enable caching.

Update the flushEmitH function in src/link/C.zig to use the zig_cache_artifact_directory instead of the incorrect local_cache_directory.

Updates #14416

As documented in ziglang#14416, when using `zig build-lib -femit-h` with
caching enabled, if the generated header file is removed, it will not
be generated again, unless the library source code is modified.

For consistent builds with `zig build`, assume that the file generated
by -femit using the default path is an artificact, and update
src/main.zig to enable caching.

Update the flushEmitH function in src/link/C.zig to use the
zig_cache_artifact_directory instead of the incorrect
local_cache_directory.

Updates ziglang#14416
@perillo
Copy link
Contributor Author

perillo commented Feb 9, 2023

-femit-asm, femit-llvm-ir and -femit-llvm-ar are in a similar situation as -femit-h since support for caching is available (see https://github.com/ziglang/zig/blob/d24ebf1d1/src/codegen/llvm.zig#L570 and https://github.com/ziglang/zig/blob/d24ebf1d1/src/codegen/llvm.zig#L763) but caching is not enabled.

Also, there is not test case, since I noticed that there are currently no test cases in cli.zig that tests the -femit flags.
However a standalone test is available in #14576.

@andrewrk
Copy link
Member

This PR depends on #9698. Let's revisit this once that issue is resolved.

@andrewrk andrewrk closed this Oct 18, 2023
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