From 7c85e6e0e95013677bc2cdc0bccbabc589d7931d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Fri, 3 Nov 2017 17:53:00 +0100 Subject: [PATCH 1/2] Makefile.base: fix AR keeping removed source files objects AR incrementally adds file without removing files. If a c file is deleted or disabled(submodule removal) it is not removed from archive and still ends up in the final elf file. This fix removes the need to do 'make clean' for this case. However it will break cases where an APPLICATION and a MODULE or two modules have the same name and only worked because source files names where different. --- Makefile.base | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.base b/Makefile.base index 0c5da103d1..ef5d77effe 100644 --- a/Makefile.base +++ b/Makefile.base @@ -68,7 +68,9 @@ $(BINDIR)/$(MODULE)/: $(BINDIR)/$(MODULE).a $(OBJ): | $(BINDIR)/$(MODULE)/ $(BINDIR)/$(MODULE).a: $(OBJ) | ${DIRS:%=ALL--%} - $(Q)$(AR) $(ARFLAGS) $@ $? + @# Recreate archive to cleanup deleted/non selected source files objects + $(Q)$(RM) $@ + $(Q)$(AR) $(ARFLAGS) $@ $^ CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS) CCASFLAGS = $(filter-out $(CCASUWFLAGS), $(CFLAGS)) $(CCASEXFLAGS) From e5d234e2f497bcf856226b446e02fbeb4fd96dfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Thu, 1 Mar 2018 14:06:28 +0100 Subject: [PATCH 2/2] doc: add warning that MODULE name should be unique Modules produce an output archive called `${MODULE}.a` if several modules use the same name, the output is overwritten. --- doc/doxygen/src/creating-modules.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/doxygen/src/creating-modules.md b/doc/doxygen/src/creating-modules.md index 63d2c840d6..82d54be000 100644 --- a/doc/doxygen/src/creating-modules.md +++ b/doc/doxygen/src/creating-modules.md @@ -34,6 +34,20 @@ current configuration or not. Modules can be used by adding their name to the `USEMODULE` macro of your application's Makefile. +### Pitfalls ### + +The `MODULE` name should be unique or build breaks as modules overwrite the +same output file. + +This problem happened in the past for: + + * Packages root directory (libfixmath/u8g2) + * boards/cpu/periph and their common boards/cpu/periph + +Note: even if all boards and cpus implement the `board` and `cpu` modules, only + one is used in an application so there is no conflict. + + Module dependencies =================== Your module may depend on other modules to minimize code duplication. These