Skip to content

Build kernel (KSN) & WIFI A16 for LineageOS 23.0 with vendor module disables #22

Build kernel (KSN) & WIFI A16 for LineageOS 23.0 with vendor module disables

Build kernel (KSN) & WIFI A16 for LineageOS 23.0 with vendor module disables #22

Workflow file for this run

name: Build kernel (KSN) & WIFI A16
on:
workflow_dispatch:
inputs:
kernel_source_url:
description: 'URL of the kernel source repository'
required: true
default: 'https://github.com/LineageOS/android_kernel_oneplus_sm8150'
kernel_branch:
description: 'Branch of the kernel source'
required: true
default: 'lineage-22.1'
kernel_defconfig:
description: 'defconfig file to use'
required: true
default: 'lineage_sm8150_defconfig'
output_name:
description: 'Name of the output.zip'
required: false
default: 'OP7_KSN_wifi'
push:
branches:
- oneplus/OOS_SM8150_11.0
pull_request:
branches:
- oneplus/OOS_SM8150_11.0
jobs:
build:
runs-on: ubuntu-latest
env:
CCACHE_COMPILERCHECK: "%compiler% -dumpmachine; %compiler% -dumpversion"
CCACHE_NOHASHDIR: "true"
CCACHE_MAXSIZE: "2G"
CCACHE_HARDLINK: "true"
KERNEL_CMDLINE: "ARCH=arm64 LLVM=1 LLVM_IAS=1 O=out CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_ARM32=arm-linux-gnueabi- CLANG_TRIPLE=aarch64-linux-gnu-"
KERNEL_DEFCONFIG: ${{ github.event.inputs.kernel_defconfig || 'lineage_sm8150_defconfig' }}
KERNEL_SOURCE_URL: ${{ github.event.inputs.kernel_source_url || 'https://github.com/LineageOS/android_kernel_oneplus_sm8150' }}
KERNEL_BRANCH: ${{ github.event.inputs.kernel_branch || 'lineage-22.1' }}
OUTPUT_ZIP_NAME: ${{ github.event.inputs.output_name || 'OP7_KSN_wifi' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Checkout Kernel Source
run: |
git clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_SOURCE_URL}" kernel
cd kernel
git submodule update --init --recursive
cd ..
- name: Set up ccache
uses: hendrikmuhs/ccache-action@v1.2
- name: Cleanup space
run: |
sudo rm -rf /opt/ghc || true
sudo rm -rf "/usr/local/share/boost" || true
sudo rm -rf /usr/share/dotnet || true
sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true
- name: Install dependencies (LLVM 18 + cross-binutils)
run: |
sudo apt-get update -y
sudo apt-get install -y \
clang-18 llvm-18 lld-18 \
gcc-aarch64-linux-gnu gcc-arm-linux-gnueabi \
binutils-aarch64-linux-gnu binutils \
make python3 libssl-dev build-essential bc bison flex unzip \
ca-certificates xz-utils mkbootimg cpio device-tree-compiler git git-lfs
git clone https://github.com/khalidaboelmagd/AnyKernel3
rm -rf AnyKernel3/.git
- name: Get Version
id: get_version
run: |
cd kernel
git fetch --unshallow || true
COUNT=$(git rev-list --count HEAD)
echo "VERSION=$(expr ${COUNT:-0} + 10200)" >> $GITHUB_OUTPUT
cd ..
- name: KernelSU-Next setup
working-directory: ./kernel
run: |
export PATH=/usr/lib/llvm-18/bin:$PATH
curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/next/kernel/setup.sh" | bash -
# ===== MM skew patches =====
- name: Apply hugetlbpage fix patch
working-directory: kernel
run: |
set -euo pipefail
if ! grep -q 'pte_t \*ptep' arch/arm64/mm/hugetlbpage.c; then
sed -i '/pte_t \*pte = NULL;/a \ pte_t *ptep = NULL;' arch/arm64/mm/hugetlbpage.c || true
fi
sed -i 's/ptep = huge_pmd_share(mm, vma, addr, pud);/if (!ptep) ptep = huge_pmd_share(mm, vma, addr, pud);/' arch/arm64/mm/hugetlbpage.c || true
- name: Apply huge_memory try_to_unmap signature patch
working-directory: kernel
run: |
set -euo pipefail
sed -i 's/try_to_unmap(page, ttu_flags);/try_to_unmap(page, ttu_flags, NULL);/g' mm/huge_memory.c 2>/dev/null || true
sed -i 's/try_to_unmap(\s*page\s*,\s*ttu_flags\s*)/try_to_unmap(page, ttu_flags, NULL)/g' mm/huge_memory.c 2>/dev/null || true
- name: Fix split_huge_pmd call order
working-directory: kernel
run: |
set -euo pipefail
sed -Ei 's/split_huge_pmd\(([[:space:]]*)vma([[:space:]]*),([[:space:]]*)addr([[:space:]]*),([[:space:]]*)pmd([[:space:]]*)\);/split_huge_pmd(vma, pmd, addr);/g' fs/proc/task_mmu.c || true
- name: Neutralize mm->nr_ptes in khugepaged
working-directory: kernel
run: |
set -euo pipefail
sed -i 's/atomic_long_dec(&mm->nr_ptes);/\/\* compat: mm->nr_ptes removed \*\/ do {} while (0);/' mm/khugepaged.c || true
# ===== Kbuild blackholes (stop compilation regardless of Kconfig) =====
- name: Hard-blackhole unwanted Kbuild subtrees (CLK and NET)
working-directory: kernel
run: |
set -euo pipefail
disable_dir() {
local d="$1"
if [ -d "$d" ]; then
[ -f "$d/Makefile" ] && mv -f "$d/Makefile" "$d/Makefile.bak" || true
[ -f "$d/Kbuild" ] && mv -f "$d/Kbuild" "$d/Kbuild.bak" || true
printf '# disabled in CI for sm8150\nobj-y :=\nobj-m :=\n' > "$d/Makefile"
printf '# disabled in CI for sm8150\n' > "$d/Kbuild"
echo "[CI] Blackholed $d"
fi
}
# Clocks vendors causing provider API errors
disable_dir drivers/clk/bcm
disable_dir drivers/clk/berlin
disable_dir drivers/clk/hisilicon
# Networking families that drag IPv6/seg6/BPF/mac80211 stacks
disable_dir net/ipv6
disable_dir net/bridge
disable_dir net/8021q
disable_dir net/bluetooth
disable_dir net/9p
disable_dir net/netfilter
disable_dir net/mac80211
disable_dir net/llc
- name: Defensive seg6 header shim (IPv6 off)
working-directory: kernel
run: |
set -euo pipefail
hdr="include/net/seg6.h"
if [ -f "$hdr" ] && grep -q 'return net->ipv6.seg6_data;' "$hdr"; then
sed -i 's|return net->ipv6.seg6_data;|#ifdef CONFIG_IPV6\nreturn net->ipv6.seg6_data;\n#else\nreturn NULL;\n#endif|' "$hdr"
echo "[CI] Patched $hdr to tolerate CONFIG_IPV6=n"
fi
# Also guard direct include in filter.c if present
if [ -f net/core/filter.c ] && grep -q '^#include <net/seg6.h>' net/core/filter.c; then
sed -i 's|#include <net/seg6.h>|#if IS_ENABLED(CONFIG_IPV6_SEG6_BPF)\n#include <net/seg6.h>\n#endif|' net/core/filter.c
fi
# ===== fs Makefile filter for NFS stacks =====
- name: Filter NFS/LOCKD/SUNRPC from fs/Makefile
working-directory: kernel
run: |
set -euo pipefail
if ! grep -q 'CI filter: prevent NFS' fs/Makefile; then
{
echo ''
echo '# CI filter: prevent NFS/LOCKD/SUNRPC from building regardless of Kconfig'
echo 'subdir-y := $(filter-out nfs lockd nfs_common sunrpc,$(subdir-y))'
echo 'subdir-m := $(filter-out nfs lockd nfs_common sunrpc,$(subdir-m))'
} >> fs/Makefile
fi
# ===== ACPI subtree filter on DT/arm64 =====
- name: Filter ACPI dir from drivers/Makefile
working-directory: kernel
run: |
set -euo pipefail
if ! grep -q 'CI filter: prevent ACPI' drivers/Makefile; then
{
echo ''
echo '# CI filter: prevent ACPI from building on DT/arm64 Android'
echo 'subdir-y := $(filter-out acpi,$(subdir-y))'
echo 'subdir-m := $(filter-out acpi,$(subdir-m))'
} >> drivers/Makefile
fi
# ===== 1) defconfig =====
- name: Prepare kernel output directory (defconfig)
working-directory: kernel
run: |
set -euo pipefail
export PATH=/usr/lib/llvm-18/bin:$PATH
export HOSTCC=clang-18
export HOSTCXX=clang++-18
mkdir -p out
make O=out ARCH=arm64 ${KERNEL_DEFCONFIG}
# ===== 2) Non-interactive finalize + hard enforcement =====
- name: Finalize kernel config (non-interactive + enforce)
working-directory: kernel
run: |
set -euo pipefail
export PATH=/usr/lib/llvm-18/bin:$PATH
cat > ../ci.defaults <<'EOF'
CONFIG_QTI_GVM=n
CONFIG_NR_CPUS=8
# MM/hugepage off
CONFIG_HUGETLB_PAGE=n
CONFIG_HUGETLBFS=n
CONFIG_TRANSPARENT_HUGEPAGE=n
CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS=n
CONFIG_TRANSPARENT_HUGEPAGE_MADVISE=n
CONFIG_KSM=n
# FS / stats off
CONFIG_BTRFS_FS=n
CONFIG_BTRFS_FS_POSIX_ACL=n
CONFIG_TASKSTATS=n
CONFIG_TASK_DELAY_ACCT=n
CONFIG_TASK_XACCT=n
CONFIG_TASK_IO_ACCOUNTING=n
CONFIG_NFS_FS=n
CONFIG_NFS_V4=n
CONFIG_LOCKD=n
CONFIG_SUNRPC=n
# Networking trims (avoid IPv6/seg6/BPF/mac80211/netfilter)
CONFIG_IPV6=n
CONFIG_IPV6_SEG6_LWTUNNEL=n
CONFIG_IPV6_SEG6_BPF=n
CONFIG_BPF_SYSCALL=n
CONFIG_BPF_JIT=n
CONFIG_NETFILTER=n
CONFIG_NETFILTER_ADVANCED=n
CONFIG_NETFILTER_XTABLES=n
CONFIG_XDP_SOCKETS=n
CONFIG_NET_CLS_BPF=n
CONFIG_NET_ACT_BPF=n
CONFIG_MAC80211=n
CONFIG_BT=n
CONFIG_VLAN_8021Q=n
CONFIG_NET_9P=n
CONFIG_9P_FS=n
# Vendor clocks off
CONFIG_COMMON_CLK_BCM=n
CONFIG_CLK_BCM_IPROC=n
CONFIG_CLK_BCM2835=n
CONFIG_COMMON_CLK_HI3660=n
CONFIG_COMMON_CLK_HI3670=n
CONFIG_COMMON_CLK_HI6220=n
# ACPI off
CONFIG_ACPI=n
CONFIG_ACPI_EC=n
CONFIG_ACPI_LPSS=n
CONFIG_ACPI_APEI=n
CONFIG_ACPI_APD=n
CONFIG_ACPI_PCI_SLOT=n
CONFIG_ACPI_PCI_ROOT=n
# PCI extras off
CONFIG_PCI_QUIRKS=n
CONFIG_PCIEAER=n
CONFIG_PCIEPORTBUS=n
# Non-interactive defaults
CONFIG_COMPILE_TEST=n
CONFIG_LOCALVERSION=""
CONFIG_LOCALVERSION_AUTO=y
CONFIG_KERNEL_GZIP=y
CONFIG_KERNEL_BZIP2=n
CONFIG_KERNEL_LZMA=n
CONFIG_KERNEL_XZ=n
CONFIG_KERNEL_LZO=n
CONFIG_KERNEL_LZ4=n
CONFIG_CROSS_COMPILE="aarch64-linux-gnu-"
EOF
make O=out ARCH=arm64 olddefconfig KCONFIG_ALLCONFIG=../ci.defaults
if [ -x scripts/config ]; then
./scripts/config --file out/.config \
--disable CONFIG_QTI_GVM --set-val CONFIG_NR_CPUS 8 \
--disable CONFIG_HUGETLB_PAGE --disable CONFIG_HUGETLBFS \
--disable CONFIG_TRANSPARENT_HUGEPAGE --disable CONFIG_TRANSPARENT_HUGEPAGE_ALWAYS --disable CONFIG_TRANSPARENT_HUGEPAGE_MADVISE \
--disable CONFIG_KSM \
--disable CONFIG_BTRFS_FS --disable CONFIG_BTRFS_FS_POSIX_ACL \
--disable CONFIG_TASKSTATS --disable CONFIG_TASK_DELAY_ACCT --disable CONFIG_TASK_XACCT --disable CONFIG_TASK_IO_ACCOUNTING \
--disable CONFIG_NFS_FS --disable CONFIG_NFS_V4 --disable CONFIG_LOCKD --disable CONFIG_SUNRPC \
--disable CONFIG_IPV6 --disable CONFIG_IPV6_SEG6_LWTUNNEL --disable CONFIG_IPV6_SEG6_BPF \
--disable CONFIG_BPF_SYSCALL --disable CONFIG_BPF_JIT \
--disable CONFIG_NETFILTER --disable CONFIG_NETFILTER_ADVANCED --disable CONFIG_NETFILTER_XTABLES \
--disable CONFIG_XDP_SOCKETS --disable CONFIG_NET_CLS_BPF --disable CONFIG_NET_ACT_BPF \
--disable CONFIG_MAC80211 --disable CONFIG_BT --disable CONFIG_VLAN_8021Q \
--disable CONFIG_NET_9P --disable CONFIG_9P_FS \
--disable CONFIG_COMMON_CLK_BCM --disable CONFIG_CLK_BCM_IPROC --disable CONFIG_CLK_BCM2835 \
--disable CONFIG_COMMON_CLK_HI3660 --disable CONFIG_COMMON_CLK_HI3670 --disable CONFIG_COMMON_CLK_HI6220 \
--disable CONFIG_ACPI --disable CONFIG_ACPI_EC --disable CONFIG_ACPI_LPSS --disable CONFIG_ACPI_AP