The gms_pure_go build tag already tells go-mysql-server to use Go's stdlib regex instead of ICU-backed go-icu-regex. However, .buildflags and the Makefile were unconditionally injecting ICU linker flags (including -licui18n -licuuc -licudata on Linux), which re-introduced the ICU shared-library dependency at link time. This caused release binaries to require a specific ICU version (e.g., libicui18n.so.74), making them non-portable across Linux distros with different ICU versions. Changes: - .buildflags: Remove ICU flag injection; only export CGO_ENABLED=1 - Makefile: Replace ICU4C detection block with BUILD_TAGS := gms_pure_go; use the tag for all platforms (not just Windows) - scripts/verify-cgo.sh: Add readelf check to fail if ICU shared-library dependency is present in ELF binaries - scripts/install.sh: Add -tags gms_pure_go to build_from_source() CGO remains enabled for embedded Dolt support. Only the ICU regex backend is swapped for Go's stdlib regex, which is sufficient since bd does not use SQL REGEXP functions. Amp-Thread-ID: https://ampcode.com/threads/T-019d6450-7b10-77ee-b3d0-58e9474e61da Co-authored-by: Amp <amp@ampcode.com>
42 lines
1.3 KiB
Bash
Executable file
42 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# verify-cgo.sh - Fail if a built binary reports CGO_ENABLED=0.
|
|
# Usage: ./scripts/verify-cgo.sh <path-to-binary>
|
|
|
|
set -euo pipefail
|
|
|
|
if [[ $# -ne 1 ]]; then
|
|
echo "Usage: $0 <path-to-binary>" >&2
|
|
exit 2
|
|
fi
|
|
|
|
binary_path="$1"
|
|
|
|
if [[ ! -f "$binary_path" ]]; then
|
|
echo "ERROR: binary not found: $binary_path" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v strings >/dev/null 2>&1; then
|
|
echo "ERROR: 'strings' is required to verify CGO metadata" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if strings "$binary_path" | awk '/^build[[:space:]]+CGO_ENABLED=0$/ { found=1 } END { exit(found?0:1) }'; then
|
|
echo "ERROR: $binary_path was built without CGO support (found CGO_ENABLED=0)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# On Linux (ELF binaries), verify no ICU shared-library dependency.
|
|
# The gms_pure_go build tag should eliminate this; if it appears, the build
|
|
# environment leaked ICU flags onto the link line.
|
|
if command -v readelf >/dev/null 2>&1; then
|
|
if readelf -d "$binary_path" 2>/dev/null | grep -qi 'libicu'; then
|
|
echo "ERROR: $binary_path has unexpected ICU runtime dependency" >&2
|
|
readelf -d "$binary_path" | grep -i 'libicu' >&2
|
|
echo "Ensure the binary is built with -tags gms_pure_go and without ICU CGO_LDFLAGS" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "OK: $binary_path has CGO support"
|