action.yml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. name: 'Enable BTF'
  2. description: 'Enable CONFIG_DEBUG_INFO_BTF and apply libbpf feature-detection fix for android12-5.10'
  3. inputs:
  4. version:
  5. description: 'Kernel config version (e.g., android12-5.10)'
  6. required: true
  7. kernel_version:
  8. description: 'Kernel version (e.g., 5.10)'
  9. required: true
  10. sublevel:
  11. description: 'Kernel sublevel'
  12. required: true
  13. runs:
  14. using: 'composite'
  15. steps:
  16. - name: Apply libbpf feature-detection fix (android12-5.10)
  17. shell: bash
  18. working-directory: ${{ github.workspace }}/kernel/common
  19. if: ${{ inputs.version == 'android12-5.10' }}
  20. run: |
  21. set -euo pipefail
  22. patch -p1 -N < ${{ github.action_path }}/patches/0001-libbpf-remove-feature-detection-BTF.patch
  23. - name: Apply resolve_btfids linker-flag fix (android12-5.10)
  24. shell: bash
  25. working-directory: ${{ github.workspace }}/kernel/common
  26. if: ${{ inputs.version == 'android12-5.10' }}
  27. run: |
  28. set -euo pipefail
  29. patch -p1 -N < ${{ github.action_path }}/patches/0002-resolve_btfids-inherit-host-linker-flags.patch
  30. - name: Apply xdp_buff BTF-emit fix (android12-5.10)
  31. shell: bash
  32. working-directory: ${{ github.workspace }}/kernel/common
  33. if: ${{ inputs.version == 'android12-5.10' }}
  34. run: |
  35. set -euo pipefail
  36. # bpf_types.h references struct xdp_buff via
  37. # BTF_ID_LIST_SINGLE(bpf_xdp_output_btf_ids) in net/core/filter.c, but
  38. # the oldest sublevels (5.10.43) never emit xdp_buff into vmlinux BTF,
  39. # so resolve_btfids aborts with "unresolved symbol xdp_buff". Force BTF
  40. # emission with BTF_TYPE_EMIT. Idempotent/harmless on newer sublevels.
  41. patch -p1 -N < ${{ github.action_path }}/patches/0003-btf-emit-xdp-buff.patch
  42. - name: Expose host dd for hermetic BTF generation (android12-5.10)
  43. shell: bash
  44. working-directory: ${{ github.workspace }}/kernel/common
  45. if: ${{ inputs.version == 'android12-5.10' }}
  46. run: |
  47. set -euo pipefail
  48. # The hermetic toolchain PATH (build.config.common -> HERMETIC_TOOLCHAIN=1)
  49. # has no /usr/bin, so coreutils 'dd' is missing. gen_btf in
  50. # scripts/link-vmlinux.sh:253 does `printf ... | dd of=...`; without dd the
  51. # pipeline fails and the build aborts with "Failed to generate BTF".
  52. # ADDITIONAL_HOST_TOOLS is honored by build/_setup_env.sh (symlinked into
  53. # the hermetic host_tools dir, which IS on the PATH). Echo it into the
  54. # build config so both Normal and Bypass build.sh runs pick it up.
  55. grep -q '^ADDITIONAL_HOST_TOOLS=' build.config.gki.aarch64 || \
  56. echo 'ADDITIONAL_HOST_TOOLS="${ADDITIONAL_HOST_TOOLS} dd"' >> build.config.gki.aarch64
  57. - name: Use apt pahole (>=1.23) for hermetic BTF generation (android12-5.10)
  58. shell: bash
  59. working-directory: ${{ github.workspace }}/kernel
  60. if: ${{ inputs.version == 'android12-5.10' }}
  61. run: |
  62. set -euo pipefail
  63. # android12-5.10 pins prebuilt pahole v1.19, which fails to recode the
  64. # DWARF types and DROPS symbols (e.g. xdp_buff) from the emitted BTF.
  65. # resolve_btfids then aborts with "FAILED unresolved symbol xdp_buff".
  66. # a13-5.10 ships prebuilt pahole v1.23 which works. The runner installs
  67. # apt pahole 1.25 (/usr/bin/pahole). Replace the hermetic-path pahole
  68. # (first dir on PATH, same dir dd lives in) with a WRAPPER that execs
  69. # the apt binary.
  70. #
  71. # The wrapper also always injects --skip_encoding_btf_enum64 /
  72. # decl_tag / type_tag. Sublevels <=149 have no scripts/pahole-flags.sh
  73. # at all, so their link-vmlinux.sh calls pahole with no skip flags; the
  74. # old in-tree libbpf there only handles BTF kinds 1-15 and EINVALs on
  75. # enum64/decl_tag/type_tag. Newer sublevels pass --skip_encoding_btf_enum64
  76. # via pahole-flags.sh already; duplicate skip flags are harmless.
  77. HERMETIC_PAHOLE="build/build-tools/path/linux-x86/pahole"
  78. REAL_PAHOLE="$(command -v pahole)"
  79. if [ -L "$HERMETIC_PAHOLE" ] || [ -f "$HERMETIC_PAHOLE" ]; then
  80. cat > "$HERMETIC_PAHOLE" <<EOF
  81. #!/bin/sh
  82. exec "$REAL_PAHOLE" --skip_encoding_btf_enum64 --skip_encoding_btf_decl_tag --skip_encoding_btf_type_tag "\$@"
  83. EOF
  84. chmod +x "$HERMETIC_PAHOLE"
  85. echo "Wrote wrapper $HERMETIC_PAHOLE -> $REAL_PAHOLE (skip enum64/decl_tag/type_tag)"
  86. "$HERMETIC_PAHOLE" --version
  87. else
  88. echo "WARNING: $HERMETIC_PAHOLE not found; leaving prebuilt pahole in place"
  89. fi
  90. - name: Enable BTF Config
  91. uses: ./.github/actions/set-kernel-config
  92. with:
  93. config_list: |
  94. CONFIG_DEBUG_INFO_BTF=y