]> gcc.gnu.org Git - gcc.git/commitdiff
MSP430: Add new msp430-elfbare target
authorJozef Lawrynowicz <jozef.l@mittosystems.com>
Mon, 16 Dec 2019 11:02:10 +0000 (11:02 +0000)
committerJozef Lawrynowicz <jozefl@gcc.gnu.org>
Mon, 16 Dec 2019 11:02:10 +0000 (11:02 +0000)
contrib/ChangeLog:

2019-12-16  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

* config-list.mk: Add msp430-elfbare.

gcc/ChangeLog:

2019-12-16  Jozef Lawrynowicz  <jozef.l@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-12-16  Jozef Lawrynowicz  <jozef.l@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-12-16  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

* config.host: s/msp430*-*-elf/msp430-*-elf*.
Override default "extra_parts" variable.
* configure: Regenerate.
* configure.ac: Disable TM clone registry by default for
msp430-elfbare.

From-SVN: r279442

18 files changed:
contrib/ChangeLog
contrib/config-list.mk
gcc/ChangeLog
gcc/config.gcc
gcc/config/msp430/msp430-devices.c
gcc/config/msp430/msp430.c
gcc/config/msp430/t-msp430
gcc/doc/install.texi
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/dso_handle1.C
gcc/testsuite/g++.dg/init/dso_handle2.C
gcc/testsuite/g++.dg/other/cxa-atexit1.C
gcc/testsuite/gcc.target/msp430/msp430.exp
libgcc/ChangeLog
libgcc/config.host
libgcc/configure
libgcc/configure.ac

index e3fef3273ffed7dc12ffcd697ccdff3fdb5cbf2a..cfac553798709d9b7ea16eb152b5eea018a3fcb0 100644 (file)
@@ -1,3 +1,7 @@
+2019-12-16  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
+
+       * config-list.mk: Add msp430-elfbare.
+
 2019-12-09  Lewis Hyatt  <lhyatt@gmail.com>
 
        PR preprocessor/49973
index a5f5d7bbd5ad86af75b60b6137f831f4d8a4e941..d154286a497cb0c8492892b8ee52cd489efac3e8 100644 (file)
@@ -68,7 +68,7 @@ LIST = aarch64-elf aarch64-linux-gnu aarch64-rtems \
   mipsel-elf mips64-elf mips64vr-elf mips64orion-elf mips-rtems \
   mips-wrs-vxworks mipstx39-elf mmix-knuth-mmixware mn10300-elf moxie-elf \
   moxie-uclinux moxie-rtems \
-  msp430-elf \
+  msp430-elf msp430-elfbare \
   nds32le-elf nds32be-elf \
   nios2-elf nios2-linux-gnu nios2-rtems \
   nvptx-none \
index acf14a5bb74abf3103a7c2bdc4c192c1c8ec425e..08d769a76afb60d63d5a8becbf7a9538e0301900 100644 (file)
@@ -1,3 +1,19 @@
+2019-12-16  Jozef Lawrynowicz  <jozef.l@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.
+
 2019-12-16  Andreas Krebbel  <krebbel@linux.ibm.com>
 
        PR target/92950
index 5aa0130135fa3ce95df502b3f84e78832b368375..9802f436e06f3d768073018ff75849beb762fd07 100644 (file)
@@ -2624,7 +2624,7 @@ mn10300-*-*)
        use_collect2=no
        use_gcc_stdint=wrap
        ;;
-msp430*-*-*)
+msp430-*-*)
        tm_file="dbxelf.h elfos.h newlib-stdint.h ${tm_file}"
        c_target_objs="msp430-c.o"
        cxx_target_objs="msp430-c.o"
@@ -2637,6 +2637,18 @@ msp430*-*-*)
        if test x${disable_initfini_array} != xyes; then
                gcc_cv_initfini_array=yes
        fi
+       case ${target} in
+         msp430-*-elfbare)
+           # __cxa_atexit increases code size, and we don't need to support
+           # dynamic shared objects on MSP430, so regular Newlib atexit is a
+           # fine replacement as it also supports registration of more than 32
+           # functions.
+           default_use_cxa_atexit=no
+           # This target does not match the generic *-*-elf case above which
+           # sets use_gcc_stdint=wrap, so explicitly set it here.
+           use_gcc_stdint=wrap
+           ;;
+       esac
        ;;
 nds32*-*-*)
        target_cpu_default="0"
index 600a111b51726b2b8d0ae9478e6341eda7aee409..b379bb2b1d43ec6e497175614b3e39aa97485086 100644 (file)
@@ -71,8 +71,23 @@ msp430_dirname (char *path)
   return path;
 }
 
+/* We need to support both the msp430-elf and msp430-elfbare target aliases.
+   gcc/config/msp430/t-msp430 will define TARGET_SUBDIR to the target_subdir
+   Makefile variable, which will evaluate to the correct subdirectory that
+   needs to be searched for devices.csv.  */
+#ifndef TARGET_SUBDIR
+#define TARGET_SUBDIR msp430-elf
+#endif
+
+#define _MSPMKSTR(x) __MSPMKSTR(x)
+#define __MSPMKSTR(x) #x
+
 /* devices.csv path from the toolchain root.  */
