diff --git a/makefiles/modules.inc.mk b/makefiles/modules.inc.mk index 7aa1e78ec628..a5ee6a2ba4c2 100644 --- a/makefiles/modules.inc.mk +++ b/makefiles/modules.inc.mk @@ -8,4 +8,17 @@ CFLAGS += $(EXTDEFINES) # filter "pseudomodules" from "real modules", but not "no_pseudomodules" REALMODULES += $(filter-out $(PSEUDOMODULES), $(_ALLMODULES)) REALMODULES += $(filter $(NO_PSEUDOMODULES), $(_ALLMODULES)) -BASELIBS += $(REALMODULES:%=$(BINDIR)/%.a) + + +# Modules that can be linked by including all objects +OBJECTS_REALMODULES = $(filter-out $(LIBS), $(REALMODULES)) +# Modules that must be linked using the default 'archive' linking behaviour +ARCHIVE_REALMODULES = $(filter $(LIBS), $(REALMODULES)) + +OBJECTS_LIBS += $(OBJECTS_REALMODULES:%=$(BINDIR)/%.a) +ARCHIVE_LIBS += $(ARCHIVE_REALMODULES:%=$(BINDIR)/%.a) + +# Warning: the object/archive compilation handling is not currently handled +# for all architectures. + +BASELIBS += $(OBJECTS_LIBS) $(ARCHIVE_LIBS) diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index bff4d74f52a1..0ce254ff7304 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -16,6 +16,12 @@ export CXXINCLUDES # The extra include paths for c++, set by the vario export USEMODULE # Sys Module dependencies of the application. Set in the application's Makefile. export USEPKG # Pkg dependencies (third party modules) of the application. Set in the application's Makefile. +# LIBS +# List of modules that must be linked using the default 'archive' linking +# behavior where only required/referenced objects/functions are included. +# +# Modules whose archive should not/cannot be linked with `--whole-archive` +# must be added to LIBS in the module Makefile.include. export DISABLE_MODULE # Used in the application's Makefile to suppress DEFAULT_MODULEs. export APPDEPS # Files / Makefile targets that need to be created before the application can be build. Set in the application's Makefile. # BUILDDEPS # Files / Makefile targets that need to be created before starting to build.