diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/mips/Makefile | 208 |
1 files changed, 39 insertions, 169 deletions
diff --git a/arch/mips/Makefile b/arch/mips/Makefile index c626dd5942f6..9a69e0f0ab76 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile | |||
@@ -12,10 +12,6 @@ | |||
12 | # for "archclean" cleaning up for this architecture. | 12 | # for "archclean" cleaning up for this architecture. |
13 | # | 13 | # |
14 | 14 | ||
15 | as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \ | ||
16 | -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \ | ||
17 | else echo "$(2)"; fi ;) | ||
18 | |||
19 | cflags-y := | 15 | cflags-y := |
20 | 16 | ||
21 | # | 17 | # |
@@ -38,12 +34,10 @@ else | |||
38 | endif | 34 | endif |
39 | 35 | ||
40 | ifdef CONFIG_32BIT | 36 | ifdef CONFIG_32BIT |
41 | gcc-abi = 32 | ||
42 | tool-prefix = $(32bit-tool-prefix) | 37 | tool-prefix = $(32bit-tool-prefix) |
43 | UTS_MACHINE := mips | 38 | UTS_MACHINE := mips |
44 | endif | 39 | endif |
45 | ifdef CONFIG_64BIT | 40 | ifdef CONFIG_64BIT |
46 | gcc-abi = 64 | ||
47 | tool-prefix = $(64bit-tool-prefix) | 41 | tool-prefix = $(64bit-tool-prefix) |
48 | UTS_MACHINE := mips64 | 42 | UTS_MACHINE := mips64 |
49 | endif | 43 | endif |
@@ -52,40 +46,28 @@ ifdef CONFIG_CROSSCOMPILE | |||
52 | CROSS_COMPILE := $(tool-prefix) | 46 | CROSS_COMPILE := $(tool-prefix) |
53 | endif | 47 | endif |
54 | 48 | ||
55 | CHECKFLAGS-y += -D__linux__ -D__mips__ \ | ||
56 | -D_MIPS_SZINT=32 \ | ||
57 | -D_ABIO32=1 \ | ||
58 | -D_ABIN32=2 \ | ||
59 | -D_ABI64=3 | ||
60 | CHECKFLAGS-$(CONFIG_32BIT) += -D_MIPS_SIM=_ABIO32 \ | ||
61 | -D_MIPS_SZLONG=32 \ | ||
62 | -D_MIPS_SZPTR=32 \ | ||
63 | -D__PTRDIFF_TYPE__=int | ||
64 | CHECKFLAGS-$(CONFIG_64BIT) += -m64 -D_MIPS_SIM=_ABI64 \ | ||
65 | -D_MIPS_SZLONG=64 \ | ||
66 | -D_MIPS_SZPTR=64 \ | ||
67 | -D__PTRDIFF_TYPE__="long int" | ||
68 | CHECKFLAGS-$(CONFIG_CPU_BIG_ENDIAN) += -D__MIPSEB__ | ||
69 | CHECKFLAGS-$(CONFIG_CPU_LITTLE_ENDIAN) += -D__MIPSEL__ | ||
70 | |||
71 | CHECKFLAGS = $(CHECKFLAGS-y) | ||
72 | |||
73 | ifdef CONFIG_32BIT | 49 | ifdef CONFIG_32BIT |
74 | gas-abi = 32 | ||
75 | ld-emul = $(32bit-emul) | 50 | ld-emul = $(32bit-emul) |
76 | vmlinux-32 = vmlinux | 51 | vmlinux-32 = vmlinux |
77 | vmlinux-64 = vmlinux.64 | 52 | vmlinux-64 = vmlinux.64 |
53 | |||
54 | cflags-y += -mabi=32 | ||
78 | endif | 55 | endif |
79 | 56 | ||
80 | ifdef CONFIG_64BIT | 57 | ifdef CONFIG_64BIT |
81 | gas-abi = 64 | ||
82 | ld-emul = $(64bit-emul) | 58 | ld-emul = $(64bit-emul) |
83 | vmlinux-32 = vmlinux.32 | 59 | vmlinux-32 = vmlinux.32 |
84 | vmlinux-64 = vmlinux | 60 | vmlinux-64 = vmlinux |
85 | 61 | ||
62 | cflags-y += -mabi=64 | ||
63 | ifdef CONFIG_BUILD_ELF64 | ||
86 | cflags-y += $(call cc-option,-mno-explicit-relocs) | 64 | cflags-y += $(call cc-option,-mno-explicit-relocs) |
65 | else | ||
66 | cflags-y += $(call cc-option,-msym32) | ||
67 | endif | ||
87 | endif | 68 | endif |
88 | 69 | ||
70 | |||
89 | # | 71 | # |
90 | # GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel | 72 | # GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel |
91 | # code since it only slows down the whole thing. At some point we might make | 73 | # code since it only slows down the whole thing. At some point we might make |
@@ -107,162 +89,44 @@ MODFLAGS += -mlong-calls | |||
107 | # carefully avoid to add it redundantly because gcc 3.3/3.4 complains | 89 | # carefully avoid to add it redundantly because gcc 3.3/3.4 complains |
108 | # when fed the toolchain default! | 90 | # when fed the toolchain default! |
109 | # | 91 | # |
110 | cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB) | 92 | cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB -D__MIPSEB__) |
111 | cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL) | 93 | cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL -D__MIPSEL__) |
112 | 94 | ||
113 | cflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \ | 95 | cflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \ |
114 | -fno-omit-frame-pointer | 96 | -fno-omit-frame-pointer |
115 | 97 | ||
116 | # | 98 | # |
117 | # Use: $(call set_gccflags,<cpu0>,<isa0>,<cpu1>,<isa1>,<isa2>) | ||
118 | # | ||
119 | # <cpu0>,<isa0> -- preferred CPU and ISA designations (may require | ||
120 | # recent tools) | ||
121 | # <cpu1>,<isa1> -- fallback CPU and ISA designations (have to work | ||
122 | # with up to the oldest supported tools) | ||
123 | # <isa2> -- an ISA designation used as an ABI selector for | ||
124 | # gcc versions that do not support "-mabi=32" | ||
125 | # (depending on the CPU type, either "mips1" or | ||
126 | # "mips2") | ||
127 | # | ||
128 | set_gccflags = $(shell \ | ||
129 | while :; do \ | ||
130 | cpu=$(1); isa=-$(2); \ | ||
131 | for gcc_opt in -march= -mcpu=; do \ | ||
132 | $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \ | ||
133 | -xc /dev/null > /dev/null 2>&1 && \ | ||
134 | break 2; \ | ||
135 | done; \ | ||
136 | cpu=$(3); isa=-$(4); \ | ||
137 | for gcc_opt in -march= -mcpu=; do \ | ||
138 | $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \ | ||
139 | -xc /dev/null > /dev/null 2>&1 && \ | ||
140 | break 2; \ | ||
141 | done; \ | ||
142 | break; \ | ||
143 | done; \ | ||
144 | gcc_abi=-mabi=$(gcc-abi); gcc_cpu=$$cpu; \ | ||
145 | if $(CC) $$gcc_abi -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then \ | ||
146 | gcc_isa=$$isa; \ | ||
147 | else \ | ||
148 | gcc_abi=; gcc_isa=-$(5); \ | ||
149 | fi; \ | ||
150 | gas_abi=-Wa,-$(gcc-abi); gas_cpu=$$cpu; gas_isa=-Wa,$$isa; \ | ||
151 | while :; do \ | ||
152 | for gas_opt in -Wa,-march= -Wa,-mcpu=; do \ | ||
153 | $(CC) $$gas_abi $$gas_opt$$cpu $$gas_isa -Wa,-Z -c \ | ||
154 | -o /dev/null -xassembler /dev/null > /dev/null 2>&1 && \ | ||
155 | break 2; \ | ||
156 | done; \ | ||
157 | gas_abi=; gas_opt=; gas_cpu=; gas_isa=; \ | ||
158 | break; \ | ||
159 | done; \ | ||
160 | if test "$(gcc-abi)" != "$(gas-abi)"; then \ | ||
161 | gas_abi="-Wa,-$(gas-abi) -Wa,-mgp$(gcc-abi)"; \ | ||
162 | fi; \ | ||
163 | if test "$$gcc_opt" = -march= && test -n "$$gcc_abi"; then \ | ||
164 | $(CC) $$gcc_abi $$gcc_opt$$gcc_cpu -S -o /dev/null \ | ||
165 | -xc /dev/null > /dev/null 2>&1 && \ | ||
166 | gcc_isa=; \ | ||
167 | fi; \ | ||
168 | echo $$gcc_abi $$gcc_opt$$gcc_cpu $$gcc_isa $$gas_abi $$gas_opt$$gas_cpu $$gas_isa) | ||
169 | |||
170 | # | ||
171 | # CPU-dependent compiler/assembler options for optimization. | 99 | # CPU-dependent compiler/assembler options for optimization. |
172 | # | 100 | # |
173 | cflags-$(CONFIG_CPU_R3000) += \ | 101 | cflags-$(CONFIG_CPU_R3000) += -march=r3000 |
174 | $(call set_gccflags,r3000,mips1,r3000,mips1,mips1) | 102 | cflags-$(CONFIG_CPU_TX39XX) += -march=r3900 |
175 | CHECKFLAGS-$(CONFIG_CPU_R3000) += -D_MIPS_ISA=_MIPS_ISA_MIPS1 | 103 | cflags-$(CONFIG_CPU_R6000) += -march=r6000 -Wa,--trap |
176 | 104 | cflags-$(CONFIG_CPU_R4300) += -march=r4300 -Wa,--trap | |
177 | cflags-$(CONFIG_CPU_TX39XX) += \ | 105 | cflags-$(CONFIG_CPU_VR41XX) += -march=r4100 -Wa,--trap |
178 | $(call set_gccflags,r3900,mips1,r3000,mips1,mips1) | 106 | cflags-$(CONFIG_CPU_R4X00) += -march=r4600 -Wa,--trap |
179 | CHECKFLAGS-$(CONFIG_CPU_TX39XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS1 | 107 | cflags-$(CONFIG_CPU_TX49XX) += -march=r4600 -Wa,--trap |
180 | 108 | cflags-$(CONFIG_CPU_MIPS32_R1) += $(call cc-option,-march=mips32,-mips2 -mtune=r4600) \ | |
181 | cflags-$(CONFIG_CPU_R6000) += \ | 109 | -Wa,-mips32 -Wa,--trap |
182 | $(call set_gccflags,r6000,mips2,r6000,mips2,mips2) \ | 110 | cflags-$(CONFIG_CPU_MIPS32_R2) += $(call cc-option,-march=mips32r2,-mips2 -mtune=r4600) \ |
183 | -Wa,--trap | 111 | -Wa,-mips32r2 -Wa,--trap |
184 | CHECKFLAGS-$(CONFIG_CPU_R6000) += -D_MIPS_ISA=_MIPS_ISA_MIPS2 | 112 | cflags-$(CONFIG_CPU_MIPS64_R1) += $(call cc-option,-march=mips64,-mips2 -mtune=r4600) \ |
185 | 113 | -Wa,-mips64 -Wa,--trap | |
186 | cflags-$(CONFIG_CPU_R4300) += \ | 114 | cflags-$(CONFIG_CPU_MIPS64_R2) += $(call cc-option,-march=mips64r2,-mips2 -mtune=r4600 ) \ |
187 | $(call set_gccflags,r4300,mips3,r4300,mips3,mips2) \ | 115 | -Wa,-mips64r2 -Wa,--trap |
188 | -Wa,--trap | 116 | cflags-$(CONFIG_CPU_R5000) += -march=r5000 -Wa,--trap |
189 | CHECKFLAGS-$(CONFIG_CPU_R4300) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 | 117 | cflags-$(CONFIG_CPU_R5432) += $(call cc-options,-march=r5400,-march=r5000) \ |
190 | |||
191 | cflags-$(CONFIG_CPU_VR41XX) += \ | ||
192 | $(call set_gccflags,r4100,mips3,r4600,mips3,mips2) \ | ||
193 | -Wa,--trap | ||
194 | CHECKFLAGS-$(CONFIG_CPU_VR41XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 | ||
195 | |||
196 | cflags-$(CONFIG_CPU_R4X00) += \ | ||
197 | $(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \ | ||
198 | -Wa,--trap | ||
199 | CHECKFLAGS-$(CONFIG_CPU_R4X00) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 | ||
200 | |||
201 | cflags-$(CONFIG_CPU_TX49XX) += \ | ||
202 | $(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \ | ||
203 | -Wa,--trap | ||
204 | CHECKFLAGS-$(CONFIG_CPU_TX49XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 | ||
205 | |||
206 | cflags-$(CONFIG_CPU_MIPS32_R1) += \ | ||
207 | $(call set_gccflags,mips32,mips32,r4600,mips3,mips2) \ | ||
208 | -Wa,--trap | 118 | -Wa,--trap |
209 | CHECKFLAGS-$(CONFIG_CPU_MIPS32_R1) += -D_MIPS_ISA=_MIPS_ISA_MIPS32 | 119 | cflags-$(CONFIG_CPU_NEVADA) += $(call cc-options,-march=rm5200,-march=r5000) \ |
210 | |||
211 | cflags-$(CONFIG_CPU_MIPS32_R2) += \ | ||
212 | $(call set_gccflags,mips32r2,mips32r2,r4600,mips3,mips2) \ | ||
213 | -Wa,--trap | ||
214 | CHECKFLAGS-$(CONFIG_CPU_MIPS32_R2) += -D_MIPS_ISA=_MIPS_ISA_MIPS32 | ||
215 | |||
216 | cflags-$(CONFIG_CPU_MIPS64_R1) += \ | ||
217 | $(call set_gccflags,mips64,mips64,r4600,mips3,mips2) \ | ||
218 | -Wa,--trap | ||
219 | CHECKFLAGS-$(CONFIG_CPU_MIPS64_R1) += -D_MIPS_ISA=_MIPS_ISA_MIPS64 | ||
220 | |||
221 | cflags-$(CONFIG_CPU_MIPS64_R2) += \ | ||
222 | $(call set_gccflags,mips64r2,mips64r2,r4600,mips3,mips2) \ | ||
223 | -Wa,--trap | ||
224 | CHECKFLAGS-$(CONFIG_CPU_MIPS64_R2) += -D_MIPS_ISA=_MIPS_ISA_MIPS64 | ||
225 | |||
226 | cflags-$(CONFIG_CPU_R5000) += \ | ||
227 | $(call set_gccflags,r5000,mips4,r5000,mips4,mips2) \ | ||
228 | -Wa,--trap | ||
229 | CHECKFLAGS-$(CONFIG_CPU_R5000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | ||
230 | |||
231 | cflags-$(CONFIG_CPU_R5432) += \ | ||
232 | $(call set_gccflags,r5400,mips4,r5000,mips4,mips2) \ | ||
233 | -Wa,--trap | ||
234 | CHECKFLAGS-$(CONFIG_CPU_R5432) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | ||
235 | |||
236 | cflags-$(CONFIG_CPU_NEVADA) += \ | ||
237 | $(call set_gccflags,rm5200,mips4,r5000,mips4,mips2) \ | ||
238 | -Wa,--trap | 120 | -Wa,--trap |
239 | CHECKFLAGS-$(CONFIG_CPU_NEVADA) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | 121 | cflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=r5000) \ |
240 | |||
241 | cflags-$(CONFIG_CPU_RM7000) += \ | ||
242 | $(call set_gccflags,rm7000,mips4,r5000,mips4,mips2) \ | ||
243 | -Wa,--trap | 122 | -Wa,--trap |
244 | CHECKFLAGS-$(CONFIG_CPU_RM7000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | 123 | cflags-$(CONFIG_CPU_RM9000) += $(call cc-option,-march=rm9000,-march=r5000) \ |
245 | |||
246 | cflags-$(CONFIG_CPU_RM9000) += \ | ||
247 | $(call set_gccflags,rm9000,mips4,r5000,mips4,mips2) \ | ||
248 | -Wa,--trap | ||
249 | CHECKFLAGS-$(CONFIG_CPU_RM9000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | ||
250 | |||
251 | |||
252 | cflags-$(CONFIG_CPU_SB1) += \ | ||
253 | $(call set_gccflags,sb1,mips64,r5000,mips4,mips2) \ | ||
254 | -Wa,--trap | 124 | -Wa,--trap |
255 | CHECKFLAGS-$(CONFIG_CPU_SB1) += -D_MIPS_ISA=_MIPS_ISA_MIPS64 | 125 | cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=r5000) \ |
256 | |||
257 | cflags-$(CONFIG_CPU_R8000) += \ | ||
258 | $(call set_gccflags,r8000,mips4,r8000,mips4,mips2) \ | ||
259 | -Wa,--trap | 126 | -Wa,--trap |
260 | CHECKFLAGS-$(CONFIG_CPU_R8000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | 127 | cflags-$(CONFIG_CPU_R8000) += -march=r8000 -Wa,--trap |
261 | 128 | cflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=r8000) \ | |
262 | cflags-$(CONFIG_CPU_R10000) += \ | ||
263 | $(call set_gccflags,r10000,mips4,r8000,mips4,mips2) \ | ||
264 | -Wa,--trap | 129 | -Wa,--trap |
265 | CHECKFLAGS-$(CONFIG_CPU_R10000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | ||
266 | 130 | ||
267 | ifdef CONFIG_CPU_SB1 | 131 | ifdef CONFIG_CPU_SB1 |
268 | ifdef CONFIG_SB1_PASS_1_WORKAROUNDS | 132 | ifdef CONFIG_SB1_PASS_1_WORKAROUNDS |
@@ -748,6 +612,12 @@ CFLAGS += $(cflags-y) | |||
748 | 612 | ||
749 | LDFLAGS += -m $(ld-emul) | 613 | LDFLAGS += -m $(ld-emul) |
750 | 614 | ||
615 | ifdef CONFIG_MIPS | ||
616 | CHECKFLAGS += $(shell $(CC) $(CFLAGS) -dM -E -xc /dev/null | \ | ||
617 | egrep -vw '__GNUC_(MAJOR|MINOR|PATCHLEVEL)__' | \ | ||
618 | sed -e 's/^\#define /-D/' -e 's/ /="/' -e 's/$$/"/') | ||
619 | endif | ||
620 | |||
751 | OBJCOPYFLAGS += --remove-section=.reginfo | 621 | OBJCOPYFLAGS += --remove-section=.reginfo |
752 | 622 | ||
753 | # | 623 | # |