diff --git a/barebones/Makefile b/barebones/Makefile
index e177a6d3ffbabad720d1ce9e940b498649e7696a..a5db2f8ac68ba857adeea4e1d8e9051de1bd3479 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 c4c7035915ff5e6448b5c5d3057a197399358e81..01968ca0ff1e74ebc25a2456afe962978e004526 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 d31efbae24a127bd553f539c6984d363e93214f0..d8c69ee72b063d08c19ec8c056738267c8d02319 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