[committed,MSP430] Enable initfini_array by default

Message ID 20190724224030.7824ed22@jozef-kubuntu
State New
Headers show
Series
  • [committed,MSP430] Enable initfini_array by default
Related show

Commit Message

Jozef Lawrynowicz July 24, 2019, 9:40 p.m.
A recent patch to newlib (commit 884b05b54) removes the .init/.fini sections
from the CRT library for msp430.
initfini_array must now be enabled by default, so that libgcc/crtstuff.c does
not try to put functions relating to .ctors/.dtors in .init/.fini.

.init_array was already the preferred way of running global C++ constructors
for msp430-elf (and it is what the ABI specifies).

initfini_array can be explicitly disabled by passing --disable-initfini-array to
configure.

Committed on trunk as obvious.

Patch

From f0a47dba32e640a3cd0d3b18d3cadab3aa5cbb05 Mon Sep 17 00:00:00 2001
From: jozefl <jozefl@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 24 Jul 2019 21:13:54 +0000
Subject: [PATCH] 2019-07-24  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	* config.gcc (msp430*-*-*): Enable initfini_array by default unless
	explicitly disabled with --disable-initfini-array.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@273774 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog  | 5 +++++
 gcc/config.gcc | 6 ++++++
 2 files changed, 11 insertions(+)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8ed57edef03..8afc61ded72 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@ 
+2019-07-24  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
+
+	* config.gcc (msp430*-*-*): Enable initfini_array by default unless
+	explicitly disabled with --disable-initfini-array.
+
 2019-07-24  Jozef Lawrynowicz  <jozef.l@mittosystems.com>
 
 	* config/msp430/msp430.h (ENDFILE_SPEC): Wrap uses of crtn*.o in
diff --git a/gcc/config.gcc b/gcc/config.gcc
index e55c67a4248..76c0cb3674c 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2512,6 +2512,12 @@  msp430*-*-*)
 	cxx_target_objs="msp430-c.o"
 	tmake_file="${tmake_file} msp430/t-msp430"
 	extra_gcc_objs="driver-msp430.o"
+	# Enable .init_array unless it has been explicitly disabled.
+	# The MSP430 EABI mandates the use of .init_array, and the Newlib CRT
+	# code since mid-2019 expects it.
+	if test x${disable_initfini_array} != xyes; then
+		gcc_cv_initfini_array=yes
+	fi
 	;;
 nds32*-*-*)
 	target_cpu_default="0"
-- 
2.17.1