-static const char rest_of_devices_path[] = "/msp430-elf/include/devices/";
+static const char rest_of_devices_path[] =
+  "/" _MSPMKSTR (TARGET_SUBDIR) "/include/devices/";
+
+#undef _MSPMKSTR
+#undef __MSPMKSTR
 
 /* "The default value of GCC_EXEC_PREFIX is prefix/lib/gcc". Strip lib/gcc
    from GCC_EXEC_PREFIX to get the path to the installed toolchain.  */
index 4ebdcf51e8b14ea483c457758563bf126bb13ac8..cce41011aef8aa95593507cec7e9efe8f58688b8 100644 (file)
@@ -288,6 +288,16 @@ msp430_option_override (void)
   if (TARGET_OPT_SPACE && optimize < 3)
     optimize_size = 1;
 
+#if !DEFAULT_USE_CXA_ATEXIT
+  /* For some configurations, we use atexit () instead of __cxa_atexit () by
+     default to save on code size and remove the declaration of __dso_handle
+     from the CRT library.
+     Configuring GCC with --enable-__cxa-atexit re-enables it by defining
+     DEFAULT_USE_CXA_ATEXIT to 1.  */
+  if (flag_use_cxa_atexit)
+    error ("%<-fuse-cxa-atexit%> is not supported for msp430-elf");
+#endif
+
 #ifndef HAVE_NEWLIB_NANO_FORMATTED_IO
   if (TARGET_TINY_PRINTF)
     error ("GCC must be configured with %<--enable-newlib-nano-formatted-io%> "
index e180ce3efdbf6e16a63cdbc2291e7b848270295c..d481696220a29fee7a5fbb0333d21188a89b9c45 100644 (file)
@@ -24,7 +24,7 @@ driver-msp430.o: $(srcdir)/config/msp430/driver-msp430.c \
 
 msp430-devices.o: $(srcdir)/config/msp430/msp430-devices.c \
        $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H)
-       $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
+       $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) -DTARGET_SUBDIR=$(target_subdir) $(INCLUDES) $<
 
 # Enable multilibs:
 
index 19d649ccc83c938f71ebbee44a6197df7ea252ec..656410afff4f658794543301efda675b47dcfc0c 100644 (file)
@@ -4330,10 +4330,24 @@ The moxie processor.
 <hr />
 @end html
 @anchor{msp430-x-elf}
-@heading msp430-*-elf
+@heading msp430-*-elf*
 TI MSP430 processor.
 This configuration is intended for embedded systems.
 
+@samp{msp430-*-elf} is the standard configuration with most GCC
+features enabled by default.
+
+@samp{msp430-*-elfbare} is tuned for a bare-metal environment, and disables
+features related to shared libraries and other functionality not used for
+this device.  This reduces code and data usage of the GCC libraries, resulting
+in a minimal run-time environment by default.
+
+Features disabled by default include:
+@itemize
+@item transactional memory
+@item __cxa_atexit
+@end itemize
+
 @html
 <hr />
 @end html
index 519bd7a297f34ed5afa3c0f9cf30f9c7094e1dcb..f04e915119622015cbb3fe46ea94b3d9a271d5f0 100644 (file)
@@ -23311,8 +23311,8 @@ this directory for devices.csv.  If devices.csv is found, this directory will
 also be registered as an include path, and linker library path.  Header files
 and linker scripts in this directory can therefore be used without manually
 specifying @code{-I} and @code{-L} on the command line.
-@item The @samp{msp430-elf/include/devices} directory
-Finally, GCC will examine @samp{msp430-elf/include/devices} from the
+@item The @samp{msp430-elf@{,bare@}/include/devices} directory
+Finally, GCC will examine @samp{msp430-elf@{,bare@}/include/devices} from the
 toolchain root directory.  This directory does not exist in a default
 installation, but if the user has created it and copied @samp{devices.csv}
 there, then the MCU data will be read.  As above, this directory will
index 247064bd955b1e533cb256b53e97df0905148832..7272aba5dcc2e0fd16e84c8baba4a7c37554def7 100644 (file)
@@ -1,3 +1,11 @@
+2019-12-16  Jozef Lawrynowicz  <jozef.l@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.
+
 2019-12-16  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/specs/clause_on_volatile.ads,
index 97f67cad8f48cf64f64527ff8165867b679863cd..0377c4ef7c0887bcb5201dae3a9fe4acf3a685ee 100644 (file)
@@ -1,6 +1,7 @@
 // PR c++/17042
 // { dg-do assemble }
 /* { dg-require-weak "" } */
+// { dg-require-effective-target cxa_atexit }
 // { dg-options "-fuse-cxa-atexit" }
 
 struct A
