summaryrefslogtreecommitdiff
path: root/builddefs
diff options
context:
space:
mode:
authorThomas Weißschuh <thomas@t-8ch.de>2023-09-17 06:25:46 +0200
committerGitHub <noreply@github.com>2023-09-17 14:25:46 +1000
commit615ca78567736c262a9e4defe479cd9b42506b8c (patch)
treeff98ac41b637d03792ed9e74e733fd218d1a696c /builddefs
parent169b0f33f6a0693bcf4f1c5b05a0f1ed6711d0a2 (diff)
directly use object files when linking ELF (#22025)
Diffstat (limited to 'builddefs')
-rw-r--r--builddefs/common_rules.mk5
1 files changed, 4 insertions, 1 deletions
diff --git a/builddefs/common_rules.mk b/builddefs/common_rules.mk
index 261ab7da02..52dccbe475 100644
--- a/builddefs/common_rules.mk
+++ b/builddefs/common_rules.mk
@@ -12,6 +12,9 @@ vpath %.hpp $(VPATH_SRC)
vpath %.S $(VPATH_SRC)
VPATH :=
+# Helper to return the distinct elements of a list
+uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
+
# Convert all SRC to OBJ
define OBJ_FROM_SRC
$(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.cc,$1/%.o,$(patsubst %.S,$1/%.o,$(patsubst %.clib,$1/%.a,$($1_SRC))))))
@@ -264,7 +267,7 @@ BEGIN = gccversion sizebefore
# Note the obj.txt depeendency is there to force linking if a source file is deleted
%.elf: $(OBJ) $(MASTER_OUTPUT)/cflags.txt $(MASTER_OUTPUT)/ldflags.txt $(MASTER_OUTPUT)/obj.txt | $(BEGIN)
@$(SILENT) || printf "$(MSG_LINKING) $@" | $(AWK_CMD)
- $(eval CMD=MAKE=$(MAKE) $(CC) $(ALL_CFLAGS) $(filter-out %.txt,$^) --output $@ $(LDFLAGS))
+ $(eval CMD=MAKE=$(MAKE) $(CC) $(ALL_CFLAGS) $(call uniq,$(OBJ)) --output $@ $(LDFLAGS))
@$(BUILD_CMD)