Skip to content

move zig.h to become an installation file that can be changed at runtime #11643

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

Closed
andrewrk opened this issue May 13, 2022 · 3 comments · Fixed by #12253
Closed

move zig.h to become an installation file that can be changed at runtime #11643

andrewrk opened this issue May 13, 2022 · 3 comments · Fixed by #12253
Labels
backend-c The C backend (CBE) outputs C source code. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@andrewrk
Copy link
Member

Currently zig.h is embedded into the zig binary like this:

pub const zig_h = @embedFile("C/zig.h");

However, I think it would be more flexible and useful to be able to edit this file without needing to rebuild the compiler.

  • figure out a place to put it within lib/
  • integrate with the caching system
  • load at runtime instead of @embedFile
@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. frontend Tokenization, parsing, AstGen, Sema, and Liveness. backend-c The C backend (CBE) outputs C source code. labels May 13, 2022
@andrewrk andrewrk added this to the 0.11.0 milestone May 13, 2022
@andrewrk andrewrk added the contributor friendly This issue is limited in scope and/or knowledge of Zig internals. label May 13, 2022
@matu3ba
Copy link
Contributor

matu3ba commented Jun 9, 2022

I am looking into this out of personal curiosity how the caching system works. I should have something working until 18./19. June.
got the part of how the Zig cache works: https://gist.github.com/matu3ba/92e5df1166c51b3725dbd04f7ff1cb4e, next is to get the details and implement it.

@matu3ba
Copy link
Contributor

matu3ba commented Jun 11, 2022

So far only the Zir of the Zig source file and builtin.zig of a file with c backend (-ofmt=c) are cached into the local cache.
Besides that, 447 files are added to the global cache into z/ (Zir files).
(Tested with #11849 and nuking local and global cache)

Can you be more specific how you expect things to be cached?

APPENDUM: The approach is relative straight forward with using the stuff in cmdTranslateC() in main.zig and adding things like in src/glibc.zig.

@nektro
Copy link
Contributor

nektro commented Jun 12, 2022

it would be part of the global cache, he said he wanted it put inside lib/

andrewrk added a commit that referenced this issue Jul 27, 2022
Now instead of zig.h being baked into the compiler binary, it is a
header file distributed along with all the other header files
distributed with Zig.

Closes #11643
andrewrk added a commit that referenced this issue Jul 27, 2022
Now instead of zig.h being baked into the compiler binary, it is a
header file distributed along with all the other header files
distributed with Zig.

Closes #11643
@andrewrk andrewrk modified the milestones: 0.11.0, 0.10.0 Jul 27, 2022
andrewrk added a commit that referenced this issue Jul 27, 2022
Now instead of zig.h being baked into the compiler binary, it is a
header file distributed along with all the other header files
distributed with Zig.

Closes #11643
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend-c The C backend (CBE) outputs C source code. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants