From 5928afd6dcbe7eff14d988b35052b1080538579c Mon Sep 17 00:00:00 2001 From: EmbeddedMan <brian@schmalzhaus.com> Date: Mon, 10 Apr 2023 21:19:55 -0500 Subject: [PATCH] Came up with a better way to handle Windows linking to the right libgcc.a --- examples/adc_polled/Makefile | 11 ++--------- examples/blink/Makefile | 12 ++---------- examples/bootload/Makefile | 12 ++---------- examples/debugprintfdemo/Makefile | 11 ++--------- examples/external_crystal/Makefile | 12 ++---------- examples/i2c_oled/Makefile | 11 ++--------- examples/optionbytes/Makefile | 12 ++---------- examples/run_from_ram/Makefile | 12 ++---------- examples/sandbox/Makefile | 11 ++--------- examples/self_modify_code/Makefile | 11 ++--------- examples/systick_irq/Makefile | 11 ++--------- examples/tim1_pwm/Makefile | 11 ++--------- examples/uartdemo/Makefile | 12 ++---------- examples/ws2812bdemo/Makefile | 11 ++--------- 14 files changed, 28 insertions(+), 132 deletions(-) diff --git a/examples/adc_polled/Makefile b/examples/adc_polled/Makefile index d2635f6..ae735e6 100644 --- a/examples/adc_polled/Makefile +++ b/examples/adc_polled/Makefile @@ -9,16 +9,9 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User CH32V003FUN:=../../ch32v003fun MINICHLINK:=../../minichlink -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -26,7 +19,7 @@ CFLAGS:= \ -nostdlib \ -I. -DSTDOUT_UART -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/blink/Makefile b/examples/blink/Makefile index 903895a..4acaf26 100644 --- a/examples/blink/Makefile +++ b/examples/blink/Makefile @@ -9,19 +9,11 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User EVT:=../../ch32v003evt MINICHLINK:=../../minichlink - -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CH32V003FUN:=../../ch32v003fun CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -29,7 +21,7 @@ CFLAGS:= \ -nostdlib \ -I. -DTINYVECTOR -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/bootload/Makefile b/examples/bootload/Makefile index d39497d..7d681ec 100644 --- a/examples/bootload/Makefile +++ b/examples/bootload/Makefile @@ -9,19 +9,11 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User EVT:=../../ch32v003evt MINICHLINK:=../../minichlink - -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CH32V003FUN:=../../ch32v003fun CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -29,7 +21,7 @@ CFLAGS:= \ -nostdlib \ -I. -DCUSTOM_INTERRUPT_VECTOR -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun-bootloader.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun-bootloader.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/debugprintfdemo/Makefile b/examples/debugprintfdemo/Makefile index 09ebe05..01ae2f3 100644 --- a/examples/debugprintfdemo/Makefile +++ b/examples/debugprintfdemo/Makefile @@ -9,16 +9,9 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User CH32V003FUN:=../../ch32v003fun MINICHLINK:=../../minichlink -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -26,7 +19,7 @@ CFLAGS:= \ -nostdlib \ -I. -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/external_crystal/Makefile b/examples/external_crystal/Makefile index 74326f1..9ee7fc5 100644 --- a/examples/external_crystal/Makefile +++ b/examples/external_crystal/Makefile @@ -9,19 +9,11 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User EVT:=../../ch32v003evt MINICHLINK:=../../minichlink - -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CH32V003FUN:=../../ch32v003fun CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -29,7 +21,7 @@ CFLAGS:= \ -nostdlib \ -I. -DTINYVECTOR -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/i2c_oled/Makefile b/examples/i2c_oled/Makefile index 2f71bfb..da35468 100644 --- a/examples/i2c_oled/Makefile +++ b/examples/i2c_oled/Makefile @@ -9,16 +9,9 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User CH32V003FUN:=../../ch32v003fun MINICHLINK:=../../minichlink -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -26,7 +19,7 @@ CFLAGS:= \ -nostdlib \ -I. -DSTDOUT_UART -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/optionbytes/Makefile b/examples/optionbytes/Makefile index 967b1fb..1c2032c 100644 --- a/examples/optionbytes/Makefile +++ b/examples/optionbytes/Makefile @@ -9,19 +9,11 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User EVT:=../../ch32v003evt MINICHLINK:=../../minichlink - -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CH32V003FUN:=../../ch32v003fun CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -29,7 +21,7 @@ CFLAGS:= \ -nostdlib \ -I. -DTINYVECTOR -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/run_from_ram/Makefile b/examples/run_from_ram/Makefile index e6c6caa..dd492af 100644 --- a/examples/run_from_ram/Makefile +++ b/examples/run_from_ram/Makefile @@ -9,19 +9,11 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User EVT:=../../ch32v003evt MINICHLINK:=../../minichlink - -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CH32V003FUN:=../../ch32v003fun CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -29,7 +21,7 @@ CFLAGS:= \ -nostdlib \ -I. -DTINYVECTOR -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/sandbox/Makefile b/examples/sandbox/Makefile index b61a370..e45f982 100644 --- a/examples/sandbox/Makefile +++ b/examples/sandbox/Makefile @@ -9,16 +9,9 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User CH32V003FUN:=../../ch32v003fun MINICHLINK:=../../minichlink -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -26,7 +19,7 @@ CFLAGS:= \ -nostdlib \ -I. -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/self_modify_code/Makefile b/examples/self_modify_code/Makefile index 3200406..abafa8a 100644 --- a/examples/self_modify_code/Makefile +++ b/examples/self_modify_code/Makefile @@ -9,16 +9,9 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User CH32V003FUN:=../../ch32v003fun MINICHLINK:=../../minichlink -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -26,7 +19,7 @@ CFLAGS:= \ -nostdlib \ -I. -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/systick_irq/Makefile b/examples/systick_irq/Makefile index 7e9ef9e..d8910e1 100644 --- a/examples/systick_irq/Makefile +++ b/examples/systick_irq/Makefile @@ -9,16 +9,9 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User CH32V003FUN:=../../ch32v003fun MINICHLINK:=../../minichlink -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -26,7 +19,7 @@ CFLAGS:= \ -nostdlib \ -I. -DSTDOUT_UART -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/tim1_pwm/Makefile b/examples/tim1_pwm/Makefile index 56fff11..0aecad0 100644 --- a/examples/tim1_pwm/Makefile +++ b/examples/tim1_pwm/Makefile @@ -9,16 +9,9 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User CH32V003FUN:=../../ch32v003fun MINICHLINK:=../../minichlink -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -26,7 +19,7 @@ CFLAGS:= \ -nostdlib \ -I. -DSTDOUT_UART -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c diff --git a/examples/uartdemo/Makefile b/examples/uartdemo/Makefile index a4e1a7c..25b0efa 100644 --- a/examples/uartdemo/Makefile +++ b/examples/uartdemo/Makefile @@ -9,16 +9,9 @@ GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User CH32V003FUN:=../../ch32v003fun MINICHLINK:=../../minichlink -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -26,7 +19,7 @@ CFLAGS:= \ -nostdlib \ -I. -DSTDOUT_UART -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c @@ -41,7 +34,6 @@ $(TARGET).bin : $(TARGET).elf $(PREFIX)-objcopy -O ihex $< $(TARGET).hex flash : $(TARGET).bin - make -C $(MINICHLINK) all $(MINICHLINK)/minichlink -w $< flash -b clean : diff --git a/examples/ws2812bdemo/Makefile b/examples/ws2812bdemo/Makefile index 8f7bb98..c6af022 100644 --- a/examples/ws2812bdemo/Makefile +++ b/examples/ws2812bdemo/Makefile @@ -7,16 +7,9 @@ PREFIX:=riscv64-unknown-elf CH32V003FUN:=../../ch32v003fun MINICHLINK:=../../minichlink -ifeq ($(OS),Windows_NT) -# On Windows, all the major RISC-V GCC installs are missing the -ec libgcc. -LIB_GCC=../../misc/libgcc.a -else -LIB_GCC=-lgcc -endif - CFLAGS:= \ -g -Os -flto -ffunction-sections \ - -static-libgcc $(LIB_GCC) \ + -static-libgcc \ -march=rv32ec \ -mabi=ilp32e \ -I/usr/include/newlib \ @@ -24,7 +17,7 @@ CFLAGS:= \ -nostdlib \ -I. -Wall -LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections +LDFLAGS:=-T $(CH32V003FUN)/ch32v003fun.ld -Wl,--gc-sections -L../../misc -lgcc SYSTEM_C:=$(CH32V003FUN)/ch32v003fun.c -- GitLab