This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, toplevel] configure nios2-elf libraries to build with -mno-gpopt


People are now starting to build quite large programs for nios2-elf and are running into problems with the small data section getting too large to be entirely within range for GP-relative addressing with a 16-bit offset. This architecture doesn't have an indirect addressing mode with 32-bit offsets and doing halfword loads to construct a 32-bit constant offset with an explicit GP add would be less efficient than a direct reference to the object residing in the small data section, which is what -mno-gpopt does.

The range overflow problem is more likely to affect libraries than user code because of the normal linker allocation strategy, so telling users to build their code with -mno-gpopt is not terribly helpful in many cases -- the libraries have to be built with -mno-gpopt, too. That's what this patch does. It's similar to what is already being done for mips-sde-elf (see config/mt-sde, in particular).

Altera has identified this as an important fix for their users. After discussion, we decided a a similar hack for nios2-linux-gnu targets isn't necessary because most people link against shared libraries instead.

I understand that this patch, although target-specific, needs to be approved by a global reviewer and then propagated to the sourceware.org binutils-gdb and newlib repositories as well. So, OK to commit?

-Sandra

2014-04-24  Sandra Loosemore  <sandra@codesourcery.com>

	* configure.ac (target_makefile_frag): Set for nios2-*-elf*.
	* configure: Regenerated.

	config/
	* mt-nios2-elf: New file.
Index: configure.ac
===================================================================
--- configure.ac	(revision 209669)
+++ configure.ac	(working copy)
@@ -2370,6 +2370,9 @@ case "${target}" in
   mips*-*-*linux* | mips*-*-gnu*)
     target_makefile_frag="config/mt-mips-gnu"
     ;;
+  nios2-*-elf*)
+    target_makefile_frag="config/mt-nios2-elf"
+    ;;
   *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
     target_makefile_frag="config/mt-gnu"
     ;;
Index: config/mt-nios2-elf
===================================================================
--- config/mt-nios2-elf	(revision 0)
+++ config/mt-nios2-elf	(revision 0)
@@ -0,0 +1,5 @@
+# We build library code with -mno-gpopt so that it can be linked with
+# larger executables with small-data sections that exceed the 16-bit
+# offset range for GP-relative addressing.
+CFLAGS_FOR_TARGET += -mno-gpopt
+CXXFLAGS_FOR_TARGET += -mno-gpopt
Index: configure
===================================================================
--- configure	(revision 209669)
+++ configure	(working copy)
@@ -6992,6 +6992,9 @@ case "${target}" in
   mips*-*-*linux* | mips*-*-gnu*)
     target_makefile_frag="config/mt-mips-gnu"
     ;;
+  nios2-*-elf*)
+    target_makefile_frag="config/mt-nios2-elf"
+    ;;
   *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
     target_makefile_frag="config/mt-gnu"
     ;;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]