You are not logged in.

#1 2014-11-05 21:45:17

parchedas
Member
From: Cambridge, UK
Registered: 2013-06-01
Posts: 74

arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

RE my discussion with anatolik here

from gcc-arm-none-eabi (4.8_2014_q3_update-2)

$ stat usr/arm-none-eabi/lib/armv6-m/libc_s.a 
  File: ‘usr/arm-none-eabi/lib/armv6-m/libc_s.a’
  Size: 778620    	Blocks: 1528       IO Block: 4096   regular file
...
$ stat usr/arm-none-eabi/lib/armv6-m/libc.a 
  File: ‘usr/arm-none-eabi/lib/armv6-m/libc.a’
  Size: 928780    	Blocks: 1816       IO Block: 4096   regular file
...

from arm-none-eabi-gcc in [community-testing] (4.9.2-1)

$ stat /usr/arm-none-eabi/lib/armv6-m/libc_nano.a
  File: ‘/usr/arm-none-eabi/lib/armv6-m/libc_nano.a’
  Size: 4351570   	Blocks: 8504       IO Block: 4096   regular file
...
$ stat /usr/arm-none-eabi/lib/armv6-m/libc.a
  File: ‘/usr/arm-none-eabi/lib/armv6-m/libc.a’
  Size: 4615784   	Blocks: 9016       IO Block: 4096   regular file
...

Offline

#2 2014-11-05 22:02:35

parchedas
Member
From: Cambridge, UK
Registered: 2013-06-01
Posts: 74

Re: arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

@anatolik


I suspect maybe different compiler flags, I see you have

export CFLAGS_FOR_TARGET='-g -O2 -ffunction-sections -fdata-sections'

I suspect -Os may be better.

Offline

#3 2014-11-05 22:44:50

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

ARM binaries contain debug symbols. After stripping them the files become significantly smaller:

arm-none-eabi-objcopy -R .comment -R .note -R .debug_info -R .debug_aranges -R .debug_pubnames -R .debug_pubtypes -R .debug_abbrev -R .debug_line -R .debug_str -R .debug_ranges -R .debug_loc $LIBRARY

929916 Nov  5 14:41 libc.a
920810 Nov  5 14:42 libc_nano.a

Still larger than binaries from ARM. Will try to recompile package with Os.


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

#4 2014-11-06 00:14:41

parchedas
Member
From: Cambridge, UK
Registered: 2013-06-01
Posts: 74

Re: arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

extract from their newlib{,-nano} build which I suspect you looked at

echo Task [III-2] /$HOST_NATIVE/newlib/
saveenv
prepend_path PATH $INSTALLDIR_NATIVE/bin
saveenvvar CFLAGS_FOR_TARGET '-g -O2 -ffunction-sections -fdata-sections'
rm -rf $BUILDDIR_NATIVE/newlib && mkdir -p $BUILDDIR_NATIVE/newlib
pushd $BUILDDIR_NATIVE/newlib

$SRCDIR/$NEWLIB/configure  \
    $NEWLIB_CONFIG_OPTS \
    --target=$TARGET \
    --prefix=$INSTALLDIR_NATIVE \
    --infodir=$INSTALLDIR_NATIVE_DOC/info \
    --mandir=$INSTALLDIR_NATIVE_DOC/man \
    --htmldir=$INSTALLDIR_NATIVE_DOC/html \
    --pdfdir=$INSTALLDIR_NATIVE_DOC/pdf \
    --enable-newlib-io-long-long \
    --enable-newlib-register-fini \
    --disable-newlib-supplied-syscalls \
    --disable-nls

make -j$JOBS

make install

if [ "x$skip_manual" != "xyes" ]; then
make pdf
mkdir -p $INSTALLDIR_NATIVE_DOC/pdf
cp $BUILDDIR_NATIVE/newlib/arm-none-eabi/newlib/libc/libc.pdf $INSTALLDIR_NATIVE_DOC/pdf/libc.pdf
cp $BUILDDIR_NATIVE/newlib/arm-none-eabi/newlib/libm/libm.pdf $INSTALLDIR_NATIVE_DOC/pdf/libm.pdf

make html
mkdir -p $INSTALLDIR_NATIVE_DOC/html
copy_dir $BUILDDIR_NATIVE/newlib/arm-none-eabi/newlib/libc/libc.html $INSTALLDIR_NATIVE_DOC/html/libc
copy_dir $BUILDDIR_NATIVE/newlib/arm-none-eabi/newlib/libm/libm.html $INSTALLDIR_NATIVE_DOC/html/libm
fi

popd
restoreenv

