diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 83022d45ae8bc7..b703f32c72c4d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -113,12 +113,6 @@ jobs: find . -type f -name *.ko | \ xargs -I % cp --parents % dist/modules - - name: Assert compiled - if: ${{ env.AUTO_FROM_RANGE == 'true' }} - run: | - source ci/build.sh - assert_compiled - - name: Assert state if: ${{ failure() }} run: | @@ -126,6 +120,12 @@ jobs: set_step_fail "assert_state" echo "fatal=true" >> "$GITHUB_ENV" + - name: Assert compiled + if: ${{ !cancelled() && env.fatal != 'true' && env.AUTO_FROM_RANGE == 'true' }} + run: | + source ci/build.sh + assert_compiled + - name: Sparse if: ${{ !cancelled() && env.fatal != 'true' && env.CHECKS_SPARCE == 'true' }} run: | diff --git a/ci/build.sh b/ci/build.sh index 3522dba1c74d17..05046cc32e3cc8 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -718,6 +718,7 @@ compile_kernel_smatch() { compile_gcc_fanalyzer () { export step_name="gcc_fanalyzer" + local exceptions_file="ci/travis/deadcode_exceptions" local files=$(git diff --diff-filter=ACM --no-renames --name-only $base_sha..$head_sha) local regex='^[[:alnum:]/._-]+:[[:digit:]]+:[[:digit:]]+: .*$' local mail= @@ -730,6 +731,10 @@ compile_gcc_fanalyzer () { return 1 fi + if [[ -f $exceptions_file ]]; then + files=$(comm -13 <(sort $exceptions_file) <(echo $files | tr ' ' '\n' | sort)) + fi + while read file; do case "$file" in *.c) @@ -891,8 +896,17 @@ compile_clang_analyzer () { assert_compiled () { export step_name="assert_compiled" + local exceptions_file="ci/travis/deadcode_exceptions" local files=$(git diff --diff-filter=ACM --no-renames --name-only $base_sha..$head_sha) local fail=0 + local error=" + At least one file was not compiled during kernel compilation + Either: + 1. ensure the Kconfig is able to enable it/them + OR + 2. remove deadcode + OR + 3. add it/them in file '$exceptions_file'" echo "$step_name were compiled on range $base_sha..$head_sha" @@ -901,6 +915,11 @@ assert_compiled () { return 1 fi + # Allows deadcode + if [[ -f $exceptions_file ]]; then + files=$(comm -13 <(sort $exceptions_file) <(echo $files | tr ' ' '\n' | sort)) + fi + while read file; do case "$file" in *.c) @@ -909,7 +928,7 @@ assert_compiled () { compile_cmd=$(jq ".[] | select(.file == \"$abs_file\") | .command" compile_commands.json) if [[ -z "$compile_cmd" ]]; then - echo "::error file=$file,line=0::$step_name: Was not compiled during kernel compilation, ensure defconfig enables it" + echo "::error file=$file,line=0::$step_name: Was not compiled during kernel compilation." fail=1 fi ;; @@ -917,6 +936,10 @@ assert_compiled () { done <<< "$files" + if [[ "$fail" == "true" ]]; then + _fmt "::error ::$step_name: $error" + fi + return $fail } diff --git a/ci/symbols_depend.py b/ci/symbols_depend.py index 27cee4092b2b68..6bf8b76474f098 100644 --- a/ci/symbols_depend.py +++ b/ci/symbols_depend.py @@ -64,7 +64,7 @@ def track_if_blocks(symbol, target_kconfig): for kconfig in get_all_parent_kconfigs(path.dirname(target_kconfig)): if debug: - print(f"{target_kconfig}: Tracking if blocks at '{kconfig}'", + print(f"{target_kconfig}: Tracking if blocks at '{kconfig}' for symbol '{symbol}'", file=stderr) with open(kconfig, 'r') as f: lines = f.readlines() @@ -74,7 +74,7 @@ def track_if_blocks(symbol, target_kconfig): line_ = line.strip() if line.startswith('if '): stack.append(line[3:].strip()) - elif line_ == 'endif': + elif line_.startswith('endif'): if stack: stack.pop() elif line_.startswith('source') and line_.endswith('Kconfig"'):