Ver Fonte

fix(action): streamline ccache setup and update cache paths in build workflow

TheWildJames há 4 meses atrás
pai
commit
aad2ff4ea2
2 ficheiros alterados com 133 adições e 142 exclusões
  1. 1 121
      .github/actions/build-kernel/action.yml
  2. 132 21
      .github/workflows/build.yml

+ 1 - 121
.github/actions/build-kernel/action.yml

@@ -4,112 +4,6 @@ description: 'Builds kernel using legacy build.sh or Bazel (kleaf)'
 runs:
   using: composite
   steps:
-    - name: 'Setup ccache and Build Environment'
-      shell: bash
-      working-directory: ${{ github.workspace }}
-      run: |
-        set -euo pipefail
-        
-        # Download and install ccache
-        echo "Installing ccache..."
-        curl -LfsS --retry 5 --retry-delay 5 --retry-all-errors --connect-timeout 30 --tcp-fastopen -H "User-Agent: Mozilla/5.0" "https://github.com/WildKernels/kernel_patches/raw/refs/heads/main/ccache/ccache-x86-64" -o ccache || { echo "❌ Failed to download ccache"; exit 1; }
-        sudo cp -f ./ccache /usr/bin/ccache || { echo "❌ Failed to install ccache"; exit 1; }
-        sudo chmod +x /usr/bin/ccache
-        rm -f ./ccache
-        
-        # Verify ccache
-        if ! /usr/bin/ccache --version > /dev/null 2>&1; then
-          echo "❌ ccache installation failed or binary is corrupted"
-          exit 1
-        fi
-        echo "✅ ccache binary verified: $(/usr/bin/ccache --version | head -1)"
-        
-        # Setup cache directories
-        export CCACHE_DIR="/home/runner/.ccache"
-        echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
-        #export LDCACHE_DIR="/home/runner/.ld_cache"
-        #echo "LDCACHE_DIR=$LDCACHE_DIR" >> $GITHUB_ENV
-        mkdir -p "$CCACHE_DIR" 
-        #"$LDCACHE_DIR"
-        
-        ## Create LD wrapper for thin-LTO caching
-        #cat > "$GITHUB_WORKSPACE/kernel/common/ld-wrapper" << 'EOF'
-        ##!/bin/bash
-        #ld.lld "$@" --thinlto-cache-dir="$LDCACHE_DIR" --thinlto-jobs="$(nproc --all)"
-        #EOF
-        #chmod +x "$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
-
-        # Setup ccache compiler wrappers in PATH (masquerade method)
-        # This intercepts compiler invocations regardless of how the build system calls them
-        #mkdir -p "$GITHUB_WORKSPACE/ccache-bin"
-        #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/clang"
-        #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/clang++"
-        #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/gcc"
-        #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/g++"
-        #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/ld.lld"
-        #chmod +x "$GITHUB_WORKSPACE/ccache-bin"/*
-        
-        # Export environment variables for subsequent steps
-        #echo "PATH=$GITHUB_WORKSPACE/ccache-bin:$PATH" >> $GITHUB_ENV
-        
-        export CC="/usr/bin/ccache clang"
-        echo "CC=$CC" >> $GITHUB_ENV
-        export CXX="/usr/bin/ccache clang++"
-        echo "CXX=$CXX" >> $GITHUB_ENV
-        export HOSTCC="/usr/bin/ccache clang"
-        echo "HOSTCC=$HOSTCC" >> $GITHUB_ENV
-        export HOSTCXX="/usr/bin/ccache clang++"
-        echo "HOSTCXX=$HOSTCXX" >> $GITHUB_ENV
-        #export LD="$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
-        #echo "LD=$LD" >> $GITHUB_ENV
-        #export HOSTLD="$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
-        #echo "HOSTLD=$HOSTLD" >> $GITHUB_ENV
-        #echo "CLANG_PREBUILT_BIN=$GITHUB_WORKSPACE/ccache-bin" >> $GITHUB_ENV
-
-
-        export CCACHE_MAXSIZE="12G"
-        echo CCACHE_MAXSIZE="12G" >> $GITHUB_ENV
-        export CCACHE_COMPILERCHECK="content"
-        echo CCACHE_COMPILERCHECK="content" >> $GITHUB_ENV
-        export CCACHE_BASEDIR="${GITHUB_WORKSPACE}"
-        echo CCACHE_BASEDIR="${GITHUB_WORKSPACE}" >> $GITHUB_ENV
-        export CCACHE_NOHASHDIR="true"
-        echo CCACHE_NOHASHDIR="true" >> $GITHUB_ENV
-        export CCACHE_IGNOREOPTIONS="--sysroot*"
-        echo CCACHE_IGNOREOPTIONS="--sysroot*" >> $GITHUB_ENV
-        export CCACHE_COMPRESSION="true"
-        echo CCACHE_COMPRESSION="true" >> $GITHUB_ENV
-        export CCACHE_COMPRESSLEVEL="3"
-        echo CCACHE_COMPRESSION_LEVEL="3" >> $GITHUB_ENV
-        export CCACHE_DIRECT="true"
-        echo CCACHE_DIRECT="true" >> $GITHUB_ENV
-        export CCACHE_FILE_CLONE="true"
-        echo CCACHE_FILE_CLONE="true" >> $GITHUB_ENV
-        export CCACHE_INODE_CACHE="true"
-        echo CCACHE_INODE_CACHE="true" >> $GITHUB_ENV
-        export CCACHE_IS_KERNEL_COMPILING="true"
-        echo CCACHE_IS_KERNEL_COMPILING="true" >> $GITHUB_ENV
-        export CCACHE_UMASK="002"
-        echo CCACHE_UMASK="002" >> $GITHUB_ENV
-        export CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale"
-        echo CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale" >> $GITHUB_ENV
-        
-        if ccache --help 2>&1 | grep -q 'depend_mode'; then
-          export CCACHE_DEPEND=true
-          echo "CCACHE_DEPEND=true" >> "$GITHUB_ENV"
-        fi
-        
-        # Initialize ccache
-        #ccache -M 100G
-        ccache -p
-        ccache -s
-        ccache -z
-        
-        echo "✅ Build environment ready"
-        echo "   CCACHE_DIR: $CCACHE_DIR"
-        #echo "   LDCACHE_DIR: $LDCACHE_DIR"
-        #echo "   Compiler wrappers: $GITHUB_WORKSPACE/ccache-bin"
-
     - name: 'Build Kernel'
       shell: bash
       working-directory: ${{ github.workspace }}/kernel
