diff --git a/.github/workflows/apt-release.yml b/.github/workflows/apt-release.yml index b640fe8..dd8b033 100644 --- a/.github/workflows/apt-release.yml +++ b/.github/workflows/apt-release.yml @@ -21,7 +21,7 @@ permissions: jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8a87ddf..deb063e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ on: # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobs jobs: build-and-test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout the repo uses: actions/checkout@v4 @@ -38,7 +38,7 @@ jobs: run: bazel test //src:all //src/quipper:all test-deb-build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 @@ -94,7 +94,7 @@ jobs: retention-days: 7 test-apt-scripts: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest needs: test-deb-build steps: - name: Checkout code diff --git a/scripts/build-deb.sh b/scripts/build-deb.sh index e7389e9..ba81264 100755 --- a/scripts/build-deb.sh +++ b/scripts/build-deb.sh @@ -7,7 +7,11 @@ mkdir -p "$OUTDIR" # Build the project with Bazel (with static linking for better compatibility) echo "Building perf_to_profile with Bazel..." -bazel build --config=opt --linkopt=-static-libgcc --linkopt=-static-libstdc++ //src:perf_to_profile +bazel build \ + --compilation_mode=opt \ + --linkopt=-static-libgcc \ + --linkopt=-static-libstdc++ \ + //src:perf_to_profile # Install FPM (skip if FPM_SKIP_INSTALL is set, e.g., in CI) if [[ "${FPM_SKIP_INSTALL:-}" != "1" ]]; then @@ -28,8 +32,18 @@ mkdir -p "$BIN_DIR" # Copy the Bazel-built binary to the temporary directory cp bazel-bin/src/perf_to_profile "$BIN_DIR/" + +# Make sure the binary is writable and executable before stripping +chmod u+w "$BIN_DIR/perf_to_profile" chmod +x "$BIN_DIR/perf_to_profile" +# Strip the binary to reduce size and remove debug symbols +strip "$BIN_DIR/perf_to_profile" || echo "Warning: Could not strip binary (not critical)" + +# Check binary dependencies for debugging +echo "Binary dependencies:" +ldd "$BIN_DIR/perf_to_profile" || echo "Static binary (no dynamic dependencies)" + # Create the .deb package using FPM fpm -s dir -t deb \ -n perf-data-converter \ diff --git a/scripts/check-binary-compatibility.sh b/scripts/check-binary-compatibility.sh new file mode 100755 index 0000000..d160837 --- /dev/null +++ b/scripts/check-binary-compatibility.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Script to check binary compatibility and suggest fixes +# Usage: ./scripts/check-binary-compatibility.sh [binary_path] + +BINARY_PATH="${1:-/usr/local/bin/perf_to_profile}" + +echo "๐Ÿ” Checking binary compatibility for: $BINARY_PATH" + +if [[ ! -f "$BINARY_PATH" ]]; then + echo "โŒ Binary not found: $BINARY_PATH" + exit 1 +fi + +echo "" +echo "๐Ÿ“‹ Binary information:" +file "$BINARY_PATH" + +echo "" +echo "๐Ÿ”— Dynamic library dependencies:" +if ldd "$BINARY_PATH" 2>/dev/null; then + echo "" + echo "๐Ÿ“Š Checking for problematic dependencies..." + + # Check for newer glibc requirements + if ldd "$BINARY_PATH" | grep -q "GLIBC_2.3[0-9]"; then + echo "โš ๏ธ Warning: Binary requires newer GLIBC (2.30+)" + echo " This may not work on older systems like Ubuntu 18.04 or CentOS 7" + fi + + # Check for newer libstdc++ requirements + if ldd "$BINARY_PATH" | grep -q "GLIBCXX_3.4.3[0-9]"; then + echo "โš ๏ธ Warning: Binary requires newer GLIBCXX (3.4.30+)" + echo " This may not work on older systems" + fi + + # Check if libraries are statically linked + if ldd "$BINARY_PATH" | grep -q "libstdc++"; then + echo "โš ๏ธ Warning: libstdc++ is dynamically linked" + echo " Consider using --linkopt=-static-libstdc++ for better compatibility" + fi + + if ldd "$BINARY_PATH" | grep -q "libgcc"; then + echo "โš ๏ธ Warning: libgcc is dynamically linked" + echo " Consider using --linkopt=-static-libgcc for better compatibility" + fi + +else + echo "โœ… Static binary (no dynamic dependencies) - excellent compatibility!" +fi + +echo "" +echo "๐Ÿงช Testing basic functionality:" +if "$BINARY_PATH" --help >/dev/null 2>&1; then + echo "โœ… Binary executes successfully" +else + echo "โŒ Binary failed to execute" + echo "" + echo "๐Ÿ”ง Troubleshooting steps:" + echo "1. Check if you're on a compatible system:" + echo " ldd --version" + echo "2. Install missing dependencies:" + echo " sudo apt-get install libc6 libstdc++6 libgcc-s1" + echo "3. Try running with verbose error output:" + echo " LD_DEBUG=libs $BINARY_PATH --help" +fi + +echo "" +echo "๐Ÿ Compatibility check complete!"