From a581c2c8ce52427316137e03b8dc1832b9c14561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 16 Sep 2019 13:14:42 +0200 Subject: [PATCH 1/3] Makefile.base: implement relative path linking without 'realpath' This fixes the following issues: * Use of 'realpath' not supported on mac * Call of 'realpath' once for each file instead of one per archive * Do not trigger 'llvm-ar' bug when invoked in the object directory. llvm-ar rcTs ../m.a obj.o # Bugged llvm-ar rcTs m.a m/obj.o # working Using relative path linking is required to have a valid thin archive path in the host when build in docker. --- Makefile.base | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile.base b/Makefile.base index 6f6984153ff8..6ca82a7d9f00 100644 --- a/Makefile.base +++ b/Makefile.base @@ -67,12 +67,12 @@ $(BINDIR)/$(MODULE)/: $(BINDIR)/$(MODULE).a $(OBJ): | $(BINDIR)/$(MODULE)/ -relpath = $(shell realpath --relative-to=$(abspath .) $(1)) - +# Build the archive from the output directory to create relative thin archives +# This allows having them valid in and outside of docker $(BINDIR)/$(MODULE).a: $(OBJ) | $(DIRS:%=ALL--%) @# Recreate archive to cleanup deleted/non selected source files objects $(Q)$(RM) $@ - $(Q)$(AR) $(ARFLAGS) $(foreach f,$@ $^,$(call relpath,$f)) + $(Q)cd $(@D) && $(AR) $(ARFLAGS) $(@F) $(subst $(@D)/,,$^) CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS) CCASFLAGS = $(filter-out $(CCASUWFLAGS), $(CFLAGS)) $(CCASEXFLAGS) From a1f0651170cee1edf505e361fd4b8ed89d222915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 16 Sep 2019 13:09:43 +0200 Subject: [PATCH 2/3] Revert "sys/arduino: work around llvm-ar bug." This reverts commit 72f934f13d6d50d5f2793f42842f410f5c08d277. Not required anymore as 'ar' is not executed in the object directory anymore. --- sys/arduino/Makefile.include | 2 +- sys/arduino/sketches.inc.mk | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/arduino/Makefile.include b/sys/arduino/Makefile.include index 2f86bc0a055b..1705d0bcceee 100644 --- a/sys/arduino/Makefile.include +++ b/sys/arduino/Makefile.include @@ -2,7 +2,7 @@ # Define application sketches module, it will be generated into $(BINDIR) SKETCH_MODULE ?= arduino_sketches -SKETCH_MODULE_DIR ?= $(BINDIR)/$(SKETCH_MODULE)_src +SKETCH_MODULE_DIR ?= $(BINDIR)/$(SKETCH_MODULE) SKETCHES = $(wildcard $(APPDIR)/*.sketch) include $(RIOTBASE)/sys/arduino/sketches.inc.mk diff --git a/sys/arduino/sketches.inc.mk b/sys/arduino/sketches.inc.mk index 0aafb8729fc4..ae71a7852423 100644 --- a/sys/arduino/sketches.inc.mk +++ b/sys/arduino/sketches.inc.mk @@ -19,8 +19,7 @@ SKETCH_GENERATED_FILES = $(SKETCH_MODULE_DIR)/Makefile $(SKETCH_MODULE_DIR)/$(SK # Building the module files # Do not use $^ in receipes as Makefile is also a prerequisite $(SKETCH_MODULE_DIR)/Makefile: $(SKETCH_MODULE_DIR)/$(SKETCH_CPP) - $(Q)echo 'MODULE = $(SKETCH_MODULE)' > $@ - $(Q)echo 'SRCXX = $(SKETCH_CPP)' >> $@ + $(Q)echo 'SRCXX = $(SKETCH_CPP)' > $@ $(Q)echo 'include $$(RIOTBASE)/Makefile.base' >> $@ $(SKETCH_MODULE_DIR)/$(SKETCH_CPP): $(SKETCHES_ALL) @mkdir -p $(@D) From a019faaedd5155cfbb851b45a487f4de2ca0903f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= Date: Mon, 16 Sep 2019 13:52:56 +0200 Subject: [PATCH 3/3] Makefile.include: use an os independant 'relpath' This should now work on 'osx'. --- Makefile.include | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.include b/Makefile.include index bae0388d497e..8df7939bfe35 100644 --- a/Makefile.include +++ b/Makefile.include @@ -500,7 +500,8 @@ endif # BUILD_IN_DOCKER # Rules to check the correctness of thin archives. -relpath = $(shell realpath --relative-to=$(abspath .) $(1)) +# OS independant relpath as 'realpath --relative-to' is not supported on OSx +relpath = $(shell python3 -c 'import pathlib; print(pathlib.Path("$1").relative_to("$(CURDIR)"))') # Each ARCHECK file contains all the absolute paths found inside the archive. BASELIB_ARCHECKS = $(patsubst %.a,%.a-check,$(filter %.a,$(BASELIBS)))