ref: 518cfe8d0c1a6eb4f90cdb68861fe0cd3a2e0d74
parent: f51ee8f9575d4eb6e8a58a61ff0e2e92092cbb1c
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Fri Jan 17 22:17:42 EST 2025
m68k macos: fix --gc-sections The reason was computed goto labels. Because those end up in data section but have to reference text section (duh) it got Elf2Mac pretty confused. Workaround by forcing the computed goto jump table into a text section. Apparently that helps.
--- a/cross/m68-apple.txt
+++ b/cross/m68-apple.txt
@@ -5,8 +5,8 @@
cpuflags = ['-march=68020', '-mtune=68020-40']
[built-in options]
-c_args = cpuflags + ['-fdata-sections', '-ffunction-sections', '-D__macos__']
-c_link_args = cpuflags + ['-Wl,--mac-single', '-Wl,--mac-strip-macsbug']
+c_args = cpuflags + ['-fdata-sections', '-ffunction-sections', '-D__macos__', '-DNDEBUG']
+c_link_args = cpuflags + ['-Wl,--gc-sections,--mac-strip-macsbug']
cpp_args = c_args
cpp_link_args = c_link_args
--- a/cross/powerpc-apple.txt
+++ b/cross/powerpc-apple.txt
@@ -4,7 +4,7 @@
prefix = path + 'powerpc-apple-macos-'
[built-in options]
-c_args = ['-fdata-sections', '-ffunction-sections', '-D__macos__']
+c_args = ['-fdata-sections', '-ffunction-sections', '-D__macos__', '-DNDEBUG']
cpp_link_args = ['-Wl,-gc-sections']
[properties]
--- a/flisp.c
+++ b/flisp.c
@@ -912,7 +912,15 @@
#if defined(COMPUTED_GOTO)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
- static const void *ops[] = {
+#if defined(__macos__) && defined(__m68k__)
+ /*
+ * Why the specific section? Because Elf2Mac is not happy otherwise,
+ * Trying to deal with data referencing text section.
+ * This solves the problem once and for all.
+ */
+ __attribute__((section(".text.vm.ops")))
+#endif
+ static const void * const ops[] = {
#define GOTO_OP_OFFSET(op) [op] = &&op_##op
#include "vm_goto.inc"
#undef GOTO_OP_OFFSET