From 0e48accbcffda9c2b19670f5f7af20fed2e2b492 Mon Sep 17 00:00:00 2001
From: mintsuki <mintsuki@protonmail.com>
Date: Sat, 6 Aug 2022 16:05:12 +0200
Subject: [PATCH] Use LD instead of CC for linking

---
 kernel/GNUmakefile | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/kernel/GNUmakefile b/kernel/GNUmakefile
index d31394c..ae7a3ea 100644
--- a/kernel/GNUmakefile
+++ b/kernel/GNUmakefile
@@ -17,6 +17,9 @@ endef
 # the host system's toolchain, but this is not guaranteed.
 $(eval $(call DEFAULT_VAR,CC,cc))
 
+# Same thing for "ld" (the linker).
+$(eval $(call DEFAULT_VAR,LD,ld))
+
 # User controllable CFLAGS.
 CFLAGS ?= -O2 -g -Wall -Wextra -Wpedantic -pipe
 
@@ -50,11 +53,11 @@ override INTERNALCFLAGS := \
     -MMD
 
 # Internal linker flags that should not be changed by the user.
-override INTERNALLDFLAGS :=     \
-    -nostdlib                   \
-    -static                     \
-    -Wl,-z,max-page-size=0x1000 \
-    -Wl,-T,linker.ld
+override INTERNALLDFLAGS := \
+    -nostdlib               \
+    -static                 \
+    -z max-page-size=0x1000 \
+    -T linker.ld
 
 # Internal nasm flags that should not be changed by the user.
 override INTERNALNASMFLAGS := \
@@ -76,7 +79,7 @@ limine.h:
 
 # Link rules for the final kernel executable.
 $(KERNEL): $(OBJ)
-	$(CC) $(CFLAGS) $(INTERNALCFLAGS) $(OBJ) $(LDFLAGS) $(INTERNALLDFLAGS) -o $@
+	$(LD) $(OBJ) $(LDFLAGS) $(INTERNALLDFLAGS) -o $@
 
 # Include header dependencies.
 -include $(HEADER_DEPS)