Makefile.include: separate link in subtargets#8844
Conversation
|
For me this one is the "tricky" part of #8838 because it is something that had be done before, reverted, assumed to be that way for a long time and should be checked properly to prevent non-rebuilding the elffile. |
Makefile.include
Outdated
|
|
||
| _LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) $(LINKFLAGPREFIX)--start-group $(BASELIBS) -lm $(LINKFLAGPREFIX)--end-group $(LINKFLAGPREFIX)-Map=$(BINDIR)/$(APPLICATION).map $(LINKFLAGS) | ||
| # Linker rule | ||
| $(ELFFILE): FORCE # Force rebuilding in case _LINK changes |
There was a problem hiding this comment.
I find the comment confusing. Why should the variable change?
There was a problem hiding this comment.
You are right it's not clear.
I tried to prevent adding a new case where make -B would be required to rebuild if you changed LINKFLAGS for any reason.
For example in native by calling first make all then make all-asan or as developer by changing LINKFLAGS in one of the cpu/board makefile.include.
In the current state, during every build the elf file is re-linked even if nothing changed in the archives.
That is what I tried to mimic by putting the FORCE dependency here.
I welcome any suggestion for the comment :)
| ifeq (,$(RIOTNOLINK)) | ||
| ifeq ($(BUILDOSXNATIVE),1) | ||
| $(Q)$(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) -o $(ELFFILE) $$(find $(BASELIBS) -size +8c) $(LINKFLAGS) $(LINKFLAGPREFIX)-no_pie | ||
| link: ..compiler-check ..build-message $(ELFFILE) $(HEXFILE) print-size |
There was a problem hiding this comment.
changing hexfile here to flashfile comes later?
There was a problem hiding this comment.
Yes, because changing to FLASHFILE requires other changes in the flasher scripts.
Makefile.include
Outdated
| ifeq ($(BUILD_IN_DOCKER),1) | ||
| link: ..in-docker-container | ||
| else | ||
| ## make script for your application. Build RIOT-base here! |
There was a problem hiding this comment.
Should you touch the file again in this PR, removing this comment would make the world a little better!
| $(Q)DIRS="$(DIRS)" "$(MAKE)" -C $(APPDIR) -f $(RIOTMAKE)/application.inc.mk | ||
| $(BINDIR)/$(APPLICATION_MODULE).a: FORCE # we do not know here if it needs to be updated | ||
|
|
||
| print-size: $(ELFFILE) |
There was a problem hiding this comment.
please add mentioning "info-buildsize" (which does not cause a rebuild)
| $(Q)$(SIZE) $< | ||
|
|
||
| $(HEXFILE): $(ELFFILE) | ||
| $(Q)$(OBJCOPY) $(OFLAGS) $< $@ |
There was a problem hiding this comment.
In this PR I only put it to a separate target but keep the old rule.
I wanted to focus on only splitting the link target.
Many boards are using 'HEXFILE' for a '.bin' file so cannot replace it here.
Makefile.include
Outdated
| .PHONY: all link clean flash flash-only term doc debug debug-server reset objdump help info-modules | ||
| .PHONY: print-size | ||
| .PHONY: ..in-docker-container | ||
| # Target can depend on FORCE to force running build command every time |
There was a problem hiding this comment.
this explanation needs rewrite, too...
Refactor osx-native linker rule into `_LINK` too.
* Add ELFFILE, HEXFILE, print-size targets $(BINDIR)/$(APPLICATION_MODULE).a target builds libraries in RIOT and in DIRS. Uses a FORCE phony target dependency to force rebuilding but still let `make` use the file modification timestamps
6ae3c67 to
f64de06
Compare
|
Thank you for the review, I rebased #8845 which is the next one in the list. |
|
Sadly, this PR introduced a problem :( (see #8910) |
Unittests add libraries in 'BASELIBS' which do not have any rules to be built as they are built by 'application.inc.mk' and the DIRS variable. So make complains about missing target for the unittests archives. The bug was introduced by RIOT-OS#8844 Fixes RIOT-OS#8910
Unittests add libraries in 'BASELIBS' which do not have any rules to be built as they are built by 'application.inc.mk' and the DIRS variable. So make complains about missing target for the unittests archives. The fix tells these files are generated when building '$(APPLICATION_MODULE).a'. The bug was introduced by RIOT-OS#8844 Fixes RIOT-OS#8910
Unittests add libraries in 'BASELIBS' which do not have any rules to be built as they are built by 'application.inc.mk' and the DIRS variable. So make complains about missing target for the unittests archives. The fix tells these files are generated when building '$(APPLICATION_MODULE).a'. The bug was introduced by RIOT-OS#8844 Fixes RIOT-OS#8910
Unittests add libraries in 'BASELIBS' which do not have any rules to be built as they are built by 'application.inc.mk' and the DIRS variable. So make complains about missing target for the unittests archives. The fix tells these files are generated when building '$(APPLICATION_MODULE).a'. The bug was introduced by RIOT-OS#8844 Fixes RIOT-OS#8910
Unittests add libraries in 'BASELIBS' which do not have any rules to be built as they are built by 'application.inc.mk', packages and the DIRS variable. So make complains about missing target for the unittests archives. The fix tells these files are generated when building '$(APPLICATION_MODULE).a'. The bug was introduced by RIOT-OS#8844 Fixes RIOT-OS#8910
Unittests add libraries in 'BASELIBS' which do not have any rules to be built as they are built by 'application.inc.mk', packages and the DIRS variable. So make complains about missing target for the unittests archives. The fix tells these files are generated when building '$(APPLICATION_MODULE).a'. The bug was introduced by RIOT-OS#8844 Fixes RIOT-OS#8910
Unittests add libraries in 'BASELIBS' which do not have any rules to be built as they are built by 'application.inc.mk', packages and the DIRS variable. So make complains about missing target for the unittests archives. The fix tells these files are generated when building '$(APPLICATION_MODULE).a'. The bug was introduced by RIOT-OS#8844 Fixes RIOT-OS#8910
Unittests add libraries in 'BASELIBS' which do not have any rules to be built as they are built by 'application.inc.mk', packages and the DIRS variable. So make complains about missing target for the unittests archives. The fix tells these files are generated when building '$(APPLICATION_MODULE).a'. The bug was introduced by RIOT-OS#8844 Fixes RIOT-OS#8910
Unittests add libraries in 'BASELIBS' which do not have any rules to be built as they are built by 'application.inc.mk', packages and the DIRS variable. So make complains about missing target for the unittests archives. The fix tells these files are generated when building '$(APPLICATION_MODULE).a'. The bug was introduced by RIOT-OS#8844 Fixes RIOT-OS#8910
Unittests add libraries in 'BASELIBS' which do not have any rules to be built as they are built by 'application.inc.mk', packages and the DIRS variable. So make complains about missing target for the unittests archives. The fix tells these files are generated when building '$(APPLICATION_MODULE).a'. The bug was introduced by RIOT-OS#8844 Fixes RIOT-OS#8910
Contribution description
It re-introduces #1098 which was removed by #1198
I removed the rebuilding issue by making ELFFILE and $(APPLICATION_MODULE).a depend on a
FORCE.PHONY target. I did not use.PHONYbecause it disables using the file timestamp.Calling make a second time shows that we are indeed re-going in RIOT directories and re-calling the link command.
For BUILDOSXNATIVE, I also re-used
_LINKvariable to harmonize things.I tested it before but would like another run on a mac.
Issues/PRs references
Part of #8838