Fix for #1878. 'zig init-lib' on MacOS missing __mh_execute_header #1903
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.
This workaround is also found in the 'shared-library' example with a TODO to remove it. Hopefully this can be used as a quick fix so that new users don't run into an obscure error with init-lib. Apparently, libSystem doesn't define this symbol.
I think that the __mh_execute_header symbol is supposed to only be in actual executable files, however, during Zigs compilation of the init-lib/src/main.zig file on MacOS, the std/c/darwin.zig file declares this symbol as an external "C" symbol...then I think std/debug/index.zig uses this symbol to set up a base address and offset for debug info. The act of linking the .o file into a library is where 'init-lib' actually fails.
I assume that this symbol should not be used for .o files and should only be inserted/used when linking an executable and not a library?
I can look further into it if someone else doesn't know of a fix for this? :)