@@ -128,18 +22,4 @@ runs:
           cp "$GITHUB_WORKSPACE/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
           tools/bazel build --config=release --notrim --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment --disk_cache=$LDCACHE_DIR --cache_dir=$GITHUB_WORKSPACE/kernel/.cache/bazel //common:kernel_aarch64
         fi
-        
-    - name: 'Report Cache Sizes'
-      shell: bash
-      working-directory: ${{ github.workspace }}/kernel/common
-      run: |
-        set -euo pipefail
-        echo "📊 Cache sizes after build:"
-        echo "   CCACHE usage:"
-        du -sh "$CCACHE_DIR" || echo "   (no ccache directory)"
-        #echo "   LDCACHE usage:"
-        #du -sh "$LDCACHE_DIR" || echo "   (no ldcache directory)"
-        
-        echo "Perform cache eviction!"
-        # 3h = 10800s using seconds to support older ccache
-        ccache --evict-older-than 10800s
+        

+ 132 - 21
.github/workflows/build.yml

@@ -69,10 +69,6 @@ jobs:
         os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
         use_repo: ${{ inputs.use_repo }}
 
-    - name: Grep for vm_flags_clear after download
-      run: |
-        grep -n 'vm_flags_clear' ${{ github.workspace }}/kernel/common/mm/mmap.c || echo 'Not found'
-
     - name: Extract Sublevel and Set File Name
       id: extract
       uses: ./.github/actions/extract-sublevel-file-name
