action.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. name: 'Build Kernel'
  2. description: 'Builds kernel using legacy build.sh or Bazel (kleaf)'
  3. runs:
  4. using: composite
  5. steps:
  6. - shell: bash
  7. working-directory: ${{ github.workspace }}
  8. run: |
  9. set -euo pipefail
  10. # Install ccache with ECS by cctv18
  11. echo "Install ccache with ECS"
  12. 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; }
  13. sudo cp -f ./ccache /usr/bin/ccache || { echo "❌ Failed to install ccache"; exit 1; }
  14. sudo chmod +x /usr/bin/ccache
  15. rm -f ./ccache
  16. # Verify ccache is actually installed and works
  17. if ! /usr/bin/ccache --version > /dev/null 2>&1; then
  18. echo "❌ ccache installation failed or binary is corrupted"
  19. exit 1
  20. fi
  21. echo "✅ ccache binary verified: $(/usr/bin/ccache --version | head -1)"
  22. - name: 'Setup Cache Environment'
  23. shell: bash
  24. working-directory: ${{ github.workspace }}/kernel/common
  25. run: |
  26. set -euo pipefail
  27. export CCACHE_DIR="$GITHUB_WORKSPACE/kernel/common/.ccache"
  28. echo "CCACHE_DIR=$CCACHE_DIR" >> $GITHUB_ENV
  29. export LDCACHE_DIR="$GITHUB_WORKSPACE/kernel/common/.ld_cache"
  30. echo "LDCACHE_DIR=$LDCACHE_DIR" >> $GITHUB_ENV
  31. cat > "$GITHUB_WORKSPACE/kernel/common/ld-wrapper" << 'EOF'
  32. #!/bin/bash
  33. ld.lld "$@" --thinlto-cache-dir="$LDCACHE_DIR" --thinlto-jobs="$(nproc --all)"
  34. EOF
  35. chmod +x "$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
  36. export CC="ccache clang"
  37. echo "CC=$CC" >> $GITHUB_ENV
  38. export CXX="ccache clang++"
  39. echo "CXX=$CXX" >> $GITHUB_ENV
  40. export HOSTCC="ccache clang"
  41. echo "HOSTCC=$HOSTCC" >> $GITHUB_ENV
  42. export HOSTCXX="ccache clang++"
  43. echo "HOSTCXX=$HOSTCXX" >> $GITHUB_ENV
  44. export "LD=$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
  45. echo "LD=$LD" >> $GITHUB_ENV
  46. export HOSTLD="$GITHUB_WORKSPACE/kernel/common/ld-wrapper"
  47. echo "HOSTLD=$HOSTLD" >> $GITHUB_ENV
  48. #export CCACHE_MAXSIZE=10G
  49. #export CCACHE_COMPILERCHECK=content
  50. #export CCACHE_BASEDIR="$GITHUB_WORKSPACE/kernel"
  51. #export CCACHE_NOHASHDIR=true
  52. #export CCACHE_COMPRESSION=true
  53. #export CCACHE_COMPRESSION_LEVEL=3
  54. #export CCACHE_DIRECT=true
  55. #export CCACHE_FILE_CLONE=true
  56. #export CCACHE_INODE_CACHE=true
  57. #export CCACHE_IS_KERNEL_COMPILING=true
  58. #export CCACHE_UMASK=002
  59. #export CCACHE_SLOPPINESS="file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale"
  60. #if /usr/bin/ccache --help 2>&1 | grep -q 'depend_mode'; then
  61. # export CCACHE_DEPEND=true
  62. #fi
  63. echo "✅ ccache environment variables set"
  64. #echo " CC: $CC"
  65. #echo " CXX: $CXX"
  66. echo "📁 Cache directories:"
  67. echo " CCACHE_DIR: $CCACHE_DIR"
  68. echo " LDCACHE_DIR: $LDCACHE_DIR"
  69. mkdir -p "$CCACHE_DIR" "$LDCACHE_DIR"
  70. ccache -M 100G
  71. ccache -p
  72. ccache -s
  73. ccache -z
  74. - name: 'Build Kernel'
  75. shell: bash
  76. working-directory: ${{ github.workspace }}/kernel
  77. run: |
  78. set -euo pipefail
  79. if [ -f "build/build.sh" ]; then
  80. SKIP_MRPROPER=1 \
  81. LTO=thin \
  82. SKIP_VENDOR_BOOT=1 \
  83. SKIP_EXT_MODULES=1 \
  84. SKIP_CP_KERNEL_HDR=1 \
  85. GKI_DEFCONFIG_FRAGMENT="$GITHUB_WORKSPACE/wild_gki.fragment" \
  86. BUILD_CONFIG=common/build.config.gki.aarch64 \
  87. LD="$LD" \
  88. HOSTLD="$HOSTLD" \
  89. CC="$CC" \
  90. HOSTCC="$HOSTCC" \
  91. CXX="$CXX" \
  92. HOSTCXX="$HOSTCXX" \
  93. build/build.sh -j"$(nproc)"
  94. else
  95. cp "$GITHUB_WORKSPACE/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
  96. 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
  97. fi
  98. - name: 'Report Cache Sizes'
  99. shell: bash
  100. working-directory: ${{ github.workspace }}/kernel/common
  101. run: |
  102. set -euo pipefail
  103. echo "📊 Cache sizes after build:"
  104. echo " CCACHE usage:"
  105. du -sh "$CCACHE_DIR" || echo " (no ccache directory)"
  106. echo " LDCACHE usage:"
  107. du -sh "$LDCACHE_DIR" || echo " (no ldcache directory)"
  108. echo "Perform cache eviction!"
  109. # 3h = 10800s using seconds to support older ccache
  110. ccache --evict-older-than 10800s