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_overflowThe 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
|
This pull request has been mentioned on Crystal Forum. There might be relevant details there: https://forum.crystal-lang.org/t/compiling-shared-libraries/8358/3 |
|
This pull request has been mentioned on Crystal Forum. There might be relevant details there: https://forum.crystal-lang.org/t/generate-a-library-and-load-it/7570/6 |
Unlike the usual
funfor 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