On Sat, 07 Dec 2019 11:40:33 -0700 Jeff Law <l...@redhat.com> wrote: > On Fri, 2019-11-29 at 21:00 +0000, Jozef Lawrynowicz wrote: > > The attached patch consolidates some configuration tweaks I > > previously submitted > > as modifications to the msp430-elf target into a new target called > > "msp430-elfbare" i.e. "bare-metal". > > > > MSP430: Disable TM clone registry by default > > https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00550.html > > MSP430: Disable __cxa_atexit > > https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00552.html > > > > The patches tweak the CRT code to achieve the smallest possible code > > size, > > and rely on some additional generic tweaks to crtstuff.c. > > > > I did submit these tweaks a while ago, but I didn't get any feedback, > > however even if they are acceptable I suspect it is too late for GCC- > > 10 anyway: > > libgcc: Dont define __do_global_dtors_aux if it will be empty > > https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00417.html > > libgcc: Implement TARGET_LIBGCC_REMOVE_DSO_HANDLE > > https://gcc.gnu.org/ml/gcc-patches/2019-11/msg00418.html > > > > (The second one is a bit hacky, but without some way of removing the > > __dso_handle declaration, we end up with 150 bytes of unnecessary > > code in some > > programs.) > > > > So for this patch crtstuff.c was copied to the msp430 subdirectory > > and the > > changes were made to that target specific version. > > > > Tiny program size can now be achieved by configuring gcc for msp430- > > elfbare. > > > > For example in an "empty main" program which loops forever: > > msp430-elfbare @ -Os: > > text data bss dec hex filename > > 14 0 0 14 e a.out > > msp430-elf @ -Os: > > text data bss dec hex filename > > 270 6 2 278 116 a.out > > > > Successfully regtested msp430-elfbare vs msp430-elf. > > > > Ok to apply? > > > > P.S. This patch relies on the -fno-exceptions multilib patch > > submitted here: > > https://gcc.gnu.org/ml/gcc-patches/2019-11/msg02523.html > > > > P.P.S. This requires some minor configury tweaks to Newlib and GDB of > > the form: > > - msp430*-*-elf) > > + msp430-*-elf*) > > > I'll apply these changes if the patch is accepted. > > From cff4611855d838315e793d45256de5fc8eeefafe Mon Sep 17 00:00:00 > > 2001 > > From: Jozef Lawrynowicz <joze...@mittosystems.com> > > Date: Mon, 25 Nov 2019 19:41:05 +0000 > > Subject: [PATCH] MSP430: Add new msp430-elfbare target > > > > contrib/ChangeLog: > > > > 2019-11-29 Jozef Lawrynowicz <joze...@mittosystems.com> > > > > * config-list.mk: Add msp430-elfbare. > > > > gcc/ChangeLog: > > > > 2019-11-29 Jozef Lawrynowicz <joze...@mittosystems.com> > > > > * config.gcc: s/msp430*-*-*/msp430-*-*. > > Handle msp430-*-elfbare. > > * config/msp430/msp430-devices.c (TARGET_SUBDIR): Define. > > (_MSPMKSTR): Define. > > (__MSPMKSTR): Define. > > (rest_of_devices_path): Use TARGET_SUBDIR value in string. > > * config/msp430/msp430.c (msp430_option_override): Error if > > -fuse-cxa-atexit is used when it has been disabled at configure > > time. > > * config/msp430/t-msp430: Define TARGET_SUBDIR when building > > msp430-devices.o. > > * doc/install.texi: Document msp430-*-elf and msp430-*-elfbare. > > * doc/invoke.texi: Update documentation about which path > > devices.csv is > > searched for. > > > > gcc/testsuite/ChangeLog: > > > > 2019-11-29 Jozef Lawrynowicz <joze...@mittosystems.com> > > > > * g++.dg/init/dso_handle1.C: Require cxa_atexit support. > > * g++.dg/init/dso_handle2.C: Likewise. > > * g++.dg/other/cxa-atexit1.C: Likewise. > > * gcc.target/msp430/msp430.exp: Update csv-using-installed.c > > test to > > handle msp430-elfbare configuration. > > > > libgcc/ChangeLog: > > > > 2019-11-29 Jozef Lawrynowicz <joze...@mittosystems.com> > > > > * config.host: Use t-msp430-elfbare-crtstuff Makefile fragment > > when GCC > > is configured for the msp430-elfbare target. > > * config/msp430/msp430-elfbare-crtstuff.c: New file. > > * config/msp430/t-msp430: Remove Makefile rules for object > > files > > built from crtstuff.c > > * config/msp430/t-msp430-crtstuff: New file. > > * config/msp430/t-msp430-elfbare-crtstuff: New file. > > * configure: Regenerate. > > * configure.ac: Disable TM clone registry by default for > > msp430-elfbare. > OK. I probably would have tried to avoid msp430-elfbare-crtstuff, but > it's not a huge wart IMHO.
If we get the __dso_handle removal into the generic libgcc/crtstuff.c those changes won't be necessary. Did you get a chance to look at "Add -fno-exceptions multilib" - https://gcc.gnu.org/ml/gcc-patches/2019-11/msg02523.html It is the cumulative effect of these patches that gives the good code size results, unfortunately without them all there isn't a significant code size improvement. Thanks, Jozef > > Jeff > > >