Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As @topolarity noticed, sometimes the LLVM backend lowers types in a way that do not have an LLVM ABI size that matches the Zig ABI size. This is essentially unwanted undefined behavior whenever it occurs.
This branch has a mechanism to detect when this occurs and log about it in a debug build of the compiler. I have it disabled in the very last commit because there are more instances to fix before turning it on. However this branch already fixes two instances, one in optional types and one in error unions. Both are fixed by adding padding bytes at the end.
Note that we never call
LLVMABISizeOfType
because this fails when lowering types that reference pointers of themselves. Rather than work around this, it is much simpler for Zig to compute the padding itself and add it unconditionally.Current Status of Audit
Behavior tests cause many messages to be emitted and I do not have those listed here.
However here are the messages for building stage3, in the hopes that this branch could solve #11450:
Finally the logging causes a crash because a type did not properly get
resolveTypeFully
called before it was sent to the linker for lowering: