Skip to content

Commit 4fb19c1

Browse files
CI softening of CCMRAM overflow for allyesconfig and stricter randconfig jobs (#1666)
1 parent 6376894 commit 4fb19c1

2 files changed

Lines changed: 93 additions & 4 deletions

File tree

.github/workflows/CI.yml

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,13 @@ jobs:
124124
target:
125125
- allyesconfig
126126
- allnoconfig
127-
- randconfig
127+
include:
128+
- target: allyesconfig
129+
build_flag: --tolerate-ccmram-overflow
128130

129131
env:
130132
TARGET: ${{ matrix.target }}
133+
BUILD_FLAG: ${{ matrix.build_flag }}
131134

132135
steps:
133136
- name: Checkout Repo
@@ -136,4 +139,39 @@ jobs:
136139
submodules: true
137140

138141
- name: build
139-
run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "KCONFIG_ALLCONFIG=configs/all.config make ${TARGET} && ./tools/build/build UNIT_TEST_STYLE=min"
142+
run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "KCONFIG_ALLCONFIG=configs/all.config make ${TARGET} && ./tools/build/build ${BUILD_FLAG} UNIT_TEST_STYLE=min"
143+
144+
kbuild-targets-random:
145+
runs-on: ubuntu-latest
146+
needs: basic_build
147+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
148+
149+
env:
150+
RANDOM_BUILD_COUNT: '5'
151+
152+
steps:
153+
- name: Checkout Repo
154+
uses: actions/checkout@v4
155+
with:
156+
submodules: true
157+
158+
- name: build
159+
# A new KCONFIG_SEED (derived from the commit SHA) is used for each iteration
160+
run: |
161+
docker run --rm \
162+
-e GITHUB_SHA \
163+
-e RANDOM_BUILD_COUNT \
164+
-v ${PWD}:/module bitcraze/builder bash -c '
165+
FAIL_COUNT=0
166+
for i in $(seq 1 "$RANDOM_BUILD_COUNT"); do
167+
SEED=$(( 0x${GITHUB_SHA:0:8} + i ))
168+
echo "=== Random build $i/$RANDOM_BUILD_COUNT ==="
169+
if ! KCONFIG_SEED=$SEED KCONFIG_ALLCONFIG=configs/all.config make randconfig || ! ./tools/build/build UNIT_TEST_STYLE=min; then
170+
FAIL_COUNT=$((FAIL_COUNT + 1))
171+
fi
172+
done
173+
if [ "$FAIL_COUNT" -ne 0 ]; then
174+
echo "ERROR: $FAIL_COUNT/$RANDOM_BUILD_COUNT random builds failed"
175+
fi
176+
exit $FAIL_COUNT
177+
'

tools/build/build

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,58 @@ set -e
33

44
scriptDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
55

6+
# Parse inputs
7+
special_case_build=0
8+
tolerate_ccmram_overflow=0
9+
if [ "$1" == "--tolerate-ccmram-overflow" ]; then
10+
special_case_build=1
11+
tolerate_ccmram_overflow=1
12+
shift
13+
fi
14+
615
${scriptDir}/test "${@}"
716
${scriptDir}/test_python "${@}"
8-
${scriptDir}/make "${@}"
9-
${scriptDir}/check_elf
17+
18+
if [ ${special_case_build} -eq 0 ]; then
19+
${scriptDir}/make "${@}"
20+
${scriptDir}/check_elf
21+
exit 0
22+
elif [ ${tolerate_ccmram_overflow} -eq 1 ]; then
23+
# Only issue a warning for CCMRAM overflow
24+
25+
# Catch build output
26+
set +e
27+
build_log=$(${scriptDir}/make "${@}" 2>&1)
28+
build_status=$?
29+
set -e
30+
printf '%s\n' "${build_log}"
31+
32+
if [ ${build_status} -eq 0 ]; then
33+
${scriptDir}/check_elf
34+
exit 0
35+
fi
36+
37+
# Check for CCMRAM overflow
38+
overflow_line=$(grep "region \`CCMRAM' overflowed" <<< "${build_log}" || true)
39+
if [ -z "${overflow_line}" ]; then
40+
exit ${build_status}
41+
fi
42+
43+
# Confirm the overflow is the *only* problem: any other linker diagnostic or
44+
# compile error means a real regression is hiding alongside it.
45+
ld_lines=$(grep -E "arm-none-eabi/bin/ld:" <<< "${build_log}" || true)
46+
unexpected_ld_lines=$(grep -v -E "will not fit in region \`CCMRAM'|region \`CCMRAM' overflowed by [0-9]+ bytes" <<< "${ld_lines}" || true)
47+
compile_errors=$(grep -E ": error:" <<< "${build_log}" | grep -v -F "collect2: error: ld returned 1 exit status" || true)
48+
49+
if [ -n "${unexpected_ld_lines}" ] || [ -n "${compile_errors}" ]; then
50+
exit ${build_status}
51+
fi
52+
53+
overflow_bytes=$(sed -n "s/.*region \`CCMRAM' overflowed by \([0-9]*\) bytes.*/\1/p" <<< "${overflow_line}" | head -1)
54+
echo "::warning::kbuild-targets (allyesconfig): CCMRAM overflow, by ${overflow_bytes} bytes — check_elf skipped, no .elf was produced."
55+
56+
exit 0
57+
else
58+
echo "Uknown special case build."
59+
exit 1
60+
fi

0 commit comments

Comments
 (0)