From 3a0d2177cdeb6dfffda502f51add299e4a7bded2 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jeremy@system76.com>
Date: Tue, 25 Aug 2020 08:21:31 -0600
Subject: [PATCH] Variable for weakened symbols, weaken umodti3

---
 Makefile | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 00ba0a14..d4ed1616 100644
--- a/Makefile
+++ b/Makefile
@@ -41,6 +41,15 @@ SRC=\
 	Cargo.* \
 	$(shell find src -type f)
 
+# FIXME: Remove the following line. It's only required since xargo automatically links with compiler_builtins, which conflicts with the compiler_builtins that rustc always links with.
+WEAKEN_SYMBOLS=\
+	-W __divti3 \
+	-W __fixdfti \
+	-W __floattidf \
+	-W __muloti4 \
+	-W __udivti3 \
+	-W __umodti3
+
 .PHONY: all clean fmt install install-headers libs test
 
 all: | libs
@@ -115,7 +124,7 @@ $(BUILD)/debug/libc.so: $(BUILD)/debug/librelibc.a $(BUILD)/pthreads-emb/libpthr
 $(BUILD)/debug/librelibc.a: $(SRC)
 	CARGO_INCREMENTAL=0 $(CARGO) rustc $(CARGOFLAGS) -- --emit link=$@ $(RUSTCFLAGS)
 	# FIXME: Remove the following line. It's only required since xargo automatically links with compiler_builtins, which conflicts with the compiler_builtins that rustc always links with.
-	$(OBJCOPY) $@ -W __divti3 -W __muloti4 -W __udivti3 -W __floattidf -W __fixdfti
+	$(OBJCOPY) $@ $(WEAKEN_SYMBOLS)
 	touch $@
 
 $(BUILD)/debug/crt0.o: $(SRC)
@@ -153,8 +162,7 @@ $(BUILD)/release/libc.so: $(BUILD)/release/librelibc.a $(BUILD)/pthreads-emb/lib
 
 $(BUILD)/release/librelibc.a: $(SRC)
 	CARGO_INCREMENTAL=0 $(CARGO) rustc --release $(CARGOFLAGS) -- --emit link=$@ $(RUSTCFLAGS)
-	# FIXME: Remove the following line. It's only required since xargo automatically links with compiler_builtins, which conflicts with the compiler_builtins that rustc always links with.
-	$(OBJCOPY) $@ -W __divti3 -W __muloti4 -W __udivti3 -W __floattidf -W __fixdfti
+	$(OBJCOPY) $@ $(WEAKEN_SYMBOLS)
 	touch $@
 
 $(BUILD)/release/crt0.o: $(SRC)
-- 
GitLab