From 465e77a2c2296e4837eba865f4fcdc53e56cf63f Mon Sep 17 00:00:00 2001
From: cnlohr <lohr85@gmail.com>
Date: Sat, 18 Feb 2023 11:44:05 -0800
Subject: [PATCH] It works with GCC!

---
 barebones/Makefile   | 5 +++--
 official/Makefile    | 5 +++--
 official/embedlibc.c | 2 ++
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/barebones/Makefile b/barebones/Makefile
index e177a6d..a5db2f8 100644
--- a/barebones/Makefile
+++ b/barebones/Makefile
@@ -7,8 +7,9 @@ PREFIX:=riscv64-unknown-elf
 GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User
 
 CFLAGS:= \
-	-Os -flto -ffunction-sections \
-	-march=rv32emc \
+	-g -Os -flto -ffunction-sections \
+	-static-libgcc -lgcc \
+	-march=rv32ec \
 	-mabi=ilp32e \
 	-I/usr/include/newlib \
 	-nostdlib \
diff --git a/official/Makefile b/official/Makefile
index c4c7035..01968ca 100644
--- a/official/Makefile
+++ b/official/Makefile
@@ -7,8 +7,9 @@ PREFIX:=riscv64-unknown-elf
 GPIO_Toggle:=EXAM/GPIO/GPIO_Toggle/User
 
 CFLAGS:= \
-	-Os -flto -ffunction-sections \
-	-march=rv32emc \
+	-g -Os -flto -ffunction-sections \
+	-static-libgcc -lgcc \
+	-march=rv32ec \
 	-mabi=ilp32e \
 	-I/usr/include/newlib \
 	-nostdlib \
diff --git a/official/embedlibc.c b/official/embedlibc.c
index d31efba..d8c69ee 100644
--- a/official/embedlibc.c
+++ b/official/embedlibc.c
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
+#include <limits.h>
 
 int errno;
 int _write(int fd, const char *buf, int size);
@@ -25,6 +26,7 @@ int printf(const char* format, ...)
 	return ret_status;
 }
 
+
 /* Some stuff from MUSL
 
 
-- 
GitLab