Open Ivan-Velickovic opened 1 year ago
Actually, it's not the macro options that are being cached, it's (I assume) to do with how incbin
takes in the same filename and so the object isn't re-compiled.
A smaller example of the bug can be done with having this in embed_file.S
instead:
.section .embedded_file, "aw", @progbits
.incbin "test.txt"
and using just zig cc -c embed_file.S
.
Would anyone be able to help me solve this bug? If it's quite non-trivial I can wait for someone familiar with the Zig compiler to fix it, but if someone's willing to give me some pointers as to what could be going wrong and where, I'd be happy to give it a shot.
Zig learns about the transitive dependencies of files given to Clang, including C and asm files, by passing dep file arguments:
If the embedded file is missing from this file, then it is a clang bug and the next step is to file a report on that project.
Great, thank you. I will do some digging then.
I believe the reason out_dep_path
is null is from the call here https://github.com/ziglang/zig/blob/956f53beb09c07925970453d4c178c6feb53ba70/src/Compilation.zig#L4604 where clangSupportsDepFile
will return false since it's an assembly file.
I guess it is a bug with Clang then.
Looks like there is already an open issue https://github.com/llvm/llvm-project/issues/54996.
While we wait for an upstream fix, is there a workaround that we could use in build.zig
?
Zig Version
0.12.0-dev.152+411462e1c
Steps to Reproduce and Observed Behavior
Create a file called
embed_file.S
with this contents:Create a file called
test.txt
with this contents:Compile:
Observe the hash of the object file:
Change the contents of
test.txt
and recompile, you will observe thatsha256sum
produces the same hash, indicating that the object file has not changed, despite the contents oftest.txt
changing.For context, I ran into this issue when embedded artifacts/other files in a C program and saw that when I updated the artifacts, the final ELF that was executing and using the artifacts did not update.
For now, I can remove the global Zig cache
rm -r ~/.cache/zig
and I get the behaviour I expect.Expected Behavior
That when re-compiling with the contents of
test.txt
changed, that the object file is actually recompiled instead of the cached object file being used.Thanks!