Skip to content

Commit 518e8f5

Browse files
committed
Add --disable-strip and enable gcc strip
GCC has an install target 'install-strip' that strips debug symbols at install time. This reduces the installed size from ~4GB to ~2GB. Enable strip on install by default but provide the option to disable it. The downside of this is when GCC ICEs, we don't get a proper backtrace any more. Signed-off-by: Joel Stanley <jms@tenstorrent.com>
1 parent aaee081 commit 518e8f5

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

Makefile.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ LLVM_SRCDIR := @with_llvm_src@
1717
DEJAGNU_SRCDIR := @with_dejagnu_src@
1818
DEBUG_INFO := @debug_info@
1919
ENABLE_DEFAULT_PIE := @enable_default_pie@
20+
GCC_INSTALL_TARGET := @gcc_install_target@
2021

2122
SIM ?= @WITH_SIM@
2223

@@ -536,7 +537,7 @@ stamps/build-gcc-linux-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) $(addprefix stamps/b
536537
CFLAGS_FOR_TARGET="-O2 $(CFLAGS_FOR_TARGET)" \
537538
CXXFLAGS_FOR_TARGET="-O2 $(CXXFLAGS_FOR_TARGET)"
538539
$(MAKE) -C $(notdir $@)
539-
$(MAKE) -C $(notdir $@) install
540+
$(MAKE) -C $(notdir $@) $(GCC_INSTALL_TARGET)
540541
cp -a $(INSTALL_DIR)/$(LINUX_TUPLE)/lib* $(SYSROOT)
541542
mkdir -p $(dir $@) && touch $@
542543

@@ -592,7 +593,7 @@ stamps/build-gcc-linux-native: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-gcc-lin
592593
$(WITH_ISA_SPEC) \
593594
$(GCC_EXTRA_CONFIGURE_FLAGS)
594595
$(MAKE) -C $(notdir $@)
595-
$(MAKE) -C $(notdir $@) install
596+
$(MAKE) -C $(notdir $@) $(GCC_INSTALL_TARGET)
596597
cp -a $(INSTALL_DIR)/$(LINUX_TUPLE)/lib* $(SYSROOT)
597598
mkdir -p $(dir $@) && touch $@
598599

configure

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ with_glibc_src
630630
with_newlib_src
631631
with_binutils_src
632632
with_gcc_src
633+
gcc_install_target
633634
enable_host_gcc
634635
enable_llvm
635636
enable_gdb
@@ -736,6 +737,7 @@ with_guile
736737
enable_gdb
737738
enable_llvm
738739
enable_host_gcc
740+
enable_strip
739741
with_gcc_src
740742
with_binutils_src
741743
with_newlib_src
@@ -1392,6 +1394,7 @@ Optional Features:
13921394
--disable-gdb Don't build GDB, as it's not upstream
13931395
--enable-llvm Build LLVM (clang)
13941396
--enable-host-gcc Build host GCC to build cross toolchain
1397+
--disable-strip Do not strip debug symbols at install time
13951398
--enable-libsanitizer Build libsanitizer, which only supports rv64
13961399
--enable-qemu-system Build qemu with system-mode emulation
13971400
@@ -4341,6 +4344,26 @@ else $as_nop
43414344
43424345
fi
43434346
4347+
# Check whether --enable-strip was given.
4348+
if test ${enable_strip+y}
4349+
then :
4350+
enableval=$enable_strip;
4351+
else case e in #(
4352+
e) strip_debug=yes ;;
4353+
esac
4354+
fi
4355+
4356+
4357+
if test "x$strip_debug" != xyes
4358+
then :
4359+
gcc_install_target=install
4360+
4361+
else case e in #(
4362+
e) gcc_install_target=install-strip
4363+
;;
4364+
esac
4365+
fi
4366+
43444367
43454368
43464369
{

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ AS_IF([test "x$enable_host_gcc" != xyes],
287287
[AC_SUBST(enable_host_gcc, --disable-host-gcc)],
288288
[AC_SUBST(enable_host_gcc, --enable-host-gcc)])
289289

290+
AC_ARG_ENABLE(strip,
291+
[AS_HELP_STRING([--disable-strip],
292+
[Do not strip debug symbols at install time])],
293+
[],
294+
[strip_debug=yes])
295+
296+
AS_IF([test "x$strip_debug" != xyes],
297+
[AC_SUBST(gcc_install_target, install)],
298+
[AC_SUBST(gcc_install_target, install-strip)])
299+
290300
AC_DEFUN([AX_ARG_WITH_SRC],
291301
[{m4_pushdef([opt_name], with_$1_src)
292302
AC_ARG_WITH($1-src,

0 commit comments

Comments
 (0)