aboutsummaryrefslogtreecommitdiff
path: root/configure.sh
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-10-19 14:44:30 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-10-19 14:44:30 -0400
commit42447f4b68235b545cc0e1b91111079c155dc2f8 (patch)
tree0304c3c30cf38983a71355bf83f09b4dc80ad938 /configure.sh
parentc814ebe71f18514c381c33aef574df0edcd0adf2 (diff)
Add makefile config option for LTO
Diffstat (limited to 'configure.sh')
-rwxr-xr-xconfigure.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/configure.sh b/configure.sh
index 1b5bd272..a4a8daa5 100755
--- a/configure.sh
+++ b/configure.sh
@@ -37,8 +37,19 @@ read DEFAULT_C_COMPILER
if [ -z "$DEFAULT_C_COMPILER" ]; then DEFAULT_C_COMPILER="cc"; fi
DEFAULT_C_COMPILER="${DEFAULT_C_COMPILER/#\~/$HOME}"
+printf '\033[1mDo you want to build the compiler with Link Time Optimization (LTO)?\033[m\n\033[2m(This makes building the Tomo compiler slower, but makes running Tomo programs faster)\033[m\n\033[1m[y/N]\033[m '
+read USE_LTO
+if [ "$USE_LTO" = "y" -o "$USE_LTO" = "Y" ]; then
+ if $DEFAULT_C_COMPILER -v 2>&1 | grep -q "gcc version"; then
+ LTO="-flto=auto -fno-fat-lto-objects -Wl,-flto";
+ elif $DEFAULT_C_COMPILER -v 2>&1 | grep -q "clang version"; then
+ LTO="-flto=thin";
+ fi
+fi
+
cat <<END >config.mk
PREFIX=$PREFIX
DEFAULT_C_COMPILER=$DEFAULT_C_COMPILER
SUDO=$SUDO
+LTO=$LTO
END