index b219dc0261121195e5d131bb9cc855af211e6cba..a4daaf3f7da1cf62cab9a4fdb3936487591cbc56 100644 (file)
@@ -1,4 +1,5 @@
 // PR c++/58846
+// { dg-require-effective-target cxa_atexit }
 // { dg-options "-fuse-cxa-atexit" }
 
 extern "C" { char* __dso_handle; }
index a51f3340142673add9647fcd2ac61a10a9a18ed4..b22911db2e02f3b59e77238399ea9e637c024482 100644 (file)
@@ -1,4 +1,5 @@
 // { dg-do compile }
+// { dg-require-effective-target cxa_atexit }
 // { dg-options "-O2 -fuse-cxa-atexit" }
 
 # 1 "cxa-atexit1.C"
index 37586612b9abb32a229d47708b96d6aa6ce9f1f5..42dc91136c99cd33c5751bed81b4af8980e3aafc 100644 (file)
@@ -141,18 +141,20 @@ proc msp430_device_permutations_runtest { tests } {
 }
 
 
-# Return $TOOLCHAIN_ROOT/msp430-elf/include/devices/
+# Return $TOOLCHAIN_ROOT/$target_alias/include/devices/
+# target_alias is expected to be either msp430-elf or msp430-elfbare.
 proc get_installed_device_data_path { } {
+    global target_alias
     set compiler [lindex [regexp -all -inline {\S+} \
        [board_info [target_info name] compiler]] 0]
     # $compiler is actually a file, but normalize will still get us the desired
     # result.
     return [file normalize \
-       "$compiler/../../msp430-elf/include/devices/devices.csv"]
+       "$compiler/../../$target_alias/include/devices/devices.csv"]
 }
 
 # If the devices.csv is installed in
-# $TOOLCHAIN_ROOT/msp430-elf/include/devices/, rename it so it doesn't
+# $TOOLCHAIN_ROOT/$target_alias/include/devices/, rename it so it doesn't
 # interfere with the hard-coded device data tests.
 proc msp430_hide_installed_devices_data { } {
     set devices_path [get_installed_device_data_path]
index 90ea2a48b3cf98db3ea68952f686d12bede84de0..6faa4d395fd07d20fc1a170be9ca76f5bc8a2574 100644 (file)
@@ -1,3 +1,11 @@
+2019-12-16  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
+
+       * config.host: s/msp430*-*-elf/msp430-*-elf*.
+       Override default "extra_parts" variable.
+       * configure: Regenerate.
+       * configure.ac: Disable TM clone registry by default for
+       msp430-elfbare.
+
 2019-12-11  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
 
        * config.host (msp430*-*-elf): Add crt{begin,end}_no_eh.o to
index 56868719fc8c048d61d3014309f1bf1c05114b38..efcf5f03f50c1c4a6202621257ac765c607ffbae 100644 (file)
@@ -1043,9 +1043,9 @@ moxie-*-elf | moxie-*-moxiebox* | moxie-*-uclinux* | moxie-*-rtems*)
        tmake_file="$tmake_file moxie/t-moxie t-softfp-sfdf t-softfp-excl t-softfp"
        extra_parts="$extra_parts crti.o crtn.o crtbegin.o crtend.o"
        ;;
-msp430*-*-elf)
+msp430-*-elf*)
        tmake_file="$tm_file t-crtstuff t-fdpbit msp430/t-msp430"
-       extra_parts="$extra_parts crtbegin_no_eh.o crtend_no_eh.o"
+       extra_parts="crtbegin.o crtend.o crtbegin_no_eh.o crtend_no_eh.o"
        extra_parts="$extra_parts libmul_none.a libmul_16.a libmul_32.a libmul_f5.a"
        ;;
 nds32*-linux*)
index 117e9c97e575909137f6a3bd2cf2a94045a962b2..97cbad3be56a06e691eb76b3d6e179459a27a9a3 100755 (executable)
@@ -4964,6 +4964,15 @@ if test "$enable_tm_clone_registry" = no; then
   use_tm_clone_registry=-DUSE_TM_CLONE_REGISTRY=0
 fi
 
+else
+
+use_tm_clone_registry=
+case $target in
+  msp430*elfbare)
+   use_tm_clone_registry=-DUSE_TM_CLONE_REGISTRY=0
+   ;;
+esac
+
 fi
 
 
index f63c5e736e5a447b4fd9cd22eddcad3f0100b3d0..2d22f05486d8b659c0fa0ccc782e966256cd067a 100644 (file)
@@ -268,6 +268,14 @@ use_tm_clone_registry=
 if test "$enable_tm_clone_registry" = no; then
   use_tm_clone_registry=-DUSE_TM_CLONE_REGISTRY=0
 fi
+],
+[
+use_tm_clone_registry=
+case $target in
+  msp430*elfbare)
+   use_tm_clone_registry=-DUSE_TM_CLONE_REGISTRY=0
+   ;;
+esac
 ])
 AC_SUBST([use_tm_clone_registry])
 
This page took 0.147544 seconds and 5 git commands to generate.