@@ -182,16 +178,11 @@ jobs:
         if-no-files-found: ignore
         compression-level: 9
 
-    - name: Grep for vm_flags_clear before build
-      run: |
-        grep -n 'vm_flags_clear' ${{ github.workspace }}/kernel/common/mm/mmap.c || echo 'Not found'
-
-
     - name: Restore build caches (ccache)
       id: restore-ccache
       uses: ./.github/actions/restore-cache
       with:
-        cache_path: ${{ github.workspace }}/kernel/common/.ccache
+        cache_path: /home/runner/.ccache
         cache_key: buildcache-${{ inputs.kernel_version }}
         cache_bucket: "ccache-cache"
         compression_level: 9
@@ -210,7 +201,7 @@ jobs:
       id: restore-ldcache
       uses: ./.github/actions/restore-cache
       with:
-        cache_path: ${{ github.workspace }}/kernel/common/.ld_cache
+        cache_path: /home/runner/.ld_cache
         cache_key: buildcache-${{ inputs.kernel_version }}
         cache_bucket: "lto-cache"
         compression_level: 9
@@ -234,17 +225,137 @@ jobs:
         pre_misses=$(echo "$stats" | awk '/cache miss/ {m+=$NF} END{print (m+0)}')
         echo "pre_hits=$pre_hits" >> $GITHUB_OUTPUT
         echo "pre_misses=$pre_misses" >> $GITHUB_OUTPUT
-        pre_ld_size=$(du -sh "$GITHUB_WORKSPACE/kernel/common/.ld_cache" 2>/dev/null | awk '{print $1}' || echo "0B")
-        pre_ld_files=$(find "$GITHUB_WORKSPACE/kernel/common/.ld_cache" -type f 2>/dev/null | wc -l || true)
+        pre_ld_size=$(du -sh "/home/runner/.ld_cache" 2>/dev/null | awk '{print $1}' || echo "0B")
+        pre_ld_files=$(find "/home/runner/.ld_cache" -type f 2>/dev/null | wc -l || true)
         echo "pre_ld_size=$pre_ld_size" >> $GITHUB_OUTPUT
         echo "pre_ld_files=$pre_ld_files" >> $GITHUB_OUTPUT
 
