From ebf1d72462d6eda772eaff6409e68a1a51eff005 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 31 Dec 2025 17:03:46 -0500 Subject: Remove LTO and add some stripping --- Makefile | 9 +++++++-- configure.sh | 11 ----------- src/tomo.c | 1 - 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index df290dbe..bd690c18 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,7 @@ O=-O3 # Note: older versions of Make have buggy behavior with hash marks inside strings, so this ugly code is necessary: TOMO_VERSION=$(shell awk 'BEGIN{hashes=sprintf("%c%c",35,35)} $$1==hashes {print $$2; exit}' CHANGES.md) GIT_VERSION=$(shell git log -1 --pretty=format:"%as_%h" 2>/dev/null || echo "unknown") -CFLAGS+=$(CCONFIG) $(INCLUDE_DIRS) $(EXTRA) $(CWARN) $(G) $(O) $(OSFLAGS) $(LTO) \ +CFLAGS+=$(CCONFIG) $(INCLUDE_DIRS) $(EXTRA) $(CWARN) $(G) $(O) $(OSFLAGS) \ -DSUDO='"$(SUDO)"' -DDEFAULT_C_COMPILER='"$(DEFAULT_C_COMPILER)"' \ -DGIT_VERSION='"$(GIT_VERSION)"' -ffunction-sections -fdata-sections CFLAGS_PLACEHOLDER="$$(printf '\033[2m\033[m\n')" @@ -140,8 +140,13 @@ $(BUILD_DIR)/bin/$(EXE_FILE): $(STDLIB_OBJS) $(COMPILER_OBJS) build/gc/lib/libgc @$(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $^ -o $@ $(BUILD_DIR)/lib/$(AR_FILE): $(STDLIB_OBJS) build/gc/lib/libgc.a build/unistring/lib/libunistring.a build/gmp/lib/libgmp.a | $(BUILD_DIR)/lib - $(CC) -no-pie -r -flto -nostdlib $^ -o libtomo.o + $(CC) -no-pie -r -nostdlib $^ -o libtomo.o + strip --strip-all --strip-unneeded --remove-section=.comment \ + --remove-section=.note --remove-section=.note.gnu.build-id \ + --remove-section=.eh_frame --remove-section=.eh_frame_hdr \ + --remove-section=.gnu_debuglink libtomo.o ar rcs $@ libtomo.o + rm -f libtomo.o $(BUILD_DIR)/lib/tomo@$(TOMO_VERSION)/modules.ini: modules/core.ini modules/examples.ini | $(BUILD_DIR)/lib/tomo@$(TOMO_VERSION) @cat $^ > $@ diff --git a/configure.sh b/configure.sh index a4a8daa5..1b5bd272 100755 --- a/configure.sh +++ b/configure.sh @@ -37,19 +37,8 @@ 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 <config.mk PREFIX=$PREFIX DEFAULT_C_COMPILER=$DEFAULT_C_COMPILER SUDO=$SUDO -LTO=$LTO END diff --git a/src/tomo.c b/src/tomo.c index a545c789..416a8664 100644 --- a/src/tomo.c +++ b/src/tomo.c @@ -81,7 +81,6 @@ static OptionalText_t show_codegen = NONE_TEXT, cflags = Text("-Werror -fdollars-in-identifiers -std=c2x -Wno-trigraphs" " -ffunction-sections -fdata-sections" " -fno-signed-zeros" - " -flto=auto -fno-fat-lto-objects -Wl,-flto" " -D_XOPEN_SOURCE -D_DEFAULT_SOURCE -fPIC -ggdb" #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) " -D_BSD_SOURCE" -- cgit v1.2.3