|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +# Script to check binary compatibility and suggest fixes |
| 5 | +# Usage: ./scripts/check-binary-compatibility.sh [binary_path] |
| 6 | + |
| 7 | +BINARY_PATH="${1:-/usr/local/bin/perf_to_profile}" |
| 8 | + |
| 9 | +echo "🔍 Checking binary compatibility for: $BINARY_PATH" |
| 10 | + |
| 11 | +if [[ ! -f "$BINARY_PATH" ]]; then |
| 12 | + echo "❌ Binary not found: $BINARY_PATH" |
| 13 | + exit 1 |
| 14 | +fi |
| 15 | + |
| 16 | +echo "" |
| 17 | +echo "📋 Binary information:" |
| 18 | +file "$BINARY_PATH" |
| 19 | + |
| 20 | +echo "" |
| 21 | +echo "🔗 Dynamic library dependencies:" |
| 22 | +if ldd "$BINARY_PATH" 2>/dev/null; then |
| 23 | + echo "" |
| 24 | + echo "📊 Checking for problematic dependencies..." |
| 25 | + |
| 26 | + # Check for newer glibc requirements |
| 27 | + if ldd "$BINARY_PATH" | grep -q "GLIBC_2.3[0-9]"; then |
| 28 | + echo "⚠️ Warning: Binary requires newer GLIBC (2.30+)" |
| 29 | + echo " This may not work on older systems like Ubuntu 18.04 or CentOS 7" |
| 30 | + fi |
| 31 | + |
| 32 | + # Check for newer libstdc++ requirements |
| 33 | + if ldd "$BINARY_PATH" | grep -q "GLIBCXX_3.4.3[0-9]"; then |
| 34 | + echo "⚠️ Warning: Binary requires newer GLIBCXX (3.4.30+)" |
| 35 | + echo " This may not work on older systems" |
| 36 | + fi |
| 37 | + |
| 38 | + # Check if libraries are statically linked |
| 39 | + if ldd "$BINARY_PATH" | grep -q "libstdc++"; then |
| 40 | + echo "⚠️ Warning: libstdc++ is dynamically linked" |
| 41 | + echo " Consider using --linkopt=-static-libstdc++ for better compatibility" |
| 42 | + fi |
| 43 | + |
| 44 | + if ldd "$BINARY_PATH" | grep -q "libgcc"; then |
| 45 | + echo "⚠️ Warning: libgcc is dynamically linked" |
| 46 | + echo " Consider using --linkopt=-static-libgcc for better compatibility" |
| 47 | + fi |
| 48 | + |
| 49 | +else |
| 50 | + echo "✅ Static binary (no dynamic dependencies) - excellent compatibility!" |
| 51 | +fi |
| 52 | + |
| 53 | +echo "" |
| 54 | +echo "🧪 Testing basic functionality:" |
| 55 | +if "$BINARY_PATH" --help >/dev/null 2>&1; then |
| 56 | + echo "✅ Binary executes successfully" |
| 57 | +else |
| 58 | + echo "❌ Binary failed to execute" |
| 59 | + echo "" |
| 60 | + echo "🔧 Troubleshooting steps:" |
| 61 | + echo "1. Check if you're on a compatible system:" |
| 62 | + echo " ldd --version" |
| 63 | + echo "2. Install missing dependencies:" |
| 64 | + echo " sudo apt-get install libc6 libstdc++6 libgcc-s1" |
| 65 | + echo "3. Try running with verbose error output:" |
| 66 | + echo " LD_DEBUG=libs $BINARY_PATH --help" |
| 67 | +fi |
| 68 | + |
| 69 | +echo "" |
| 70 | +echo "🏁 Compatibility check complete!" |
0 commit comments