+    - name: 'Setup ccache and Build Environment'
+      shell: bash
+      working-directory: ${{ github.workspace }}
+      run: |
+        set -euo pipefail
+        
+        # Download and install ccache
+        echo "Installing ccache..."
+        curl -LfsS --retry 5 --retry-delay 5 --retry-all-errors --connect-timeout 30 --tcp-fastopen -H "User-Agent: Mozilla/5.0" "https://github.com/WildKernels/kernel_patches/raw/refs/heads/main/ccache/ccache-x86-64" -o ccache || { echo "❌ Failed to download ccache"; exit 1; }
+        sudo cp -f ./ccache /usr/bin/ccache || { echo "❌ Failed to install ccache"; exit 1; }
+        sudo chmod +x /usr/bin/ccache
+        rm -f ./ccache
+        
+        # Verify ccache
+        if ! /usr/bin/ccache --version > /dev/null 2>&1; then
+          echo "❌ ccache installation failed or binary is corrupted"
+          exit 1
+        fi
+        echo "✅ ccache binary verified: $(/usr/bin/ccache --version | head -1)"
+        
+        # Setup cache directories
+        export CCACHE_DIR="/home/runner/.ccache"
+        echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
+        #export LDCACHE_DIR="/home/runner/.ld_cache"
+        #echo "LDCACHE_DIR=$LDCACHE_DIR" >> $GITHUB_ENV
+        mkdir -p "$CCACHE_DIR" 
+        #"$LDCACHE_DIR"
+        
+        ## Create LD wrapper for thin-LTO caching
+        #cat > "$GITHUB_WORKSPACE/kernel/common/ld-wrapper" << 'EOF'
+        ##!/bin/bash
+        #ld.lld "$@" --thinlto-cache-dir="$LDCACHE_DIR" --thinlto-jobs="$(nproc --all)"
+        #EOF
+        #chmod +x "$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
+
+        # Setup ccache compiler wrappers in PATH (masquerade method)
+        # This intercepts compiler invocations regardless of how the build system calls them
+        #mkdir -p "$GITHUB_WORKSPACE/ccache-bin"
+        #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/clang"
+        #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/clang++"
+        #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/gcc"
+        #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/g++"
+        #cp /usr/bin/ccache "$GITHUB_WORKSPACE/ccache-bin/ld.lld"
+        #chmod +x "$GITHUB_WORKSPACE/ccache-bin"/*
+        
+        # Export environment variables for subsequent steps
+        #echo "PATH=$GITHUB_WORKSPACE/ccache-bin:$PATH" >> $GITHUB_ENV
+        
+        export CC="/usr/bin/ccache clang"
+        echo "CC=$CC" >> $GITHUB_ENV
+        export CXX="/usr/bin/ccache clang++"
+        echo "CXX=$CXX" >> $GITHUB_ENV
+        export HOSTCC="/usr/bin/ccache clang"
+        echo "HOSTCC=$HOSTCC" >> $GITHUB_ENV
+        export HOSTCXX="/usr/bin/ccache clang++"
+        echo "HOSTCXX=$HOSTCXX" >> $GITHUB_ENV
+        #export LD="$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
+        #echo "LD=$LD" >> $GITHUB_ENV
+        #export HOSTLD="$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
+        #echo "HOSTLD=$HOSTLD" >> $GITHUB_ENV
+        #echo "CLANG_PREBUILT_BIN=$GITHUB_WORKSPACE/ccache-bin" >> $GITHUB_ENV
+
+        export CCACHE_MAXSIZE="12G"
+        echo CCACHE_MAXSIZE="12G" >> $GITHUB_ENV
+        export CCACHE_COMPILERCHECK="content"
+        echo CCACHE_COMPILERCHECK="content" >> $GITHUB_ENV
+        export CCACHE_BASEDIR="${GITHUB_WORKSPACE}"
+        echo CCACHE_BASEDIR="${GITHUB_WORKSPACE}" >> $GITHUB_ENV
+        export CCACHE_NOHASHDIR="true"
+        echo CCACHE_NOHASHDIR="true" >> $GITHUB_ENV
+        export CCACHE_IGNOREOPTIONS="--sysroot*"
+        echo CCACHE_IGNOREOPTIONS="--sysroot*" >> $GITHUB_ENV
+        export CCACHE_COMPRESSION="true"
+        echo CCACHE_COMPRESSION="true" >> $GITHUB_ENV
+        export CCACHE_COMPRESSLEVEL="3"
+        echo CCACHE_COMPRESSION_LEVEL="3" >> $GITHUB_ENV
+        export CCACHE_DIRECT="true"
+        echo CCACHE_DIRECT="true" >> $GITHUB_ENV
+        export CCACHE_FILE_CLONE="true"
+        echo CCACHE_FILE_CLONE="true" >> $GITHUB_ENV
+        export CCACHE_INODE_CACHE="true"
+        echo CCACHE_INODE_CACHE="true" >> $GITHUB_ENV
+        export CCACHE_IS_KERNEL_COMPILING="true"
+        echo CCACHE_IS_KERNEL_COMPILING="true" >> $GITHUB_ENV
+        export CCACHE_UMASK="002"
+        echo CCACHE_UMASK="002" >> $GITHUB_ENV
+        export CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale"
+        echo CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale" >> $GITHUB_ENV
+        
+        if ccache --help 2>&1 | grep -q 'depend_mode'; then
+          export CCACHE_DEPEND=true
+          echo "CCACHE_DEPEND=true" >> "$GITHUB_ENV"
+        fi
+        
+        # Initialize ccache
+        #ccache -M 100G
+        ccache -p
+        ccache -s
+        ccache -z
+        
+        echo "✅ Build environment ready"
+        echo "   CCACHE_DIR: $CCACHE_DIR"
+        #echo "   LDCACHE_DIR: $LDCACHE_DIR"
+        #echo "   Compiler wrappers: $GITHUB_WORKSPACE/ccache-bin"
+
     - name: Build Kernel
       env:
         SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
         KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
       uses: ./.github/actions/build-kernel
 
