Fix : gh #256 : Use -O0 not -o0 to set optimisation level for TARGET=linux - #258
Fix : gh #256 : Use -O0 not -o0 to set optimisation level for TARGET=linux#258Ulrond wants to merge 2 commits into
Conversation
-o0 was replaced with -O0 to correctly set optimisation level. This issue only happens with build target LINUX Fixes #256
|
I have read the CLA Document and I hereby sign the CLA 1 out of 2 committers have signed the CLA. |
There was a problem hiding this comment.
Pull request overview
Fixes a build-flag typo in the TARGET=linux Makefile branch where -o0 (output file) was incorrectly used instead of -O0 (optimization level 0), which could cause downstream builds (notably the ut-control sub-make invocation) to emit an unintended output file named 0.
Changes:
- Replace
-o0with-O0in the LinuxCOMPILERdefinition. - Replace
-o0with-O0in the LinuxUT_CONTROL_COMPILERdefinition (used when invoking the ut-control sub-make).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adds check_makefile_flags to the tests suite, alongside the existing
check_macros static gate.
Two checks:
scan walks the build files for a lowercase -o glued to an
optimisation level (-o0, -os, -og). gcc accepts these
silently and a later -o $@ on the same command line wins,
so nothing ever fails - which is why #256 went unnoticed.
expect asks make printenv what COMPILER and UT_CONTROL_COMPILER
actually expand to and asserts -ggdb -O0 -Wall are present,
catching the flags being dropped as well as mistyped.
Runs before the framework build so a flag typo is reported in
seconds rather than after a full compile. Expectations apply to
TARGET=linux only; arm takes its compiler from the SDK.
Verified by reintroducing -o0: both checks fail, exit 1.
Refs #256
23e5268 to
8646879
Compare
| NC='\033[0m' | ||
|
|
||
| .PHONY: clean list build all | ||
| .PHONY: clean list build all check_macros check_makefile_flags |
| NC='\033[0m' | ||
|
|
||
| .PHONY: clean list build all | ||
| .PHONY: clean list build all check_macros check_makefile_flags |
Fixes #256
Applies the patch supplied by @looopTools in the issue, with authorship preserved via
git am.-o0is not an optimisation flag — lowercase-ois "write output to this file", so-o0asks for a file named0. TheTARGET=linuxbranch of the Makefile used it in two places; both are now-O0.TARGET=armis untouched — it takes$(CC)/$(CXX)from the SDK and never carried the flag.Note for reviewers: where the stray
0file actually comes fromEvery compile/link rule in ut-core appends its own
-o $@after$(COMPILER)(Makefile lines 152, 167, 172, 191, 198), and GCC lets the last-owin —gcc -ggdb -o0 -Wall -c t.c -o t.oexits 0 and producest.o, no file named0. So ut-core's own objects were named correctly; what was silently lost is the intended-O0(benign in practice, as-O0is gcc's default).The object-naming symptom in the issue shows up downstream:
UT_CONTROL_COMPILERis handed to the ut-control sub-make asCC="gcc -ggdb -o0 -Wall", and any command there that supplies no-oof its own writes a file called0. The sibling typo in ut-control itself is rdkcentral/ut-control#130.Verification
make printenv TARGET=linuxnow reportsCOMPILER [ gcc -ggdb -O0 -Wall].grep -rn '\-o0' --include=Makefile --include=*.mk --include=*.sh .returns no hits.make TARGET=linux VARIANT=CPPundertests/: full success,ut-testlinks.make TARGET=linuxundertests/: all objects compile andut-testlinks. The run then stops on the pre-existingcheck_macrosgate (30/33 macros documented inut_cunit.h), which is source-content based and unaffected by compiler flags.0anywhere in the tree after either clean build.Second commit: a regression guard in the tests suite
The typo itself is two characters, but it survived because no functional test could ever have caught it — gcc accepted
-o0, the later-o $@won, and-O0is gcc's default, so every build stayed green and every binary stayed correct. Only a static check on the build files can see it.tests/check_makefile_flags.pyis wired into the suite ascheck_makefile_flags, alongside the existingcheck_macrosgate, and runs before the framework build so a flag typo costs seconds rather than a full compile.Two checks:
scanMakefile/*.mk/*.shfor a lowercase-oglued to an optimisation level —-o0,-os,-og,-ofast. Comments are stripped before matching, so prose describing the typo does not trip it. Third-party trees (framework/,build/,cpp_libs/) are skipped.expectmake printenvwhatCOMPILERandUT_CONTROL_COMPILERactually expand to and asserts-ggdb -O0 -Wallare present. This catches the flags being dropped or overridden, not just mistyped.Expectations apply to
TARGET=linuxonly —armtakes its compiler from the SDK.Verified by reintroducing
-o0on top of the fix:Both checks fire,
makeexits 1. On the fixed tree: 25 build files scanned, 0 findings, 2/2 expectations met — confirmed forTARGET=linux,VARIANT=CPP, andTARGET=arm(scan only).