echo Task [III-3] /$HOST_NATIVE/newlib-nano/
saveenv
prepend_path PATH $INSTALLDIR_NATIVE/bin
saveenvvar CFLAGS_FOR_TARGET '-g -Os -ffunction-sections -fdata-sections'
rm -rf $BUILDDIR_NATIVE/newlib-nano && mkdir -p $BUILDDIR_NATIVE/newlib-nano
pushd $BUILDDIR_NATIVE/newlib-nano

$SRCDIR/$NEWLIB_NANO/configure  \
    $NEWLIB_CONFIG_OPTS \
    --target=$TARGET \
    --prefix=$BUILDDIR_NATIVE/target-libs \
    --disable-newlib-supplied-syscalls    \
    --enable-newlib-reent-small           \
    --disable-newlib-fvwrite-in-streamio  \
    --disable-newlib-fseek-optimization   \
    --disable-newlib-wide-orient          \
    --enable-newlib-nano-malloc           \
    --disable-newlib-unbuf-stream-opt     \
    --enable-lite-exit                    \
    --enable-newlib-global-atexit         \
    --disable-nls

make -j$JOBS
make install

but you may have missed it is -O2 for newlib and -Os for newlib-nano

Last edited by parchedas (2014-11-06 00:15:14)

Offline

#5 2014-11-06 06:01:30

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

I just pushed new versions of newlib and gcc compiled with more aggressive options to [community-testing] repo. I also stripped the binaries and now their size is much smaller. Give it a try please.

Last edited by anatolik (2014-11-06 06:01:56)


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

#6 2014-11-06 07:19:22

parchedas
Member
From: Cambridge, UK
Registered: 2013-06-01
Posts: 74

Re: arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

I get this now

 LD        [fw|cc  ]  build/fw_coptercontrol/fw_coptercontrol.elf
/usr/lib/gcc/arm-none-eabi/4.9.2/../../../../arm-none-eabi/bin/ld: skipping incompatible /usr/lib/gcc/arm-none-eabi/4.9.2/armv7-m/libgcc.a when searching for -lgcc
/usr/lib/gcc/arm-none-eabi/4.9.2/../../../../arm-none-eabi/bin/ld: skipping incompatible /usr/lib/gcc/arm-none-eabi/4.9.2/libgcc.a when searching for -lgcc
/usr/lib/gcc/arm-none-eabi/4.9.2/../../../../arm-none-eabi/bin/ld: cannot find -lgcc
/usr/lib/gcc/arm-none-eabi/4.9.2/../../../../arm-none-eabi/bin/ld: skipping incompatible /usr/lib/gcc/arm-none-eabi/4.9.2/armv7-m/libgcc.a when searching for -lgcc
/usr/lib/gcc/arm-none-eabi/4.9.2/../../../../arm-none-eabi/bin/ld: skipping incompatible /usr/lib/gcc/arm-none-eabi/4.9.2/libgcc.a when searching for -lgcc
/usr/lib/gcc/arm-none-eabi/4.9.2/../../../../arm-none-eabi/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
/home/james/builds/openpilot-git/OpenPilot/make/common-defs.mk:224: recipe for target '/home/james/builds/openpilot-git/OpenPilot/build/fw_coptercontrol/fw_coptercontrol.elf' failed
make[1]: *** [/home/james/builds/openpilot-git/OpenPilot/build/fw_coptercontrol/fw_coptercontrol.elf] Error 1
Makefile:408: recipe for target 'fw_coptercontrol_opfw' failed
make: *** [fw_coptercontrol_opfw] Error 2

Offline

#7 2014-11-06 18:52:39

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

Thanks for testing it. I think this library was incorrectly stripped. Could you please try this package http://pkgbuild.com/~anatolik/arm-embedded/ ? (And do not forget to check the package signature when you install it).


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

#8 2014-11-06 20:33:52

parchedas
Member
From: Cambridge, UK
Registered: 2013-06-01
Posts: 74

Re: arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

That seems to have done the trick, thanks.

Last edited by parchedas (2014-11-06 20:34:06)

Offline

#9 2014-11-06 20:37:15

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

What is the firmware size difference between Arch and ARM versions of toolchain? Just curious.


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

#10 2014-11-06 21:31:24

parchedas
Member
From: Cambridge, UK
Registered: 2013-06-01
Posts: 74

Re: arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

elfs at most 1% bigger with Arch, bins exactly the same for most of them.

Offline

#11 2014-11-06 22:37:40

anatolik
Developer
Registered: 2012-09-27
Posts: 458

Re: arm-none-eabi-gcc: Arch version libs are much bigger than ARM version

I just pushed this version to [community-testing]. I am going to release it to stable in a few days if there will be no problems.


Read it before posting http://www.catb.org/esr/faqs/smart-questions.html
Ruby gems repository done right https://bbs.archlinux.org/viewtopic.php?id=182729
Fast initramfs generator with security in mind https://wiki.archlinux.org/index.php/Booster

Offline

Board footer

Powered by FluxBB