-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
68 lines (55 loc) · 1.5 KB
/
build.sh
File metadata and controls
68 lines (55 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
# build.sh — One-command build for the Ternary GGUF converter (t81z)
# Works on Linux, macOS, WSL, and GitHub Actions
set -euo pipefail
GREEN='\033[0;32m'
CYAN='\033[0;36m'
RED='\033[0;31m'
NC='\033[0m'
echo -e "${CYAN}=== Ternary LLM Converter Build Script ===${NC}"
# Detect platform
OS="$(uname -s)"
ARCH="$(uname -m)"
echo "Detected: $OS $ARCH"
# Find C++ compiler
if command -v clang++ >/dev/null; then
CXX="clang++"
elif command -v g++ >/dev/null; then
CXX="g++"
else
echo -e "${RED}Error: No suitable C++ compiler found (need g++ or clang++)${NC}"
exit 1
fi
echo "Using compiler: $CXX"
# Build flags: max performance + native
BASE_FLAGS="-std=c++20 -O3 -march=native -flto -DNDEBUG"
WARN_FLAGS="-Wall -Wextra -Wpedantic"
# macOS needs special treatment
if [[ "$OS" == "Darwin" ]]; then
BASE_FLAGS="$BASE_FLAGS -stdlib=libc++"
LDFLAGS="-lc++"
else
LDFLAGS="-static-libgcc -static-libstdc++"
fi
# Final command
CMD="$CXX src/t81z.cpp $BASE_FLAGS $WARN_FLAGS -lz $LDFLAGS -o t81z"
echo -e "${CYAN}Building with maximum optimization...${NC}"
echo "$CMD"
echo
# Build it
$CMD
# Success message
echo
echo -e "${GREEN}Build successful!${NC}"
echo -e "${GREEN}Binary: ./t81z${NC}"
echo
echo "Example usage:"
echo " ./t81z gemma-2b-it-safetensors/ --to-gguf gemma-2b-t3.gguf"
echo
echo "Run './t81z --help' for full options"
echo
# Show binary info
if command -v strip >/dev/null; then
strip t81z 2>/dev/null || true
fi
echo -e "${GREEN}Ready for ternary domination.${NC}"