This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch] New option to enable linux kernel builds
- From: Sterling Augustine <sterling at tensilica dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 10 Feb 2010 16:36:45 -0800
- Subject: [Patch] New option to enable linux kernel builds
[There is no current Xtensa maintainer, although I am again working to
become such. Would someone review and apply this patch please?]
Hello,
On Xtensa, user-land code must be compiled PIC, and thus the current
port ignores the -fno-pic flag, which enables most packages to compile
successfully without a problem.
However, under some fairly unusual circumstances, certain bits of
software--such as parts of the Linux kernel--really do need to be built
without PIC. The attached patch introduces a new Xtensa option
"-mforce-no-pic" to allow this.
Thanks,
Sterling
diff -urd gcc-4.3.3.orig/gcc/config/xtensa/xtensa.c gcc-4.3.3/gcc/config/xtensa/xtensa.c
--- gcc-4.3.3.orig/gcc/config/xtensa/xtensa.c 2008-01-11 14:44:47.000000000 -0800
+++ gcc-4.3.3/gcc/config/xtensa/xtensa.c 2010-01-10 07:59:07.000000000 -0800
@@ -1899,6 +1899,8 @@
if (flag_pic && TARGET_CONST16)
error ("-f%s is not supported with CONST16 instructions",
(flag_pic > 1 ? "PIC" : "pic"));
+ else if (TARGET_FORCE_NO_PIC)
+ flag_pic = 0;
else if (XTENSA_ALWAYS_PIC)
{
if (TARGET_CONST16)
diff -urd gcc-4.3.3.orig/gcc/config/xtensa/xtensa.opt gcc-4.3.3/gcc/config/xtensa/xtensa.opt
--- gcc-4.3.3.orig/gcc/config/xtensa/xtensa.opt 2007-08-02 03:49:31.000000000 -0700
+++ gcc-4.3.3/gcc/config/xtensa/xtensa.opt 2010-01-10 07:59:07.000000000 -0800
@@ -26,6 +26,10 @@
Target Report Mask(FUSED_MADD)
Enable fused multiply/add and multiply/subtract FP instructions
+mforce-no-pic
+Target Report Mask(FORCE_NO_PIC)
+Disable position-independent code (PIC) for use in OS kernel code
+
mlongcalls
Target
Use indirect CALLXn instructions for large programs
diff -urd gcc-4.3.3.orig/gcc/doc/invoke.texi gcc-4.3.3/gcc/doc/invoke.texi
--- gcc-4.3.3.orig/gcc/doc/invoke.texi 2008-11-21 08:21:50.000000000 -0800
+++ gcc-4.3.3/gcc/doc/invoke.texi 2010-01-10 07:59:07.000000000 -0800
@@ -798,6 +798,7 @@
@emph{Xtensa Options}
@gccoptlist{-mconst16 -mno-const16 @gol
-mfused-madd -mno-fused-madd @gol
+-mforce-no-pic @gol
-mtext-section-literals -mno-text-section-literals @gol
-mtarget-align -mno-target-align @gol
-mlongcalls -mno-longcalls}
@@ -14723,6 +14724,12 @@
sensitive to the compiler's ability to combine multiply and add/subtract
operations.
+@item -mforce-no-pic
+@opindex mforce-no-pic
+For targets, like GNU/Linux, where all user-mode Xtensa code must be
+position-independent code (PIC), this option disables PIC for compiling
+kernel code.
+
@item -mtext-section-literals
@itemx -mno-text-section-literals
@opindex mtext-section-literals