From 32de906f6d8d76e8ad0ce663c34b23760b05d809 Mon Sep 17 00:00:00 2001 From: Damian Gryski Date: Sun, 5 Sep 2021 17:32:00 -0700 Subject: [PATCH] internal/task, runtime: add subsections_via_symbols to assembly files on darwin This allows the assembly routines in these files to be stripped as dead code if they're not referenced. This solves the link issues on MacOS when the `leaking` garbage collector or the `coroutines` scheduler are selected. Fixes #2081 --- src/internal/task/task_stack_amd64.S | 5 +++++ src/runtime/gc_amd64.S | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/internal/task/task_stack_amd64.S b/src/internal/task/task_stack_amd64.S index 44b5f065..f9182d49 100644 --- a/src/internal/task/task_stack_amd64.S +++ b/src/internal/task/task_stack_amd64.S @@ -72,3 +72,8 @@ tinygo_swapTask: // Return into the new task, as if tinygo_swapTask was a regular call. ret + +#ifdef __MACH__ // Darwin +// allow these symbols to stripped as dead code +.subsections_via_symbols +#endif diff --git a/src/runtime/gc_amd64.S b/src/runtime/gc_amd64.S index fa89479f..c0ad7bc8 100644 --- a/src/runtime/gc_amd64.S +++ b/src/runtime/gc_amd64.S @@ -27,3 +27,8 @@ _tinygo_scanCurrentStack: // were only pushed to be discoverable by the GC. addq $56, %rsp retq + +#ifdef __MACH__ // Darwin +// allow these symbols to stripped as dead code +.subsections_via_symbols +#endif