-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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
@@ -318,23 +323,38 @@ LINKFLAGPREFIX ?= -Wl, | |||
|
|||
DIRS += $(EXTERNAL_MODULE_DIRS) | |||
|
|||
_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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the comment confusing. Why should the variable change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing hexfile here to flashfile comes later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because changing to FLASHFILE
requires other changes in the flasher scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Makefile.include
Outdated
_LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) $$(find $(BASELIBS) -size +8c) $(LINKFLAGS) $(LINKFLAGPREFIX)-no_pie | ||
else | ||
_LINK = $(if $(CPPMIX),$(LINKXX),$(LINK)) $(UNDEF) $(LINKFLAGPREFIX)--start-group $(BASELIBS) -lm $(LINKFLAGPREFIX)--end-group $(LINKFLAGS) $(LINKFLAGPREFIX)-Map=$(BINDIR)/$(APPLICATION).map | ||
endif # BUILDOSXNATIVE | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should you touch the file again in this PR, removing this comment would make the world a little better!
Makefile.include
Outdated
$(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add mentioning "info-buildsize" (which does not cause a rebuild)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried something.
$(Q)$(SIZE) $< | ||
|
||
$(HEXFILE): $(ELFFILE) | ||
$(Q)$(OBJCOPY) $(OFLAGS) $< $@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no -Oihex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Makefile.include
Outdated
.PHONY: ..in-docker-container | ||
# Target can depend on FORCE to force running build command every time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK.
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.PHONY
because 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
_LINK
variable to harmonize things.I tested it before but would like another run on a mac.
Issues/PRs references
Part of #8838