note: the recipies here are not necessarily the right thing to do. Some adjustments may break building for other archs or CPUs. It's a log of what was needed so I don't forget, and hopefully get to do it correctly eventually.

/etc/mk.conf:

.if ${MACHINE} == "amiga"
CPUFLAGS+=-m68020-60 -mhard-float
# kernel
CMACHFLAGS=-m68020-60
.endif

changes to source files:

m68020 - m68060 doesn't need strict alignment and not aligning strictly should give more efficient code

--- external/gpl3/gcc/dist/gcc/config/m68k/m68k.cc      2 Feb 2026 20:18:21 -0000       1.1.1.1.4.1
+++ external/gpl3/gcc/dist/gcc/config/m68k/m68k.cc      7 Aug 2026 06:29:04 -0000
@@ -550,7 +550,7 @@
   target_mask = 0;

   /* ColdFire is lenient about alignment.  */
-  if (!TARGET_COLDFIRE)
+  if (!TARGET_68020 && !TARGET_COLDFIRE)
     target_mask |= MASK_STRICT_ALIGNMENT;

   if ((m68k_cpu_flags & FL_BITFIELD) != 0)

the bootblocks are 68030 assembler code and -m68020-60 -march=68030 -mcpu=68030 won't compile. Setting AFLAGS with '=' instead of with '+=' loses assembler flags that aren't CPUFLAGS, this needs a better solution

--- sys/arch/amiga/stand/bootblock/boot/Makefile        8 Jun 2024 06:39:57 -0000       1.63
+++ sys/arch/amiga/stand/bootblock/boot/Makefile        7 Aug 2026 06:40:05 -0000
@@ -85,7 +85,7 @@ INCPATH += -I${.CURDIR}
 INCPATH += -I${.CURDIR}/../../.. -I${.OBJDIR}
 INCPATH += -I${.CURDIR}/../elf2bb

-AFLAGS += -march=68030 -mcpu=68030
+AFLAGS = -march=68030 -mcpu=68030
 CAFLAGS += -Wa,-march=68030 -Wa,-mcpu=68030 ${INCPATH}

 COPTIM= -Os -fomit-frame-pointer -fcse-follow-jumps -fcse-skip-blocks
--- sys/arch/amiga/stand/bootblock/bootxx_ffs/Makefile  29 Apr 2022 07:45:20 -0000      1.28
+++ sys/arch/amiga/stand/bootblock/bootxx_ffs/Makefile  7 Aug 2026 06:40:58 -0000
@@ -70,7 +70,7 @@
 INCPATH += -I${.CURDIR}/../boot -I${.CURDIR}/../../..
 INCPATH += -I${.CURDIR}/../elf2bb -I${.OBJDIR}

-AFLAGS += -m68030 -l
+AFLAGS = -m68030 -l
 CAFLAGS += -Wa,-l -Wa,-march=68030 -Wa,-mcpu=68030 ${INCPATH} -D_PRIMARY_BOOT

 COPTIM= -Os -fomit-frame-pointer -fcse-follow-jumps -fcse-skip-blocks

when compiling the kernel

locore.s needs -Wa,-m68030 and netbsd060sp.c needs pure -m68060 to build. When hitting these compile them with the -m68020-60 replaced by what they need and normally would use, and continue the kernel build with -u (very crude solution)

when building distribution

the build fails with:

#     build  libgcc_s/libgcc_s.so.1.0
rm -f libgcc_s.so.1.0
/home/netbsd/11/arch/amiga/tools/bin/m68k--netbsdelf-gcc -nodefaultlibs -shared -Wl,-soname,libgcc_s.so.1  -Wl,--warn-shared-textrel -Wl,-Map=libgcc_s.so.1.map   --sysroot=/home/netbsd/11/arch/amiga/destdir -nodefaultlibs -Wl,-z -Wl,nodelete -Wl,--version-script=/home/netbsd/11/arch/amiga/obj/external/gpl3/gcc/lib/libgcc/libgcc_s/libgcc.map  -o libgcc_s.so.1.0.tmp  -Wl,-rpath,/lib  -L=/lib -Wl,-x  -Wl,--whole-archive libgcc_s_pic.a  -Wl,--no-whole-archive -L/home/netbsd/11/arch/amiga/obj/external/gpl3/gcc/lib/libgcc/libgcc -lgcc 
libgcc_s_pic.a(_float.pico):(.text+0x8): relocation truncated to fit: R_68K_PLT16 against symbol `$_exception_handler' defined in .text section in libgcc_s_pic.a(_floatex.pico)
libgcc_s_pic.a(_float.pico):(.text+0x18): relocation truncated to fit: R_68K_PLT16 against symbol `$_exception_handler' defined in .text section in libgcc_s_pic.a(_floatex.pico)
libgcc_s_pic.a(_float.pico):(.text+0x22): relocation truncated to fit: R_68K_PLT16 against symbol `$_exception_handler' defined in .text section in libgcc_s_pic.a(_floatex.pico)
libgcc_s_pic.a(_float.pico):(.text+0x2c): relocation truncated to fit: R_68K_PLT16 against symbol `$_exception_handler' defined in .text section in libgcc_s_pic.a(_floatex.pico)
libgcc_s_pic.a(_float.pico):(.text+0x3c): relocation truncated to fit: R_68K_PLT16 against symbol `$_exception_handler' defined in .text section in libgcc_s_pic.a(_floatex.pico)
libgcc_s_pic.a(_float.pico): in function `__cmpsf2_internal':
(.text+0x726): relocation truncated to fit: R_68K_PLT16 against symbol `$_exception_handler' defined in .text section in libgcc_s_pic.a(_floatex.pico)
collect2: error: ld returned 1 exit status

this builds when not using CPUFLAGS (surprise :/ )

building just

_double.S, _float.S and _floatex.S

derivates without -m68020-60 was insufficient. Building the entire libgcc_s without (but the rest of the build with -m68020-60) also works.

After consultation with someone who knows assembler (mlelstv@) the following change helped:

--- external/gpl3/gcc/dist/libgcc/config/m68k/lb1sf68.S 30 Jul 2023 05:51:37 -0000      1.10
+++ external/gpl3/gcc/dist/libgcc/config/m68k/lb1sf68.S 7 Aug 2026 13:16:23 -0000
@@ -215,7 +215,7 @@
        lea     \addr-.-8,a0
        jmp     pc@(a0)
 #else
-       bra     \addr@PLTPC
+       bral    \addr@PLTPC
 #endif
        .endm