Skip to content

Commit ea385b2

Browse files
Joel Stanleyshenki
authored andcommitted
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 <joel@tenstorrent.com>
1 parent 6d7b5b7 commit ea385b2

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
@@ -16,6 +16,7 @@ LLVM_SRCDIR := @with_llvm_src@
1616
DEJAGNU_SRCDIR := @with_dejagnu_src@
1717
DEBUG_INFO := @debug_info@
1818
DEJAGNU_SRCDIR := @with_dejagnu_src@
19+
GCC_INSTALL_TARGET := @gcc_install_target@
1920

2021
SIM ?= @WITH_SIM@
2122

@@ -515,7 +516,7 @@ stamps/build-gcc-linux-stage2: $(GCC_SRCDIR) $(GCC_SRC_GIT) $(addprefix stamps/b
515516
CFLAGS_FOR_TARGET="-O2 $(CFLAGS_FOR_TARGET)" \
516517
CXXFLAGS_FOR_TARGET="-O2 $(CXXFLAGS_FOR_TARGET)"
517518
$(MAKE) -C $(notdir $@)
518-
$(MAKE) -C $(notdir $@) install
519+
$(MAKE) -C $(notdir $@) $(GCC_INSTALL_TARGET)
519520
cp -a $(INSTALL_DIR)/$(LINUX_TUPLE)/lib* $(SYSROOT)
520521
mkdir -p $(dir $@) && touch $@
521522

@@ -569,7 +570,7 @@ stamps/build-gcc-linux-native: $(GCC_SRCDIR) $(GCC_SRC_GIT) stamps/build-gcc-lin
569570
$(WITH_ISA_SPEC) \
570571
$(GCC_EXTRA_CONFIGURE_FLAGS)
571572
$(MAKE) -C $(notdir $@)
572-
$(MAKE) -C $(notdir $@) install
573+
$(MAKE) -C $(notdir $@) $(GCC_INSTALL_TARGET)
573574
cp -a $(INSTALL_DIR)/$(LINUX_TUPLE)/lib* $(SYSROOT)
574575
mkdir -p $(dir $@) && touch $@
575576

configure

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ with_glibc_src
598598
with_newlib_src
599599
with_binutils_src
600600
with_gcc_src
601+
gcc_install_target
601602
enable_host_gcc
602603
enable_llvm
603604
enable_gdb
@@ -699,6 +700,7 @@ with_guile
699700
enable_gdb
700701
enable_llvm
701702
enable_host_gcc
703+
enable_strip
702704
with_gcc_src
703705
with_binutils_src
704706
with_newlib_src
@@ -1343,6 +1345,7 @@ Optional Features:
13431345
--disable-gdb Don't build GDB, as it's not upstream
13441346
--enable-llvm Build LLVM (clang)
13451347
--enable-host-gcc Build host GCC to build cross toolchain
1348+
--disable-strip Do not strip debug symbols at install time
13461349
--enable-libsanitizer Build libsanitizer, which only supports rv64
13471350
--enable-qemu-system Build qemu with system-mode emulation
13481351
@@ -3640,6 +3643,26 @@ else
36403643
36413644
fi
36423645
3646+
# Check whether --enable-strip was given.
3647+
if test ${enable_strip+y}
3648+
then :
3649+
enableval=$enable_strip;
3650+
else case e in #(
3651+
e) strip_debug=yes ;;
3652+
esac
3653+
fi
3654+
3655+
3656+
if test "x$strip_debug" != xyes
3657+
then :
3658+
gcc_install_target=install
3659+
3660+
else case e in #(
3661+
e) gcc_install_target=install-strip
3662+
;;
3663+
esac
3664+
fi
3665+
36433666
36443667
36453668
{

configure.ac

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

272+
AC_ARG_ENABLE(strip,
273+
[AS_HELP_STRING([--disable-strip],
274+
[Do not strip debug symbols at install time])],
275+
[],
276+
[strip_debug=yes])
277+
278+
AS_IF([test "x$strip_debug" != xyes],
279+
[AC_SUBST(gcc_install_target, install)],
280+
[AC_SUBST(gcc_install_target, install-strip)])
281+
272282
AC_DEFUN([AX_ARG_WITH_SRC],
273283
[{m4_pushdef([opt_name], with_$1_src)
274284
AC_ARG_WITH($1-src,

0 commit comments

Comments
 (0)