2024-12-20 18:15:57 +04:00
|
|
|
#!/bin/echo Must be sourced from a bash script **
|
|
|
|
|
|
|
|
# strict mode
|
|
|
|
export IFS=$'\n'
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
# git clone wrapper
|
|
|
|
clone () {
|
|
|
|
if ! [ -e "$2" ]; then
|
|
|
|
git clone \
|
|
|
|
--single-branch --depth 1 \
|
|
|
|
--recurse-submodules \
|
|
|
|
"$1" \
|
|
|
|
"$2"
|
|
|
|
else
|
|
|
|
echo " ** '$2/' already exists"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-12-20 19:25:20 +04:00
|
|
|
# optimizations
|
|
|
|
set_cflags () {
|
|
|
|
export \
|
2024-12-21 21:29:59 +04:00
|
|
|
CFLAGS="-std=gnu2x -Ofast -march=native" \
|
|
|
|
CPPFLAGS="-Ofast -march=native" \
|
|
|
|
LDFLAGS="-Wl,-O3" \
|
|
|
|
RUSTFLAGS="-C target-cpu=native -C panic=abort"
|
|
|
|
}
|
|
|
|
|
|
|
|
# in a separate fn because ring does not build with LTO
|
|
|
|
use_lto () {
|
|
|
|
export \
|
|
|
|
CFLAGS="$CFLAGS -flto=auto -fwhole-program" \
|
|
|
|
CPPFLAGS="$CPPFLAGS -flto=auto -fwhole-program"
|
2024-12-20 19:25:20 +04:00
|
|
|
}
|
|
|
|
|
2024-12-20 18:15:57 +04:00
|
|
|
# make -j12
|
|
|
|
make_maxthreads() {
|
|
|
|
[ -v JOBS ] || JOBS=$(nproc || echo 4)
|
|
|
|
JOBS="${JOBS//[^0-9]/}"
|
|
|
|
make -j"$JOBS"
|
|
|
|
}
|
2024-12-21 21:58:03 +04:00
|
|
|
|
|
|
|
# alias build_rust="cargo build -r"
|
|
|
|
build_rust () {
|
|
|
|
cargo build \
|
|
|
|
--release \
|
|
|
|
--config 'panic="abort"' \
|
|
|
|
--config 'lto="fat"' \
|
|
|
|
--config 'codegen-units=1' \
|
|
|
|
"$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# just disabling debugging
|
|
|
|
build_go () {
|
|
|
|
go build -v \
|
|
|
|
-trimpath \
|
|
|
|
-ldflags "-s -w -buildid=" \
|
|
|
|
"$@"
|
|
|
|
}
|