foss-for-synopsys-dwc-arc-processors / arc-gnu-toolchain

Scripting for building ARC toolchain
5 stars 3 forks source link

Make building with debug info optional or parametrized #11

Closed abrodkin closed 1 year ago

abrodkin commented 2 years ago

Currently we build tools with debug info, which gets us an insanely huge (2.5 GiB) toolchain distribution:

$ du -h -d1 . | sort -h
20K     ./include
15M     ./lib
17M     ./share
71M     ./arc-linux-gnu
492M    ./bin
843M    ./sysroot
1.1G    ./libexec
2.5G    .

Only libc.a in sysroot occupies ~0.5 GiB:

$ du -h ./sysroot/usr/lib/libc.a
460M    ./sysroot/usr/lib/libc.a

It's clear we do want tools and target binaries with debug info during development and debugging, but that gets in the way in a sense of a delivery size. So let's try to make everybody happy with adding an option to not generate debug info.

abrodkin commented 2 years ago

Interesting enough removal of -g from this repo's Makefile.in like that:

diff --git a/Makefile.in b/Makefile.in
index 0aae344..a8182c7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -195,8 +195,8 @@ stamps/build-glibc-linux: $(GLIBC_SRCDIR) stamps/build-gcc-linux-stage1
        cd $(notdir $@) && \
                CC="$(GLIBC_CC_FOR_TARGET) $($@_CFLAGS)" \
                CXX="$(GLIBC_CXX_FOR_TARGET) $($@_CFLAGS)" \
-               CFLAGS="$(CFLAGS_FOR_TARGET) -g -O2 $($@_CFLAGS)" \
-               CXXFLAGS="$(CXXFLAGS_FOR_TARGET) -g -O2 $($@_CFLAGS)" \
+               CFLAGS="$(CFLAGS_FOR_TARGET) -O2 $($@_CFLAGS)" \
+               CXXFLAGS="$(CXXFLAGS_FOR_TARGET) -O2 $($@_CFLAGS)" \
                ASFLAGS="$(ASFLAGS_FOR_TARGET) $($@_CFLAGS)" \
                $</configure \
                --host=${LINUX_TUPLE} \
@@ -208,7 +208,7 @@ stamps/build-glibc-linux: $(GLIBC_SRCDIR) stamps/build-gcc-linux-stage1
                $(MULTILIB_FLAGS) \
                $(GLIBC_TARGET_FLAGS) \
                $($@_LIBDIROPTS) \
-               CFLAGS="-O2 -g3"
+               CFLAGS="-O2"
        $(MAKE) -C $(notdir $@)
        +flock $(SYSROOT)/.lock $(MAKE) -C $(notdir $@) install install_root=$(SYSROOT)
        mkdir -p $(dir $@) && touch $@

doesn't bring a lot of reduction:

$ du -h -d1 . | sort -h
20K     ./include
15M     ./lib
17M     ./share
68M     ./sysroot
71M     ./arc-linux-gnu
492M    ./bin
1.1G    ./libexec
1.7G    .

So there should be something else to change.

abrodkin commented 2 years ago

See huge arc-linux-gnu-gdb & arc-linux-gnu-lto-dump:

$ du -h bin/* | sort -h
...
6.9M    bin/arc-linux-gnu-as
7.3M    bin/arc-linux-gnu-objdump
178M    bin/arc-linux-gnu-gdb
253M    bin/arc-linux-gnu-lto-dump

See lto1, cc1, f951 & cc1plus:

$ du -h libexec/gcc/arc-linux-gnu/12.0.1/* | sort -h
...
4.5M    libexec/gcc/arc-linux-gnu/12.0.1/collect2
6.2M    libexec/gcc/arc-linux-gnu/12.0.1/lto-wrapper
253M    libexec/gcc/arc-linux-gnu/12.0.1/lto1
263M    libexec/gcc/arc-linux-gnu/12.0.1/cc1
265M    libexec/gcc/arc-linux-gnu/12.0.1/f951
281M    libexec/gcc/arc-linux-gnu/12.0.1/cc1plus
claziss commented 2 years ago

I think this is an ok mod.

luismgsilva commented 1 year ago

Merged. See https://github.com/foss-for-synopsys-dwc-arc-processors/arc-gnu-toolchain/pull/20