After some more testing, it seems when all source files are given to GCC at once, the debugging works fine,
When I compile all source files to object files and then link them together, the debugging fails.
When building everything in one go, debugging succeeds (paths shorted to shrink the length)
riscv-none-elf-gcc ch32.S gd32.S rv32f103.S irq.S gd32_intexc.S gd32_intexc.c ch32.c gd32.c common.c main.c -I NMSIS/Core/Include/ -o test.gcc12.elf -T rv32f103.ld --specs=nosys.specs --specs=nano.specs -nostartfiles -Wl,--no-relax -Wl,--gc-sections -march=rv32imac -mabi=ilp32 -mcmodel=medlow -fdata-sections -ffunction-sections -misa-spec=2.2 -O0 -g3 -Wl,-Map=test.gcc12.map
When building every file into its own object, then linking it all together, debugging fails (paths shorted to shrink the length)
riscv-none-elf-gcc -c -INMSIS/Core/Include/ -Iucdev/lib/libhalglue/common/ -Iucdev/lib/libhalglue/bshal/ -INMSIS/Core/Include/ -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 -DNONE -DNONE -I -O0 -g3 -Wall -fdata-sections -ffunction-sections -MMD -MP -MF"debug/none/build/main.c.d" -DDEBUG -Wa,-a,-ad,-alms=debug/none/build/main.lst ../main.c -o debug/none/build/main.c.o
riscv-none-elf-gcc -c -INMSIS/Core/Include/ -Iucdev/lib/libhalglue/common/ -Iucdev/lib/libhalglue/bshal/ -INMSIS/Core/Include/ -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 -DNONE -DNONE -I -O0 -g3 -Wall -fdata-sections -ffunction-sections -MMD -MP -MF"debug/none/build/gd32_intexc.c.d" -DDEBUG -Wa,-a,-ad,-alms=debug/none/build/gd32_intexc.lst ucdev/lib/libhalglue/compat/rv32f103/gd32_intexc.c -o debug/none/build/gd32_intexc.c.o
riscv-none-elf-gcc -c -INMSIS/Core/Include/ -Iucdev/lib/libhalglue/common/ -Iucdev/lib/libhalglue/bshal/ -INMSIS/Core/Include/ -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 -DNONE -DNONE -I -O0 -g3 -Wall -fdata-sections -ffunction-sections -MMD -MP -MF"debug/none/build/ch32.c.d" -DDEBUG -Wa,-a,-ad,-alms=debug/none/build/ch32.lst ucdev/lib/libhalglue/compat/rv32f103/ch32.c -o debug/none/build/ch32.c.o
riscv-none-elf-gcc -c -INMSIS/Core/Include/ -Iucdev/lib/libhalglue/common/ -Iucdev/lib/libhalglue/bshal/ -INMSIS/Core/Include/ -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 -DNONE -DNONE -I -O0 -g3 -Wall -fdata-sections -ffunction-sections -MMD -MP -MF"debug/none/build/gd32.c.d" -DDEBUG -Wa,-a,-ad,-alms=debug/none/build/gd32.lst ucdev/lib/libhalglue/compat/rv32f103/gd32.c -o debug/none/build/gd32.c.o
riscv-none-elf-gcc -c -INMSIS/Core/Include/ -Iucdev/lib/libhalglue/common/ -Iucdev/lib/libhalglue/bshal/ -INMSIS/Core/Include/ -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 -DNONE -DNONE -I -O0 -g3 -Wall -fdata-sections -ffunction-sections -MMD -MP -MF"debug/none/build/common.c.d" -DDEBUG -Wa,-a,-ad,-alms=debug/none/build/common.lst ucdev/lib/libhalglue/compat/rv32f103/common.c -o debug/none/build/common.c.o
riscv-none-elf-gcc -x assembler-with-cpp -c -INMSIS/Core/Include/ -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 -O0 -g3 -Wall -fdata-sections -ffunction-sections -MMD -MP -MF"debug/none/build/ch32.S.d" ucdev/lib/libhalglue/compat/rv32f103/ch32.S -o debug/none/build/ch32.S.o
riscv-none-elf-gcc -x assembler-with-cpp -c -INMSIS/Core/Include/ -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 -O0 -g3 -Wall -fdata-sections -ffunction-sections -MMD -MP -MF"debug/none/build/gd32.S.d" ucdev/lib/libhalglue/compat/rv32f103/gd32.S -o debug/none/build/gd32.S.o
riscv-none-elf-gcc -x assembler-with-cpp -c -INMSIS/Core/Include/ -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 -O0 -g3 -Wall -fdata-sections -ffunction-sections -MMD -MP -MF"debug/none/build/rv32f103.S.d" ucdev/lib/libhalglue/compat/rv32f103/rv32f103.S -o debug/none/build/rv32f103.S.o
riscv-none-elf-gcc -x assembler-with-cpp -c -INMSIS/Core/Include/ -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 -O0 -g3 -Wall -fdata-sections -ffunction-sections -MMD -MP -MF"debug/none/build/irq.S.d" ucdev/lib/libhalglue/compat/rv32f103/irq.S -o debug/none/build/irq.S.o
riscv-none-elf-gcc -x assembler-with-cpp -c -INMSIS/Core/Include/ -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 -O0 -g3 -Wall -fdata-sections -ffunction-sections -MMD -MP -MF"debug/none/build/gd32_intexc.S.d" ucdev/lib/libhalglue/compat/rv32f103/gd32_intexc.S -o debug/none/build/gd32_intexc.S.o
riscv-none-elf-gcc debug/none/build/main.c.o debug/none/build/gd32_intexc.c.o debug/none/build/ch32.c.o debug/none/build/gd32.c.o debug/none/build/common.c.o debug/none/build/ch32.S.o debug/none/build/gd32.S.o debug/none/build/rv32f103.S.o debug/none/build/irq.S.o debug/none/build/gd32_intexc.S.o -nostartfiles -Wl,--no-relax -march=rv32imac -mabi=ilp32 -mcmodel=medlow -misa-spec=2.2 --specs=nosys.specs --specs=nano.specs -Trv32f103.ld -L.. -L.. -Wl,--gc-sections -Wl,-Map=debug/none/rv32test.map,--cref -o debug/none/rv32test.elf