From 6b75d8b30d3871247fd919d2b65e657a0b0eee21 Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Sun, 30 Aug 2026 23:22:03 +0700 Subject: [PATCH 01/14] dipper: add baseline Android 15 kernel build --- config/dipper-baseline.env | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 config/dipper-baseline.env diff --git a/config/dipper-baseline.env b/config/dipper-baseline.env new file mode 100644 index 0000000000..bb034665b6 --- /dev/null +++ b/config/dipper-baseline.env @@ -0,0 +1,36 @@ +KERNEL_SOURCE=https://github.com/LineageOS/android_kernel_xiaomi_sdm845.git +KERNEL_SOURCE_BRANCH=lineage-22.1 + +KERNEL_CONFIG=vendor/xiaomi/mi845_defconfig +KERNEL_IMAGE_NAME=Image.gz-dtb +ARCH=arm64 + +# Kernel 4.9: dùng toolchain cũ/an toàn hơn +CLANG_BRANCH=master-kernel-build-2022 +CLANG_VERSION=r450784e + +USE_LLVM=false +ENABLE_GCC_ARM64=true +ENABLE_GCC_ARM32=true + +# ----- ROOT ----- +KSU_VARIANT=none +KSU_REF= +KSU_HOOK_MODE=none + +# ----- SUSFS ----- +ENABLE_SUSFS=false +ENABLE_PATH_UMOUNT=false +ENABLE_HIDE_STUFF=false +ENABLE_KPM=false + +# Không tự bật KPROBES +ADD_KPROBES_CONFIG=false + +ADD_OVERLAYFS_CONFIG=true + +# Chưa đóng gói boot.img tự động +BUILD_BOOT_IMG=false +NEED_DTBO=false + +ENABLE_CCACHE=true \ No newline at end of file From 281ad36ae9e0c07198a2cb610afd5141f2bfaa3e Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Sun, 30 Aug 2026 23:41:02 +0700 Subject: [PATCH 02/14] dipper: add baseline Android 15 kernel build fix v1 --- config/dipper-baseline.env | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/config/dipper-baseline.env b/config/dipper-baseline.env index bb034665b6..3c41e65dc6 100644 --- a/config/dipper-baseline.env +++ b/config/dipper-baseline.env @@ -9,11 +9,16 @@ ARCH=arm64 CLANG_BRANCH=master-kernel-build-2022 CLANG_VERSION=r450784e -USE_LLVM=false -ENABLE_GCC_ARM64=true -ENABLE_GCC_ARM32=true - -# ----- ROOT ----- +USE_LLVM=false +ENABLE_GCC_ARM64=true +ENABLE_GCC_ARM32=true + +# The Android-targeted Clang prebuilt is rejected by this 4.9 Kbuild unless +# its GNU binutils target is stated explicitly. Keep this baseline-only: +# it changes no kernel configuration or runtime behaviour. +CUSTOM_CMDS=CLANG_TRIPLE=aarch64-linux-gnu- + +# ----- ROOT ----- KSU_VARIANT=none KSU_REF= KSU_HOOK_MODE=none @@ -33,4 +38,4 @@ ADD_OVERLAYFS_CONFIG=true BUILD_BOOT_IMG=false NEED_DTBO=false -ENABLE_CCACHE=true \ No newline at end of file +ENABLE_CCACHE=true From 4f1cd8346aeb1a708900dd9cfba46756737577ce Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Sun, 30 Aug 2026 23:51:51 +0700 Subject: [PATCH 03/14] dipper: default manual builds to baseline profile --- .github/workflows/build-kernel.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-kernel.yml b/.github/workflows/build-kernel.yml index e324ce6fc5..9622bb9c8a 100644 --- a/.github/workflows/build-kernel.yml +++ b/.github/workflows/build-kernel.yml @@ -9,7 +9,10 @@ on: config: description: "Config file to build (path, relative to the repo root)" required: false - default: "config.env" + # This branch is the Mi 8 baseline stage. Keeping its profile as the + # dispatch default prevents an accidental build of the repository's + # generic config.env (which targets a different device). + default: "config/dipper-baseline.env" type: string # "config" on the options below means "use whatever the config file says". # It is the default so that running the form without touching anything From dffadaccd806b6a3e1202f3749a7abeb5dbe001b Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Sun, 30 Aug 2026 23:52:22 +0700 Subject: [PATCH 04/14] dipper: use lld in baseline build --- config/dipper-baseline.env | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/dipper-baseline.env b/config/dipper-baseline.env index 3c41e65dc6..86faa8d653 100644 --- a/config/dipper-baseline.env +++ b/config/dipper-baseline.env @@ -17,6 +17,9 @@ ENABLE_GCC_ARM32=true # its GNU binutils target is stated explicitly. Keep this baseline-only: # it changes no kernel configuration or runtime behaviour. CUSTOM_CMDS=CLANG_TRIPLE=aarch64-linux-gnu- +# Use the linker shipped with the same AOSP Clang package; do not fall back to +# the runner's host linker during the later link stage. +EXTRA_CMDS=LD=ld.lld # ----- ROOT ----- KSU_VARIANT=none From 0a39e45ded4f86bfbfd1d6117e183526ce0550d1 Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Mon, 31 Aug 2026 00:02:31 +0700 Subject: [PATCH 05/14] dipper: use integrated assembler for VDSO --- config/dipper-baseline.env | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config/dipper-baseline.env b/config/dipper-baseline.env index 86faa8d653..22558bc3ce 100644 --- a/config/dipper-baseline.env +++ b/config/dipper-baseline.env @@ -17,9 +17,10 @@ ENABLE_GCC_ARM32=true # its GNU binutils target is stated explicitly. Keep this baseline-only: # it changes no kernel configuration or runtime behaviour. CUSTOM_CMDS=CLANG_TRIPLE=aarch64-linux-gnu- -# Use the linker shipped with the same AOSP Clang package; do not fall back to -# the runner's host linker during the later link stage. -EXTRA_CMDS=LD=ld.lld +# Use the linker and integrated assembler shipped with the same AOSP Clang +# package. Clang 14 otherwise delegates VDSO assembly to the legacy GNU +# assembler, which rejects Clang's generated .file directives. +EXTRA_CMDS=LD=ld.lld LLVM_IAS=1 # ----- ROOT ----- KSU_VARIANT=none From a996cab754e9e7f8ff158d58799d63bbe0f830a3 Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Mon, 31 Aug 2026 00:14:51 +0700 Subject: [PATCH 06/14] fix: supply ARM32 linker path to compat VDSO --- scripts/build.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/build.sh b/scripts/build.sh index 0f62c1bb0d..5e58582ba1 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -97,6 +97,17 @@ make_args() { [ -n "${EXTRA_CMDS:-}" ] && printf ' %s' "$EXTRA_CMDS" [ -n "${GCC_64:-}" ] && printf ' %s' "$GCC_64" [ -n "${GCC_32:-}" ] && printf ' %s' "$GCC_32" + # Legacy arm64 Android kernels link their compat (32-bit) VDSO by invoking + # clang directly with --target=arm-linux-androideabi. The old Makefiles do + # not add the downloaded GCC 4.9 bin directory to that clang invocation, so + # clang falls back to the runner's x86 /usr/bin/ld. -B makes the matching + # arm-linux-androideabi-ld discoverable without changing the kernel source. + if [[ "${GCC_32:-}" == CROSS_COMPILE_ARM32=* ]]; then + local arm32_prefix arm32_bin + arm32_prefix=${GCC_32#CROSS_COMPILE_ARM32=} + arm32_bin=${arm32_prefix%/*} + [ "$arm32_bin" != "$arm32_prefix" ] && printf ' KCFLAGS=-B%s/' "$arm32_bin" + fi if is_true "${USE_LLVM:-false}"; then printf ' LLVM=1 LLVM_IAS=1' [ -n "${GCC_64:-}" ] || printf ' CROSS_COMPILE=aarch64-linux-gnu-' From 65d90365f06dfb9136bd0d799cbc1c098d499aa1 Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Mon, 31 Aug 2026 00:23:43 +0700 Subject: [PATCH 07/14] fix: force lld for compat VDSO links --- scripts/build.sh | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 5e58582ba1..d4c83f3f50 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -97,17 +97,6 @@ make_args() { [ -n "${EXTRA_CMDS:-}" ] && printf ' %s' "$EXTRA_CMDS" [ -n "${GCC_64:-}" ] && printf ' %s' "$GCC_64" [ -n "${GCC_32:-}" ] && printf ' %s' "$GCC_32" - # Legacy arm64 Android kernels link their compat (32-bit) VDSO by invoking - # clang directly with --target=arm-linux-androideabi. The old Makefiles do - # not add the downloaded GCC 4.9 bin directory to that clang invocation, so - # clang falls back to the runner's x86 /usr/bin/ld. -B makes the matching - # arm-linux-androideabi-ld discoverable without changing the kernel source. - if [[ "${GCC_32:-}" == CROSS_COMPILE_ARM32=* ]]; then - local arm32_prefix arm32_bin - arm32_prefix=${GCC_32#CROSS_COMPILE_ARM32=} - arm32_bin=${arm32_prefix%/*} - [ "$arm32_bin" != "$arm32_prefix" ] && printf ' KCFLAGS=-B%s/' "$arm32_bin" - fi if is_true "${USE_LLVM:-false}"; then printf ' LLVM=1 LLVM_IAS=1' [ -n "${GCC_64:-}" ] || printf ' CROSS_COMPILE=aarch64-linux-gnu-' @@ -135,9 +124,15 @@ build_kernel() { fi local cc="clang" args + # Android 4.9's compat VDSO links through CC directly, bypassing the make + # variable LD. When a profile selects ld.lld, make Clang select it too so + # VDSO32 cannot accidentally invoke the runner's x86 /usr/bin/ld. + case " ${EXTRA_CMDS:-} " in + *" LD=ld.lld "*) cc="clang -fuse-ld=lld" ;; + esac args=$(make_args) if is_true "${ENABLE_CCACHE:-true}" && command -v ccache >/dev/null; then - cc="ccache clang" + cc="ccache ${cc}" export CCACHE_DIR="${CCACHE_DIR:-${WORKSPACE}/.ccache}" info "ccache enabled (dir: ${CCACHE_DIR})" fi From 91972b687795bd6e978341a848ad9981ca11ab8a Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Mon, 31 Aug 2026 00:36:05 +0700 Subject: [PATCH 08/14] dipper: allow legacy tree warnings during baseline build --- config/dipper-baseline.env | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/config/dipper-baseline.env b/config/dipper-baseline.env index 22558bc3ce..4e257772e3 100644 --- a/config/dipper-baseline.env +++ b/config/dipper-baseline.env @@ -33,12 +33,16 @@ ENABLE_PATH_UMOUNT=false ENABLE_HIDE_STUFF=false ENABLE_KPM=false -# Không tự bật KPROBES -ADD_KPROBES_CONFIG=false - -ADD_OVERLAYFS_CONFIG=true - -# Chưa đóng gói boot.img tự động +# Không tự bật KPROBES +ADD_KPROBES_CONFIG=false + +ADD_OVERLAYFS_CONFIG=true +# This 4.9 vendor tree promotes diagnostics introduced by modern Clang to +# errors (for example packed-member and int-in-bool-context). It does not +# affect the generated kernel; it only lets the legacy tree compile. +DISABLE_CC_WERROR=true + +# Chưa đóng gói boot.img tự động BUILD_BOOT_IMG=false NEED_DTBO=false From a2547535b789d3167b5155c2c38d62d0f1ccdc88 Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Mon, 31 Aug 2026 00:57:27 +0700 Subject: [PATCH 09/14] fix: make legacy warning override effective --- scripts/build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/build.sh b/scripts/build.sh index d4c83f3f50..1bf20e24f4 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -97,6 +97,10 @@ make_args() { [ -n "${EXTRA_CMDS:-}" ] && printf ' %s' "$EXTRA_CMDS" [ -n "${GCC_64:-}" ] && printf ' %s' "$GCC_64" [ -n "${GCC_32:-}" ] && printf ' %s' "$GCC_32" + # Some Android 4.9 vendor trees append -Werror directly in their Makefiles, + # so CONFIG_CC_WERROR alone cannot override it. KCFLAGS is appended after + # the tree's flags, preserving diagnostics while making them non-fatal. + is_true "${DISABLE_CC_WERROR:-false}" && printf ' KCFLAGS=-Wno-error' if is_true "${USE_LLVM:-false}"; then printf ' LLVM=1 LLVM_IAS=1' [ -n "${GCC_64:-}" ] || printf ' CROSS_COMPILE=aarch64-linux-gnu-' From d3be278e992a70f7945c8d1193d119a2ab38205c Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Mon, 31 Aug 2026 01:21:55 +0700 Subject: [PATCH 10/14] ci: print concise kernel build errors --- .github/workflows/build-kernel.yml | 36 +++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-kernel.yml b/.github/workflows/build-kernel.yml index 9622bb9c8a..a3bf05d017 100644 --- a/.github/workflows/build-kernel.yml +++ b/.github/workflows/build-kernel.yml @@ -189,7 +189,41 @@ jobs: max-size: 2G - name: Build kernel - run: bash scripts/build.sh all + shell: bash + run: | + # Keep the web log readable. The complete compiler output remains + # available as an artifact below when a deeper investigation is + # needed. + build_log="$RUNNER_TEMP/kernel-build.log" + if bash scripts/build.sh all >"$build_log" 2>&1; then + echo "Kernel build completed. Last 80 log lines:" + tail -n 80 "$build_log" + exit 0 + else + status=$? + echo "::error::Kernel build failed. Showing the first error with context; download the kernel-build-log artifact for the complete output." + first_error=$(grep -n -m1 -E '(^|[[:space:]])(fatal[[:space:]]+)?error:|undefined reference|collect2: error' "$build_log" || true) + if [ -n "$first_error" ]; then + line=${first_error%%:*} + start=$(( line > 25 ? line - 25 : 1 )) + end=$(( line + 40 )) + echo "First error at log line $line:" + sed -n "${start},${end}p" "$build_log" + else + echo "No compiler-style error line was found; last 120 log lines:" + tail -n 120 "$build_log" + fi + exit "$status" + fi + + - name: Upload complete kernel build log + if: always() + uses: actions/upload-artifact@v4 + with: + name: kernel-build-log-${{ env.DEVICE }}-${{ github.run_id }} + path: ${{ runner.temp }}/kernel-build.log + if-no-files-found: warn + retention-days: 7 - name: Package artifacts run: bash scripts/package.sh all From fab5a6d093c0d8677037ac8f89d5a6e11ba10d35 Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Mon, 31 Aug 2026 01:30:54 +0700 Subject: [PATCH 11/14] fix: retry incomplete toolchain archives --- scripts/lib.sh | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/scripts/lib.sh b/scripts/lib.sh index 3dc909eab0..01dec46d00 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -103,13 +103,42 @@ retry() { # ------------------------------------------------------------- downloading --- -# fetch URL DEST -- resumable, retrying download. +# fetch URL DEST -- retrying download with an integrity check for archives. fetch() { - local url=$1 dest=$2 + local url=$1 dest=$2 tmp="${2}.partial" + local attempt=1 delay=5 info "fetching ${url}" - retry 4 curl -fsSL --connect-timeout 30 --retry 3 --retry-delay 3 -o "$dest" "$url" \ - || die "failed to download ${url}" - [ -s "$dest" ] || die "downloaded file is empty: ${url}" + rm -f "$dest" "$tmp" + + while [ "$attempt" -le 4 ]; do + # Do not write straight to DEST: a proxy/server can terminate a streamed + # archive cleanly enough for curl to exit 0, while gzip/tar later finds an + # unexpected EOF. Only promote a verified file to DEST. + if curl -fsSL --connect-timeout 30 --retry 3 --retry-delay 3 \ + --retry-all-errors -o "$tmp" "$url" && [ -s "$tmp" ]; then + case "$dest" in + *.tar.gz | *.tgz) gzip -t "$tmp" ;; + *.tar.xz) xz -t "$tmp" ;; + *.tar.zst) zstd -tq "$tmp" ;; + *.tar.bz2) bzip2 -t "$tmp" ;; + *.tar) tar -tf "$tmp" >/dev/null ;; + *.zip) unzip -tqq "$tmp" ;; + *) true ;; + esac && { + mv "$tmp" "$dest" + return 0 + } + fi + + rm -f "$tmp" + if [ "$attempt" -lt 4 ]; then + warn "download was incomplete or invalid; retrying in ${delay}s (${attempt}/4): ${url}" + sleep "$delay" + delay=$((delay * 2)); [ "$delay" -gt 60 ] && delay=60 + fi + attempt=$((attempt + 1)) + done + die "failed to download a valid file after 4 attempts: ${url}" } # fetch_stdout URL -- print a URL's body, retrying. Used for small text files. From 8583177ab8b31d566a7a0cc9d0e92bdad257ee4d Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Mon, 31 Aug 2026 01:51:37 +0700 Subject: [PATCH 12/14] ci: capture uppercase and make build errors --- .github/workflows/build-kernel.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-kernel.yml b/.github/workflows/build-kernel.yml index a3bf05d017..30dff8f372 100644 --- a/.github/workflows/build-kernel.yml +++ b/.github/workflows/build-kernel.yml @@ -202,7 +202,10 @@ jobs: else status=$? echo "::error::Kernel build failed. Showing the first error with context; download the kernel-build-log artifact for the complete output." - first_error=$(grep -n -m1 -E '(^|[[:space:]])(fatal[[:space:]]+)?error:|undefined reference|collect2: error' "$build_log" || true) + # DTC reports failures as uppercase "ERROR:", while make itself + # may be the only process that prints an error marker. Match both + # forms so parallel compiler output cannot hide the true failure. + first_error=$(grep -ni -m1 -E '(^|[[:space:]])(fatal[[:space:]]+)?error:|undefined reference|collect2: error|make(\[[0-9]+\])?: \*\*\*' "$build_log" || true) if [ -n "$first_error" ]; then line=${first_error%%:*} start=$(( line > 25 ? line - 25 : 1 )) From 535fd99f4de5c98dd02af703195110244e379f1a Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Mon, 31 Aug 2026 02:18:50 +0700 Subject: [PATCH 13/14] dipper: skip unrelated QVR phandle check --- config/dipper-baseline.env | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/dipper-baseline.env b/config/dipper-baseline.env index 4e257772e3..71068e5891 100644 --- a/config/dipper-baseline.env +++ b/config/dipper-baseline.env @@ -20,7 +20,10 @@ CUSTOM_CMDS=CLANG_TRIPLE=aarch64-linux-gnu- # Use the linker and integrated assembler shipped with the same AOSP Clang # package. Clang 14 otherwise delegates VDSO assembly to the legacy GNU # assembler, which rejects Clang's generated .file directives. -EXTRA_CMDS=LD=ld.lld LLVM_IAS=1 +# The generic SDM845 build also emits an incomplete QVR-only DTS that refers +# to touchscreen labels absent from this source tree. Dipper's DTS does not +# use those labels; retain every other DTC check and suppress only that one. +EXTRA_CMDS=LD=ld.lld LLVM_IAS=1 DTC_FLAGS=-Wno-phandle_references # ----- ROOT ----- KSU_VARIANT=none From 466b51e262a7cb1a612fedc566b29c8c5cc96e4e Mon Sep 17 00:00:00 2001 From: Tuan Dat Date: Mon, 31 Aug 2026 02:42:31 +0700 Subject: [PATCH 14/14] dipper: disable QVR phandle error check correctly --- config/dipper-baseline.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/dipper-baseline.env b/config/dipper-baseline.env index 71068e5891..d789f68da7 100644 --- a/config/dipper-baseline.env +++ b/config/dipper-baseline.env @@ -23,7 +23,7 @@ CUSTOM_CMDS=CLANG_TRIPLE=aarch64-linux-gnu- # The generic SDM845 build also emits an incomplete QVR-only DTS that refers # to touchscreen labels absent from this source tree. Dipper's DTS does not # use those labels; retain every other DTC check and suppress only that one. -EXTRA_CMDS=LD=ld.lld LLVM_IAS=1 DTC_FLAGS=-Wno-phandle_references +EXTRA_CMDS=LD=ld.lld LLVM_IAS=1 DTC_FLAGS=-Eno-phandle_references # ----- ROOT ----- KSU_VARIANT=none