arch/*/src/Makefile: Avoid uncessary relinking of the nuttx binary.#18704
arch/*/src/Makefile: Avoid uncessary relinking of the nuttx binary.#18704liamhickey2 wants to merge 1 commit intoapache:masterfrom
Conversation
|
@liamhickey2 thank you very much for this improvement. |
Hi Alan, I just noticed it from the make output. It's not a very important issue, but sometimes I run make when I'm not sure if I've compiled my changes already. I thought maybe other people would appreciate it if I upstreamed that, even if the linking is not very time consuming. I'm looking into the failure in x86 (I can see its caused by the .tmp files being preserved), and I plan on uploading another sanity test since I ran that hardware test with a (patched) older version of nuttx. Sorry for the trouble, I haven't made any contributions to open source before. |
7e817cf to
2790c16
Compare
The goal is to only execute recipes when there is an actual change in the prerequisites. There are several issues which cause the nuttx binary target to be re-made every time the top level make is run. 1. Previously the target nuttx$(EXEEXT), was used, but make resolved this in the relative directory make -C $(ARCH_SRC), and couldn’t find it (need an absolute path: `$(TOPDIR)/..). 2. The .tmp prerequisite for nuttx was always deleted 3. libboard's recipe had a sub-make which may or may not update that target. This was a phony target, and was therefore always considered out of date. These issues were causing the nuttx recipe to be run every make, which was hiding some missing prerequisites: 1. the .config is a prerequisite for the .tmp target 2. libapps.a (and other linklibs) are pre-requisites for nuttx Changes: The changes are only in the build system, and only for arm. Track nuttx$(EXEEXT) via vpath so Make knows when it's already up to date without an explicit path. Add $(TOPDIR)/.config as a dependency to the linker script preprocessing so config changes trigger re-preprocessing. Keep the .tmp linker script on disk (clean already removes it) so timestamp-based dependency checking works across builds. Use FORCE pattern for board/libboard to ensure it's always checked but use the actual library file as the link dependency so nuttx is only re-linked when library content changes. Add staging libs as dependency to nuttx link rule so changed app libs trigger re-link. Signed-off-by: Liam Hickey <williamhickey@geotab.com>
2790c16 to
a7267b9
Compare
|
I'm not sure this failure is legitimate. Looking at the test output, there were no failing tests. Not sure if there's something I'm missing here: https://github.com/apache/nuttx/actions/runs/24398561469/job/71303607293?pr=18704 ================ 1224 passed, 548 skipped in 3745.46s (1:02:25) ================ |
Note: Please adhere to Contributing Guidelines.
Summary
The goal is to only execute recipes when there is an actual change in the prerequisites.
There were several issues which cause the nuttx binary target to be re-made every time the top level make is run, which was hiding some missing prerequisites.
Changes:
Impact
This change ensures that we only run the nuttx recipe (and others) if the prerequisites are meaningfully out of date. In other words, the make should be faster and have a more concise output when there were no changes made by the user.
Testing
Methodology:
Scripts were made to reproduce build/test steps (e.g. make and touching files).
The change has the intended effects:
The change doesn't have unintended effects:
Results:
Intended effects (script: test-results/test-intended.sh, output: test-results/test-intended.log):
Two consecutive make runs with no changes — neither triggers LD: nuttx:
--- make (no changes, attempt 1) ---
CP: nuttx.bin
--- end ---
--- make (no changes, attempt 2) ---
CP: nuttx.bin
--- end ---
No unintended effects (script: test-results/test-unintended.sh, output: test-results/test-unintended.log):
Touching a source file recompiles and relinks, then stabilizes:
--- make (after touching arch/arm/src/chip/qemu_boot.c) ---
CC: chip/qemu_boot.c IN: libarch.a -> staging/libarch.a LD: nuttx CP: nuttx.bin
--- make (no changes after source touch) ---
CP: nuttx.bin
Touching .config re-preprocesses linker script and relinks, then stabilizes:
--- make (after touching .config) ---
CPP: dramboot.ld -> dramboot.ld.tmp LD: nuttx CP: nuttx.bin
--- make (no changes after .config touch) ---
CP: nuttx.bin
test-results.zip
Sanity Hardware Test:
The changes are only in the build system, but this confirms that everything is still built/linked correctly.