Files
foxhunt/scripts/setup_lld.sh
jgrusewski 8d89fe80ff chore: Second cleanup wave - organize root directory
- Archive: 85 agent .txt files → docs/archive/agents/legacy_txt/
- Scripts: Move 110 shell scripts → scripts/ (keep deploy.sh in root)
- Models: Move 18 .safetensors → ml/models/checkpoints/training_artifacts/
- Delete: 34 directories (~33GB freed) - target/, coverage_*, test artifacts
- Build: Clean 14 build artifacts (.rlib, .o, .pid, binaries)
- Tests: Move 14 .rs files → tests/standalone/
- SQL: Move 5 files → sql/ (keep init-db*.sql for Docker)
- Wave 153: Archive to docs/archive/historical/wave153/
- Docs: Archive 9 markdown files to wave_d/reports/ and historical/

Total impact: ~34GB freed (both waves), root directory cleaned from 583 to ~40 essential files
Directory count reduced from 65 to 31 (52% reduction)
All historical data preserved in organized archive structure
2025-10-30 01:26:02 +01:00

134 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
set -e
echo "=========================================="
echo "LLD Linker Setup Script for Foxhunt"
echo "=========================================="
echo ""
# Check if running with sudo
if [ "$EUID" -eq 0 ]; then
echo "✓ Running with sudo privileges"
else
echo "⚠️ This script requires sudo privileges"
echo " Please run: sudo bash $0"
exit 1
fi
# Install lld
echo "Step 1: Installing lld..."
apt-get update -qq
apt-get install -y lld
echo ""
echo "Step 2: Verifying installation..."
if command -v ld.lld &> /dev/null; then
echo "✓ LLD installed successfully"
ld.lld --version
else
echo "✗ LLD installation failed"
exit 1
fi
# Update .cargo/config.toml
echo ""
echo "Step 3: Updating .cargo/config.toml..."
FOXHUNT_DIR="/home/jgrusewski/Work/foxhunt"
CONFIG_FILE="$FOXHUNT_DIR/.cargo/config.toml"
if [ ! -f "$CONFIG_FILE" ]; then
echo "✗ Config file not found: $CONFIG_FILE"
exit 1
fi
# Backup original
cp "$CONFIG_FILE" "$CONFIG_FILE.backup.$(date +%Y%m%d_%H%M%S)"
echo "✓ Backup created: $CONFIG_FILE.backup.*"
# Apply changes
cat > "$CONFIG_FILE" << 'CONFIGEOF'
[env]
# SQLx offline mode - use cached query metadata from .sqlx/ directory
# Generated with: cargo sqlx prepare --workspace
SQLX_OFFLINE = "true"
[build]
rustflags = [
"-D", "unsafe_op_in_unsafe_fn",
"-D", "clippy::undocumented_unsafe_blocks",
"-W", "rust_2024_idioms",
"-C", "force-frame-pointers=yes",
# REMOVED: "-C", "stack-protector=strong", # Not compatible with coverage tools
"-C", "relocation-model=pic",
]
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = [
"-C", "link-arg=-Wl,-z,relro,-z,now",
"-C", "link-arg=-Wl,--as-needed",
"-C", "link-arg=-fuse-ld=lld", # LLD linker for faster linking (5-10x improvement)
# CRITICAL HFT PERFORMANCE FLAGS - FIXES SIMD 10,000x REGRESSION
"-C", "target-cpu=native",
"-C", "target-feature=+avx2,+fma,+bmi2",
"-C", "opt-level=3",
"-C", "codegen-units=1",
]
# Profile-specific optimizations for maximum SIMD performance
[profile.release]
opt-level = 3
lto = "fat"
codegen-units = 1
panic = "abort"
strip = false
debug = false
overflow-checks = false
# Benchmarking profile with SIMD optimizations
[profile.bench]
inherits = "release"
debug = false
# HFT-specific profile for production with aggressive SIMD optimization
[profile.hft]
inherits = "release"
opt-level = 3
lto = "fat"
codegen-units = 1
panic = "abort"
strip = false
overflow-checks = false
CONFIGEOF
echo "✓ Configuration updated"
# Test compilation
echo ""
echo "Step 4: Testing compilation..."
cd "$FOXHUNT_DIR"
sudo -u jgrusewski bash << 'TESTEOF'
cd /home/jgrusewski/Work/foxhunt
echo "Running: cargo check --workspace"
cargo check --workspace 2>&1 | head -20
TESTEOF
if [ $? -eq 0 ]; then
echo "✓ Compilation test passed"
else
echo "⚠️ Compilation test encountered issues (this may be normal)"
fi
echo ""
echo "=========================================="
echo "✓ LLD Setup Complete!"
echo "=========================================="
echo ""
echo "Next steps:"
echo "1. Run a clean build: cargo clean && time cargo build --release"
echo "2. Compare build times with previous builds"
echo "3. Expected improvement: 40-60% faster linking"
echo ""
echo "Backup location: $CONFIG_FILE.backup.*"