Page 1 of 1

Surprised by change in rules.mk

Posted: Mon Mar 23, 2026 7:14 pm
by geoffrey.brown
I'm working on porting my projects from 20.3 to 21.11 and found the following surprising change in rules.mk (from ARMCMx/...../GCC)

< IINCDIR := $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
> IINCDIR := $(sort $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR)))

Not sure why a decision was made to sort the user includes, but order matters in complex builds.

Geoffrey

Re: Surprised by change in rules.mk

Posted: Tue Mar 24, 2026 4:11 am
by Giovanni
Hi,

It is done to remove duplicate paths, some .mk files add the same paths to shared modules.

This can be a problem only if you have colliding file names in your paths, which should be avoided if possible.

Giovanni

Re: Surprised by change in rules.mk

Posted: Tue Mar 24, 2026 2:53 pm
by geoffrey.brown
I guess my use situation is unusual. I have a whole collection of related devices (data loggers for songbirds) and I do sometimes need to override include files in my common source code and I have had, on occasion, to tweak include files from the chibios directories. In the short run, I tweaked the the rules file, but I guess in the long run I'll have to track down and eliminate the problem cases.

Re: Surprised by change in rules.mk

Posted: Thu Apr 02, 2026 2:06 pm
by geoffrey.brown
I've thought about this a bit more, is there a compelling reason to sort UINC with all the other includes. As it stands, there is no way to override an existing include file.

Re: Surprised by change in rules.mk

Posted: Thu Apr 02, 2026 7:59 pm
by Giovanni
Hi,

You could simply bring rules.mk in your project and tweak it, it is just an inclusion in your makefile, not something that can break later anyway.

Giovanni