+    - name: 'Report Cache Sizes'
+      shell: bash
+      working-directory: ${{ github.workspace }}/kernel/common
+      run: |
+        set -euo pipefail
+        echo "📊 Cache sizes after build:"
+        echo "   CCACHE usage:"
+        du -sh "$CCACHE_DIR" || echo "   (no ccache directory)"
+        #echo "   LDCACHE usage:"
+        #du -sh "$LDCACHE_DIR" || echo "   (no ldcache directory)"
+        
+        echo "Perform cache eviction!"
+        # 3h = 10800s using seconds to support older ccache
+        ccache --evict-older-than 10800s
+
     - name: Post-build cache stats
       id: post-cache-stats
       run: |
@@ -263,8 +374,8 @@ jobs:
         else
           echo "No compiler activity detected (no ccache accesses)."
         fi
-        post_ld_size=$(du -sh "$GITHUB_WORKSPACE/kernel/common/.ld_cache" 2>/dev/null | awk '{print $1}' || echo "0B")
-        post_ld_files=$(find "$GITHUB_WORKSPACE/kernel/common/.ld_cache" -type f 2>/dev/null | wc -l || true)
+        post_ld_size=$(du -sh "/home/runner/.ld_cache" 2>/dev/null | awk '{print $1}' || echo "0B")
+        post_ld_files=$(find "/home/runner/.ld_cache" -type f 2>/dev/null | wc -l || true)
         echo "ld_cache size before: ${{ steps.pre-cache-stats.outputs.pre_ld_size }}, after: $post_ld_size"
         echo "ld_cache files before: ${{ steps.pre-cache-stats.outputs.pre_ld_files }}, after: $post_ld_files"
 
@@ -272,16 +383,16 @@ jobs:
       working-directory: ${{ github.workspace }}
       run: |
         echo "=== .ccache ==="
-        du -sh kernel/common/.ccache || true
-        ls -l kernel/common/.ccache || true
+        du -sh /home/runner/.ccache || true
+        ls -l /home/runner/.ccache || true
         echo "=== .cache/bazel ==="
-        du -sh kernel/common/.cache/bazel || true
-        ls -l kernel/common/.cache/bazel || true
+        du -sh /home/runner/.cache/bazel || true
+        ls -l /home/runner/.cache/bazel || true
 
     - name: Save ccache cache
       uses: ./.github/actions/save-cache
       with:
-        cache_path: ${{ github.workspace }}/kernel/common/.ccache
+        cache_path: /home/runner/.ccache
         cache_key: buildcache-${{ inputs.kernel_version }}
         cache_bucket: "ccache-cache"
         compression_level: 9
@@ -290,7 +401,7 @@ jobs:
     - name: Save LTO LD cache
       uses: ./.github/actions/save-cache
       with:
-        cache_path: ${{ github.workspace }}/kernel/common/.ld_cache
+        cache_path: /home/runner/.ld_cache
         cache_key: buildcache-${{ inputs.kernel_version }}
         cache_bucket: "lto-cache"
         compression_level: 9