From 2890ff30f1b8bf29d31d519f5e9555592ee15502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Tue, 5 Mar 2019 16:13:54 +0100 Subject: [PATCH 1/2] makefiles: introduce 'LIBS' variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This introduced the LIBS variables to declare a module as a static library. It is a requirement to allow handling linking differently between static libraries and shared libraries in upcoming pull requests. Co-authored-by: Joakim NohlgÄrd --- makefiles/modules.inc.mk | 14 +++++++++++++- makefiles/vars.inc.mk | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/makefiles/modules.inc.mk b/makefiles/modules.inc.mk index 7aa1e78ec628..4c4246bb73b8 100644 --- a/makefiles/modules.inc.mk +++ b/makefiles/modules.inc.mk @@ -8,4 +8,16 @@ 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) + +# For 'shared libraries' every object must be included +SHARED_LIBS = $(filter-out $(LIBS), $(REALMODULES)) +# For 'static libraries' only required object files are included +STATIC_LIBS = $(filter $(LIBS), $(REALMODULES)) + +# Warning: the shared/static libraries handling is not currently handled +# for all architectures. But correctly defining them allows future proof +# handling. + +SHARED_LIBS_FILES = $(SHARED_LIBS:%=$(BINDIR)/%.a) +STATIC_LIBS_FILES = $(STATIC_LIBS:%=$(BINDIR)/%.a) +BASELIBS += $(SHARED_LIBS_FILES) $(STATIC_LIBS_FILES) diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk index bff4d74f52a1..6786623d036e 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -16,6 +16,7 @@ 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 # Handle the module as a static library instead of a shared library. Set by the package's Makefile.include when necessary 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. From bfa6d751e55d62192103a33008d3a88539e69731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 9 May 2019 12:13:28 +0200 Subject: [PATCH 2/2] squash! makefiles: introduce 'LIBS' variable Update the documentation to replace 'SHARED' by 'OBJECTS', 'ARCHIVE'. --- makefiles/modules.inc.mk | 21 +++++++++++---------- makefiles/vars.inc.mk | 7 ++++++- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/makefiles/modules.inc.mk b/makefiles/modules.inc.mk index 4c4246bb73b8..a5ee6a2ba4c2 100644 --- a/makefiles/modules.inc.mk +++ b/makefiles/modules.inc.mk @@ -9,15 +9,16 @@ CFLAGS += $(EXTDEFINES) REALMODULES += $(filter-out $(PSEUDOMODULES), $(_ALLMODULES)) REALMODULES += $(filter $(NO_PSEUDOMODULES), $(_ALLMODULES)) -# For 'shared libraries' every object must be included -SHARED_LIBS = $(filter-out $(LIBS), $(REALMODULES)) -# For 'static libraries' only required object files are included -STATIC_LIBS = $(filter $(LIBS), $(REALMODULES)) -# Warning: the shared/static libraries handling is not currently handled -# for all architectures. But correctly defining them allows future proof -# handling. +# 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)) -SHARED_LIBS_FILES = $(SHARED_LIBS:%=$(BINDIR)/%.a) -STATIC_LIBS_FILES = $(STATIC_LIBS:%=$(BINDIR)/%.a) -BASELIBS += $(SHARED_LIBS_FILES) $(STATIC_LIBS_FILES) +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 6786623d036e..0ce254ff7304 100644 --- a/makefiles/vars.inc.mk +++ b/makefiles/vars.inc.mk @@ -16,7 +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 # Handle the module as a static library instead of a shared library. Set by the package's Makefile.include when necessary +# 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.