Skip to content
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

Merged
merged 2 commits into from
Apr 9, 2018

Conversation

cladmi
Copy link
Contributor

@cladmi cladmi commented Mar 28, 2018

Contribution description

  • Add ELFFILE, HEXFILE, print-size targets

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

@cladmi cladmi added Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Mar 28, 2018
@cladmi
Copy link
Contributor Author

cladmi commented Mar 28, 2018

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
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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!
Copy link
Contributor

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)
Copy link
Contributor

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)

Copy link
Contributor Author

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) $< $@
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no -Oihex?

Copy link
Contributor Author

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.

Copy link
Contributor

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
Copy link
Contributor

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
@cladmi cladmi force-pushed the pr/make/split_link_target branch from 6ae3c67 to f64de06 Compare April 9, 2018 14:52
@kaspar030 kaspar030 added CI: run tests If set, CI server will run tests on hardware for the labeled PR CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Apr 9, 2018
Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

@kaspar030 kaspar030 merged commit c23eb5a into RIOT-OS:master Apr 9, 2018
@cladmi cladmi deleted the pr/make/split_link_target branch April 9, 2018 15:26
@cladmi
Copy link
Contributor Author

cladmi commented Apr 9, 2018

Thank you for the review, I rebased #8845 which is the next one in the list.

@miri64
Copy link
Member

miri64 commented Apr 10, 2018

Sadly, this PR introduced a problem :( (see #8910)

cladmi added a commit to cladmi/RIOT that referenced this pull request Apr 10, 2018
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
cladmi added a commit to cladmi/RIOT that referenced this pull request Apr 10, 2018
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
cladmi added a commit to cladmi/RIOT that referenced this pull request Apr 10, 2018
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
cladmi added a commit to cladmi/RIOT that referenced this pull request Apr 10, 2018
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
cladmi added a commit to cladmi/RIOT that referenced this pull request Apr 16, 2018
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
maxvankessel pushed a commit to maxvankessel/RIOT that referenced this pull request Apr 20, 2018
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
jcarrano pushed a commit to jcarrano/RIOT that referenced this pull request May 7, 2018
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
jcarrano pushed a commit to jcarrano/RIOT that referenced this pull request May 9, 2018
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
@miri64 miri64 mentioned this pull request Jun 4, 2018
8 tasks
jia200x pushed a commit to jia200x/RIOT that referenced this pull request Jun 11, 2018
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
panail pushed a commit to panail/RIOT that referenced this pull request Oct 29, 2018
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
@cladmi cladmi added this to the Release 2018.04 milestone Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants