summaryrefslogtreecommitdiffstats
path: root/yocto-poky/meta/recipes-devtools/gcc/gcc-5.2/0040-nativesdk-gcc-support.patch
blob: fd81ae24495e68c05d4056ce4d1b27116a20919d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
Being able to build a nativesdk gcc is useful, particularly in cases
where the host compiler may be of an incompatible version (or a 32
bit compiler is needed).

Sadly, building nativesdk-gcc is not straight forward. We install
nativesdk-gcc into a relocatable location and this means that its
library locations can change. "Normal" sysroot support doesn't help
in this case since the values of paths like "libdir" change, not just
base root directory of the system.

In order to handle this we do two things:

a) Add %r into spec file markup which can be used for injected paths
   such as SYSTEMLIBS_DIR (see gcc_multilib_setup()).
b) Add other paths which need relocation into a .gccrelocprefix section
   which the relocation code will notice and adjust automatically.


Upstream-Status: Inappropriate
RP 2015/7/28

diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c
--- a/gcc/cppdefault.c
+++ b/gcc/cppdefault.c
@@ -35,6 +35,30 @@
 # undef CROSS_INCLUDE_DIR
 #endif
 
+static char GPLUSPLUS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_INCLUDE_DIR;
+static char GCC_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GCC_INCLUDE_DIR;
+static char GPLUSPLUS_TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_TOOL_INCLUDE_DIR;
+static char GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = GPLUSPLUS_BACKWARD_INCLUDE_DIR;
+static char STANDARD_STARTFILE_PREFIX_2VAR[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET;
+#ifdef LOCAL_INCLUDE_DIR
+static char LOCAL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = LOCAL_INCLUDE_DIR;
+#endif
+#ifdef PREFIX_INCLUDE_DIR
+static char PREFIX_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = PREFIX_INCLUDE_DIR;
+#endif
+#ifdef FIXED_INCLUDE_DIR
+static char FIXED_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = FIXED_INCLUDE_DIR;
+#endif
+#ifdef CROSS_INCLUDE_DIR
+static char CROSS_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = CROSS_INCLUDE_DIR;
+#endif
+#ifdef TOOL_INCLUDE_DIR
+static char TOOL_INCLUDE_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = TOOL_INCLUDE_DIR;
+#endif
+#ifdef NATIVE_SYSTEM_HEADER_DIR
+static char NATIVE_SYSTEM_HEADER_DIRVAR[4096] __attribute__ ((section (".gccrelocprefix"))) = NATIVE_SYSTEM_HEADER_DIR;
+#endif
+
 const struct default_include cpp_include_defaults[]
 #ifdef INCLUDE_DEFAULTS
 = INCLUDE_DEFAULTS;
@@ -42,38 +66,38 @@ const struct default_include cpp_include_defaults[]
 = {
 #ifdef GPLUSPLUS_INCLUDE_DIR
     /* Pick up GNU C++ generic include files.  */
-    { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,
+    { GPLUSPLUS_INCLUDE_DIRVAR, "G++", 1, 1,
       GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
 #endif
 #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR
     /* Pick up GNU C++ target-dependent include files.  */
-    { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,
+    { GPLUSPLUS_TOOL_INCLUDE_DIRVAR, "G++", 1, 1,
       GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },
 #endif
 #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
     /* Pick up GNU C++ backward and deprecated include files.  */
-    { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1,
+    { GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR, "G++", 1, 1,
       GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
 #endif
 #ifdef GCC_INCLUDE_DIR
     /* This is the dir for gcc's private headers.  */
-    { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
+    { GCC_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 0 },
 #endif
 #ifdef GCC_INCLUDE_SUBDIR_TARGET
     /* This is the dir for gcc's private headers under the specified sysroot.  */
-    { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0 },
+    { STANDARD_STARTFILE_PREFIX_2VAR, "GCC", 0, 0, 1, 0 },
 #endif
 #ifdef LOCAL_INCLUDE_DIR
     /* /usr/local/include comes before the fixincluded header files.  */
-    { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
-    { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
+    { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 2 },
+    { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 0 },
 #endif
 #ifdef PREFIX_INCLUDE_DIR
-    { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 },
+    { PREFIX_INCLUDE_DIRVAR, 0, 0, 1, 0, 0 },
 #endif
 #ifdef FIXED_INCLUDE_DIR
     /* This is the dir for fixincludes.  */
-    { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0,
+    { FIXED_INCLUDE_DIRVAR, "GCC", 0, 0, 0,
       /* A multilib suffix needs adding if different multilibs use
 	 different headers.  */
 #ifdef SYSROOT_HEADERS_SUFFIX_SPEC
@@ -85,16 +109,16 @@ const struct default_include cpp_include_defaults[]
 #endif
 #ifdef CROSS_INCLUDE_DIR
     /* One place the target system's headers might be.  */
-    { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
+    { CROSS_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 0 },
 #endif
 #ifdef TOOL_INCLUDE_DIR
     /* Another place the target system's headers might be.  */
-    { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0 },
+    { TOOL_INCLUDE_DIRVAR, "BINUTILS", 0, 1, 0, 0 },
 #endif
 #ifdef NATIVE_SYSTEM_HEADER_DIR
     /* /usr/include comes dead last.  */
-    { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 },
-    { NATIVE_SYSTEM_HEADER_DIR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 },
+    { NATIVE_SYSTEM_HEADER_DIRVAR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 2 },
+    { NATIVE_SYSTEM_HEADER_DIRVAR, NATIVE_SYSTEM_HEADER_COMPONENT, 0, 0, 1, 0 },
 #endif
     { 0, 0, 0, 0, 0, 0 }
   };
diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h
--- a/gcc/cppdefault.h
+++ b/gcc/cppdefault.h
@@ -33,7 +33,8 @@
 
 struct default_include
 {
-  const char *const fname;	/* The name of the directory.  */
+  const char *fname;     /* The name of the directory.  */
+
   const char *const component;	/* The component containing the directory
 				   (see update_path in prefix.c) */
   const char cplusplus;		/* Only look here if we're compiling C++.  */
diff --git a/gcc/gcc.c b/gcc/gcc.c
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -120,6 +120,8 @@ static const char *target_system_root = TARGET_SYSTEM_ROOT;
 #else
 static const char *target_system_root = 0;
 #endif
+ 
+static char target_relocatable_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = SYSTEMLIBS_DIR;
 
 /* Nonzero means pass the updated target_system_root to the compiler.  */
 
@@ -390,6 +392,7 @@ or with constant text in a single argument.
  %G     process LIBGCC_SPEC as a spec.
  %R     Output the concatenation of target_system_root and
         target_sysroot_suffix.
+ %r     Output the base path target_relocatable_prefix
  %S     process STARTFILE_SPEC as a spec.  A capital S is actually used here.
  %E     process ENDFILE_SPEC as a spec.  A capital E is actually used here.
  %C     process CPP_SPEC as a spec.
@@ -1286,10 +1289,10 @@ static const char *gcc_libexec_prefix;
    gcc_exec_prefix is set because, in that case, we know where the
    compiler has been installed, and use paths relative to that
    location instead.  */
-static const char *const standard_exec_prefix = STANDARD_EXEC_PREFIX;
-static const char *const standard_libexec_prefix = STANDARD_LIBEXEC_PREFIX;
-static const char *const standard_bindir_prefix = STANDARD_BINDIR_PREFIX;
-static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
+static char standard_exec_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_EXEC_PREFIX;
+static char standard_libexec_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_LIBEXEC_PREFIX;
+static char standard_bindir_prefix[4096] __attribute__ ((section (".gccrelocprefix"))) = STANDARD_BINDIR_PREFIX;
+static char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
 
 /* For native compilers, these are well-known paths containing
    components that may be provided by the system.  For cross
@@ -1297,9 +1300,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
 static const char *md_exec_prefix = MD_EXEC_PREFIX;
 static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
 static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
-static const char *const standard_startfile_prefix_1
+static char standard_startfile_prefix_1[4096] __attribute__ ((section (".gccrelocprefix")))
   = STANDARD_STARTFILE_PREFIX_1;
-static const char *const standard_startfile_prefix_2
+static char standard_startfile_prefix_2[4096] __attribute__ ((section (".gccrelocprefix")))
   = STANDARD_STARTFILE_PREFIX_2;
 
 /* A relative path to be used in finding the location of tools
@@ -5550,6 +5553,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
 	      }
 	    break;
 
+          case 'r':
+              obstack_grow (&obstack, target_relocatable_prefix,
+		      strlen (target_relocatable_prefix));
+            break;
+
 	  case 'S':
 	    value = do_spec_1 (startfile_spec, 0, NULL);
 	    if (value != 0)
OpenPOWER on IntegriCloud