Build kernel (KSN) & WIFI A16 for LineageOS 23.0 with vendor module disables #11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: Apply hugetlbpage fix patch | |
| working-directory: kernel | |
| run: | | |
| set -euo pipefail | |
| # Insert missing ptep declaration after line 208 (near pte_t *pte = NULL;) | |
| sed -i '208a \ | |
| pte_t *ptep = NULL;' arch/arm64/mm/hugetlbpage.c | |
| # Replace faulty assignment at line 235 with conditional to avoid double-call or null issues | |
| sed -i '235s/ptep = huge_pmd_share(mm, vma, addr, pud);/if (!ptep) ptep = huge_pmd_share(mm, vma, addr, pud);/' arch/arm64/mm/hugetlbpage.c | |
| echo "Patch applied:" | |
| grep -A5 -B2 "ptep =" arch/arm64/mm/hugetlbpage.c | head -10 | |
| - 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 - | |
| # 1) Seed .config into O=out (explicit ARCH) | |
| - 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: preseed QTI_GVM, NR_CPUS=8, and accept defaults for any new symbols | |
| - name: Finalize kernel config (non-interactive) | |
| 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 | |
| CONFIG_HUGETLB_PAGE=n | |
| CONFIG_HUGETLBFS=n | |
| EOF | |
| make O=out ARCH=arm64 olddefconfig KCONFIG_ALLCONFIG=../ci.defaults | |
| # Force NR_CPUS=8 override in case defconfig/vendor ignores KCONFIG_ALLCONFIG | |
| sed -i 's/^# CONFIG_NR_CPUS is not set$/CONFIG_NR_CPUS=8/' out/.config | |
| sed -i 's/^CONFIG_NR_CPUS=.*/CONFIG_NR_CPUS=8/' out/.config | |
| # Re-run olddefconfig to propagate the change without prompts | |
| make O=out ARCH=arm64 olddefconfig | |
| echo "==== Ensured config ====" | |
| grep -E '^CONFIG_QTI_GVM=|^CONFIG_NR_CPUS=|^CONFIG_HUGETLB_PAGE=|^CONFIG_HUGETLBFS=' out/.config || true | |
| # 3) Only after config is finalized, build scripts/headers | |
| - name: Prepare scripts and headers | |
| working-directory: ./kernel | |
| run: | | |
| set -euo pipefail | |
| export PATH=/usr/lib/llvm-18/bin:$PATH | |
| export HOSTCC=clang-18 | |
| export HOSTCXX=clang++-18 | |
| make ${KERNEL_CMDLINE} scripts CC="ccache clang-18" | |
| make ${KERNEL_CMDLINE} prepare CC="ccache clang-18" | |
| - name: Build kernel | |
| working-directory: kernel | |
| env: | |
| KBUILD_OUTPUT: out | |
| run: | | |
| set -euo pipefail | |
| export PATH=/usr/lib/llvm-18/bin:$PATH | |
| export LD_LIBRARY_PATH="/usr/lib/llvm-18/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" | |
| export DTC_EXT=dtc | |
| export HOSTCC=clang-18 | |
| export HOSTCXX=clang++-18 | |
| # Ensure Kconfig settled (non-interactive) | |
| make O=out ARCH=arm64 olddefconfig | |
| # Verify critical configs before compile | |
| if ! grep -q '^CONFIG_NR_CPUS=8' out/.config; then | |
| echo "Error: NR_CPUS not set to 8; check config" | |
| exit 1 | |
| fi | |
| make ${KERNEL_CMDLINE} CC="ccache clang-18" LD="ld.lld-18" AR="llvm-ar-18" NM="llvm-nm-18" OBJCOPY="llvm-objcopy-18" OBJDUMP="llvm-objdump-18" STRIP="llvm-strip-18" -j"$(nproc)" | |
| test -f out/arch/arm64/boot/Image | |
| cp out/arch/arm64/boot/Image ../AnyKernel3 | |
| - name: Run simple verification on build output | |
| working-directory: kernel | |
| run: | | |
| set -euo pipefail | |
| if [ -d out ]; then | |
| echo "Build output exists:" | |
| ls -lah out | sed -n '1,200p' | |
| else | |
| echo "No build output directory found" | |
| exit 1 | |
| fi | |
| - name: Build Wi-Fi Module (qca_cld3) | |
| working-directory: ./kernel | |
| run: | | |
| set -euo pipefail | |
| export PATH=/usr/lib/llvm-18/bin:$PATH | |
| export LD_LIBRARY_PATH="/usr/lib/llvm-18/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" | |
| export HOSTCC=clang-18 | |
| export HOSTCXX=clang++-18 | |
| make ${KERNEL_CMDLINE} modules_prepare CC="ccache clang-18" | |
| make ${KERNEL_CMDLINE} CC="ccache clang-18" LD="ld.lld-18" AR="llvm-ar-18" NM="llvm-nm-18" OBJCOPY="llvm-objcopy-18" OBJDUMP="llvm-objdump-18" STRIP="llvm-strip-18" -j"$(nproc)" M=drivers/staging/qcacld-3.0 modules | |
| sudo mkdir -p ../modules/vendor/lib/modules | |
| sudo find out/drivers/staging/qcacld-3.0 -name "*.ko" -exec cp -v {} ../modules/vendor/lib/modules/ ; | |
| sudo chown -R "$(id -u)":"$(id -g)" ../modules | |
| - name: Package Kernel | |
| run: | | |
| cd AnyKernel3 | |
| zip -r ../${{ env.OUTPUT_ZIP_NAME }}.zip * | |
| cd .. | |
| - name: Package Wi-Fi Module | |
| run: | | |
| if [ ! -d "modules/vendor/lib/modules" ] || ! ls modules/vendor/lib/modules/*.ko >/dev/null 2>&1; then | |
| echo "Error: No Wi-Fi modules found to package!" | |
| exit 1 | |
| fi | |
| cd modules | |
| zip -r ../${{ env.OUTPUT_ZIP_NAME }}-modules.zip * | |
| cd .. | |
| - name: Upload kernel build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: kernel-out | |
| path: kernel/out | |
| if-no-files-found: warn | |
| - name: Upload zips | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: outputs | |
| path: | | |
| ${{ env.OUTPUT_ZIP_NAME }}.zip | |
| ${{ env.OUTPUT_ZIP_NAME }}-modules.zip | |
| if-no-files-found: error | |
| - name: Upload logs | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: kernel-build-logs | |
| path: kernel/out |