Use LD instead of CC for linking

This commit is contained in:
mintsuki 2022-08-06 16:05:12 +02:00
parent c24528a481
commit 0e48accbcf

View file

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