#!/usr/bin/env bash set -euo pipefail root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" source_file="$root/src/rootguard/bpf/rootguard.bpf.c" patch_file="$root/pkgbuild/patches/rootguard-clang23-memcpy-inline.patch" for statement in \ '__builtin_memcpy_inline(destination, source, RG_FILENAME_LEN);' \ '__builtin_memcpy_inline(destination, source, RG_COMM_LEN);' \ '__builtin_memcpy_inline(destination, pending->path, RG_FILENAME_LEN);'; do grep -Fq -- "$statement" "$source_file" done # The reference patch must already be applied to the delivered source. if patch -d "$root" -p1 --dry-run -R -i "$patch_file" >/dev/null 2>&1; then echo 'RootGuard Clang 23 source patch: integrated' else echo 'ERROR: RootGuard Clang 23 patch missing or source differs' >&2 exit 1 fi if command -v clang >/dev/null 2>&1; then printf '%s\n' \ 'void inline_copy(char *d, const char *s) {' \ ' __builtin_memcpy_inline(d, s, 256);' \ ' __builtin_memcpy_inline(d, s, 16);' \ '}' | clang -std=c11 -Wall -Wextra -Werror -fsyntax-only -x c - echo 'Clang builtin smoke test: OK (not an eBPF target build)' fi