-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Set linkage of __crystal_*
funs to internal
#15439
Set linkage of __crystal_*
funs to internal
#15439
Conversation
When compiling to a single module we can set the `__crystal_main` function linkage to internal.
…e module Unlike the usual fun that create a non mangled symbols, and is usually expected to have external linkage, the `__crystal_*` funs are an internal implementation detail to abstract calls to stdlib from the codegen pass (e.g. `__crystal_once`, `__crystal_raise`, ...). We should compile them to be internal when compiling to a single module.
Interesting, darwin fails to link, for aarch64 and x86_64 alike:
All symbols are declared in the |
$ nm ~/.cache/crystal/Users-runner-work-crystal-crystal-spec-std-data-collect_within_ensure/_main.o3.o | grep __crystal
0000000000000000 t ___crystal_main
0000000000000cb8 t ___crystal_personality
00000000000011dc t ___crystal_raise
0000000000001224 t ___crystal_raise_overflow The symbol is in the object file, with internal linkage |
That seems to be a bug in macos Is macos ruining support for #921? Yes. Apparently it would only work with |
Since we use internal linkage for all defs, it might just be a bug with the personality function? 🤔 Confirmed: not making I fail to link using
I notice that clang-11 injected |
That SO question is also about a personality function. So perhaps it's related to some quirk of exception handling on macos? |
e615ba8
to
1938467
Compare
Yeah, it seems that personalities functions are an issue in mach-o in general: Notably: |
__crystal_*
fun__crystal_*
funs to internal
Unlike the usual
fun
for which we might expect to have external linkage, the__crystal_*
funs are an internal implementation detail to abstract calls to stdlib from the codegen pass (e.g.__crystal_once
,__crystal_raise
, ...).When compiling to a single module, we can mark them to have internal linkage, so they're only considered inside the object file. We already do that for all globals and
def
.Related to #921