Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/scripts/check-release-apiabi.sh # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / scripts / check-release-apiabi.sh` 128 lines ยท 4415 bytes Raw Blame History 1 #!/bin/bash 2 # Check API/ABI compatibility between the previous release tag and current HEAD. 3 # 4 # Finds the most recent vX.Y.Z tag, checks it out in a temporary git worktree, 5 # builds both versions with shared libs enabled, and uses check-apiabi-compat.sh 6 # to compare the results. 7 # 8 # Exit codes: 9 # 0: compatible, or check was skipped 10 # 1: backwards-incompatible changes found, or build failed 11 # 12 # Options: 13 # --tag : compare against this tag instead of the latest release 14 # 15 # Environment: 16 # SKIP_APIABI_CHECK: set to 1 or true to skip 17 # APIABI_COMPARE_TAG: equivalent to --tag (used by CI) 18 # APIABI_REPORT_DIR: preserve reports and dumps in this directory, even if the comparison fails 19 20 set -euo pipefail 21 22 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 23 REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" 24 LIBS=(libggml libggml-base) 25 26 usage() { 27 echo "Usage: $0 [--tag ]" >&2 28 echo " --tag Compare against this release tag (default: latest)" >&2 29 } 30 31 COMPARE_TAG="${APIABI_COMPARE_TAG:-}" 32 while [[ "$#" -gt 0 ]]; do 33 case "$1" in 34 --tag) 35 if [[ -z "${2:-}" ]]; then usage; exit 1; fi 36 COMPARE_TAG="$2" 37 shift 2 38 ;; 39 --tag=*) 40 COMPARE_TAG="${1#*=}" 41 shift 42 ;; 43 -h | --help) 44 usage; exit 0 45 ;; 46 *) 47 usage; exit 1 48 ;; 49 esac 50 done 51 52 if [[ "${SKIP_APIABI_CHECK:-}" == "1" || "${SKIP_APIABI_CHECK:-}" == "true" ]]; then 53 echo "SKIP_APIABI_CHECK is set - skipping API/ABI compatibility check" 54 exit 0 55 fi 56 57 if ! command -v abi-compliance-checker >/dev/null 2>&1 || ! command -v abidw >/dev/null 2>&1; then 58 echo "Warning: abi-compliance-checker or abigail-tools not installed - skipping API/ABI check" 59 exit 0 60 fi 61 62 if [[ -n "${COMPARE_TAG}" ]]; then 63 PREV_TAG="${COMPARE_TAG}" 64 if ! git -C "$REPO_ROOT" rev-parse --verify "${PREV_TAG}^{}" >/dev/null 2>&1; then 65 echo "Error: tag '${PREV_TAG}' not found in repository." >&2 66 exit 1 67 fi 68 else 69 PREV_TAG=$(git -C "$REPO_ROOT" tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1 || true) 70 if [[ -z "${PREV_TAG}" ]]; then 71 echo "Warning: no previous release tag found - skipping API/ABI check" 72 exit 0 73 fi 74 fi 75 OLD_VERSION="${PREV_TAG#v}" 76 OLD_MAJOR="${OLD_VERSION%%.*}" 77 OLD_MINOR="${OLD_VERSION#*.}"; OLD_MINOR="${OLD_MINOR%%.*}" 78 79 NEW_MAJOR=$(grep "set(GGML_VERSION_MAJOR" "$REPO_ROOT/CMakeLists.txt" | sed 's/.*MAJOR \([0-9]*\).*/\1/') 80 NEW_MINOR=$(grep "set(GGML_VERSION_MINOR" "$REPO_ROOT/CMakeLists.txt" | sed 's/.*MINOR \([0-9]*\).*/\1/') 81 82 if [[ "$NEW_MAJOR" -gt "$OLD_MAJOR" ]]; then 83 echo "Major version increment ($OLD_MAJOR -> $NEW_MAJOR): API/ABI breaking changes are expected, skipping compatibility check." 84 exit 0 85 fi 86 87 CHECK_FLAGS=() 88 if [[ "$NEW_MINOR" -eq "$OLD_MINOR" ]]; then 89 echo "Patch version bump detected: checking for any API/ABI changes (a minor bump is required if any are found)..." 90 CHECK_FLAGS+=(--strict) 91 else 92 echo "Minor version bump detected: checking for backwards-incompatible API/ABI changes..." 93 fi 94 95 echo "Checking API/ABI compatibility against ${PREV_TAG}..." 96 97 WORKTREE_DIR=$(mktemp -d) 98 BUILD_OLD=$(mktemp -d) 99 BUILD_NEW=$(mktemp -d) 100 101 cleanup() { 102 git -C "$REPO_ROOT" worktree remove --force "$WORKTREE_DIR" 2>/dev/null || true 103 rm -rf "$WORKTREE_DIR" "$BUILD_OLD" "$BUILD_NEW" 104 } 105 trap cleanup EXIT 106 107 git -C "$REPO_ROOT" worktree add "$WORKTREE_DIR" "$PREV_TAG" 108 109 cmake -S "$WORKTREE_DIR" -B "$BUILD_OLD" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo 110 cmake --build "$BUILD_OLD" --parallel "$(nproc)" 111 112 cmake -S "$REPO_ROOT" -B "$BUILD_NEW" -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo 113 cmake --build "$BUILD_NEW" --parallel "$(nproc)" 114 115 (cd "$WORKTREE_DIR" && "$SCRIPT_DIR/check-apiabi-compat.sh" --generate "$BUILD_OLD" "${LIBS[@]}") 116 (cd "$REPO_ROOT" && "$SCRIPT_DIR/check-apiabi-compat.sh" --generate "$BUILD_NEW" "${LIBS[@]}") 117 118 CHECK_RESULT=0 119 (cd "$REPO_ROOT" && "$SCRIPT_DIR/check-apiabi-compat.sh" "${CHECK_FLAGS[@]}" --check "$BUILD_OLD" "$BUILD_NEW") || CHECK_RESULT=$? 120 121 if [[ -n "${APIABI_REPORT_DIR:-}" ]]; then 122 mkdir -p "$APIABI_REPORT_DIR/old" "$APIABI_REPORT_DIR/new" 123 cp -R "$BUILD_OLD/apiabi/." "$APIABI_REPORT_DIR/old/" 124 cp -R "$BUILD_NEW/apiabi/." "$APIABI_REPORT_DIR/new/" 125 echo "API/ABI reports saved to $APIABI_REPORT_DIR" 126 fi 127 128 exit "$CHECK_RESULT"