build/autoconf/arch.m4

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:f99ec4fd777d
1 dnl This Source Code Form is subject to the terms of the Mozilla Public
2 dnl License, v. 2.0. If a copy of the MPL was not distributed with this
3 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 AC_DEFUN([MOZ_ARCH_OPTS],
6 [
7
8 dnl ========================================================
9 dnl = ARM toolchain tweaks
10 dnl ========================================================
11
12 MOZ_THUMB=toolchain-default
13 MOZ_THUMB_INTERWORK=toolchain-default
14 MOZ_FPU=toolchain-default
15 MOZ_FLOAT_ABI=toolchain-default
16 MOZ_SOFT_FLOAT=toolchain-default
17 MOZ_ALIGN=toolchain-default
18
19 MOZ_ARG_WITH_STRING(arch,
20 [ --with-arch=[[type|toolchain-default]]
21 Use specific CPU features (-march=type). Resets
22 thumb, fpu, float-abi, etc. defaults when set],
23 if test -z "$GNU_CC"; then
24 AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchains])
25 fi
26 MOZ_ARCH=$withval)
27
28 if test -z "$MOZ_ARCH"; then
29 dnl Defaults
30 case "${CPU_ARCH}-${OS_TARGET}" in
31 arm-Android)
32 MOZ_THUMB=yes
33 MOZ_ARCH=armv7-a
34 MOZ_FPU=vfp
35 MOZ_FLOAT_ABI=softfp
36 MOZ_ALIGN=no
37 ;;
38 arm-Darwin)
39 MOZ_ARCH=toolchain-default
40 MOZ_THUMB=yes
41 ;;
42 esac
43 fi
44
45 if test "$MOZ_ARCH" = "armv6" -a "$OS_TARGET" = "Android"; then
46 MOZ_FPU=vfp
47 fi
48
49 MOZ_ARG_WITH_STRING(thumb,
50 [ --with-thumb[[=yes|no|toolchain-default]]]
51 [ Use Thumb instruction set (-mthumb)],
52 if test -z "$GNU_CC"; then
53 AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchains])
54 fi
55 MOZ_THUMB=$withval)
56
57 MOZ_ARG_WITH_STRING(thumb-interwork,
58 [ --with-thumb-interwork[[=yes|no|toolchain-default]]
59 Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
60 if test -z "$GNU_CC"; then
61 AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchains])
62 fi
63 MOZ_THUMB_INTERWORK=$withval)
64
65 MOZ_ARG_WITH_STRING(fpu,
66 [ --with-fpu=[[type|toolchain-default]]
67 Use specific FPU type (-mfpu=type)],
68 if test -z "$GNU_CC"; then
69 AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchains])
70 fi
71 MOZ_FPU=$withval)
72
73 MOZ_ARG_WITH_STRING(float-abi,
74 [ --with-float-abi=[[type|toolchain-default]]
75 Use specific arm float ABI (-mfloat-abi=type)],
76 if test -z "$GNU_CC"; then
77 AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchains])
78 fi
79 MOZ_FLOAT_ABI=$withval)
80
81 MOZ_ARG_WITH_STRING(soft-float,
82 [ --with-soft-float[[=yes|no|toolchain-default]]
83 Use soft float library (-msoft-float)],
84 if test -z "$GNU_CC"; then
85 AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchains])
86 fi
87 MOZ_SOFT_FLOAT=$withval)
88
89 case "$MOZ_ARCH" in
90 toolchain-default|"")
91 arch_flag=""
92 ;;
93 *)
94 arch_flag="-march=$MOZ_ARCH"
95 ;;
96 esac
97
98 case "$MOZ_THUMB" in
99 yes)
100 MOZ_THUMB2=1
101 thumb_flag="-mthumb"
102 ;;
103 no)
104 MOZ_THUMB2=
105 thumb_flag="-marm"
106 ;;
107 *)
108 _SAVE_CFLAGS="$CFLAGS"
109 CFLAGS="$arch_flag"
110 AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
111 MOZ_THUMB2=1,
112 MOZ_THUMB2=)
113 CFLAGS="$_SAVE_CFLAGS"
114 thumb_flag=""
115 ;;
116 esac
117
118 if test "$MOZ_THUMB2" = 1; then
119 AC_DEFINE(MOZ_THUMB2)
120 fi
121
122 case "$MOZ_THUMB_INTERWORK" in
123 yes)
124 thumb_interwork_flag="-mthumb-interwork"
125 ;;
126 no)
127 thumb_interwork_flag="-mno-thumb-interwork"
128 ;;
129 *) # toolchain-default
130 thumb_interwork_flag=""
131 ;;
132 esac
133
134 case "$MOZ_FPU" in
135 toolchain-default|"")
136 fpu_flag=""
137 ;;
138 *)
139 fpu_flag="-mfpu=$MOZ_FPU"
140 ;;
141 esac
142
143 case "$MOZ_FLOAT_ABI" in
144 toolchain-default|"")
145 float_abi_flag=""
146 ;;
147 *)
148 float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
149 ;;
150 esac
151
152 case "$MOZ_SOFT_FLOAT" in
153 yes)
154 soft_float_flag="-msoft-float"
155 ;;
156 no)
157 soft_float_flag="-mno-soft-float"
158 ;;
159 *) # toolchain-default
160 soft_float_flag=""
161 ;;
162 esac
163
164 case "$MOZ_ALIGN" in
165 no)
166 align_flag="-mno-unaligned-access"
167 ;;
168 yes)
169 align_flag="-munaligned-access"
170 ;;
171 *)
172 align_flag=""
173 ;;
174 esac
175
176 if test -n "$align_flag"; then
177 _SAVE_CFLAGS="$CFLAGS"
178 CFLAGS="$CFLAGS $align_flag"
179 AC_MSG_CHECKING(whether alignment flag ($align_flag) is supported)
180 AC_TRY_COMPILE([],[],,align_flag="")
181 CFLAGS="$_SAVE_CFLAGS"
182 fi
183
184 dnl Use echo to avoid accumulating space characters
185 all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag $align_flag`
186 if test -n "$all_flags"; then
187 _SAVE_CFLAGS="$CFLAGS"
188 CFLAGS="$all_flags"
189 AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
190 AC_TRY_COMPILE([],[return 0;],
191 AC_MSG_RESULT([yes]),
192 AC_MSG_ERROR([no]))
193
194 CFLAGS="$_SAVE_CFLAGS $all_flags"
195 CXXFLAGS="$CXXFLAGS $all_flags"
196 ASFLAGS="$ASFLAGS $all_flags"
197 if test -n "$thumb_flag"; then
198 LDFLAGS="$LDFLAGS $thumb_flag"
199 fi
200 fi
201
202 AC_SUBST(MOZ_THUMB2)
203
204 if test "$CPU_ARCH" = "arm"; then
205 AC_MSG_CHECKING(for ARM SIMD support in compiler)
206 # We try to link so that this also fails when
207 # building with LTO.
208 AC_TRY_LINK([],
209 [asm("uqadd8 r1, r1, r2");],
210 result="yes", result="no")
211 AC_MSG_RESULT("$result")
212 if test "$result" = "yes"; then
213 AC_DEFINE(HAVE_ARM_SIMD)
214 HAVE_ARM_SIMD=1
215 fi
216
217 AC_MSG_CHECKING(ARM version support in compiler)
218 dnl Determine the target ARM architecture (5 for ARMv5, v5T, v5E, etc.; 6 for ARMv6, v6K, etc.)
219 ARM_ARCH=`${CC-cc} ${CFLAGS} -dM -E - < /dev/null | sed -n 's/.*__ARM_ARCH_\([[0-9]][[0-9]]*\).*/\1/p'`
220 AC_MSG_RESULT("$ARM_ARCH")
221
222 AC_MSG_CHECKING(for ARM NEON support in compiler)
223 # We try to link so that this also fails when
224 # building with LTO.
225 AC_TRY_LINK([],
226 [asm(".fpu neon\n vadd.i8 d0, d0, d0");],
227 result="yes", result="no")
228 AC_MSG_RESULT("$result")
229 if test "$result" = "yes"; then
230 AC_DEFINE(HAVE_ARM_NEON)
231 HAVE_ARM_NEON=1
232
233 dnl We don't need to build NEON support if we're targetting a non-NEON device.
234 dnl This matches media/webrtc/trunk/webrtc/build/common.gypi.
235 if test -n "$ARM_ARCH"; then
236 if test "$ARM_ARCH" -lt 7; then
237 BUILD_ARM_NEON=
238 else
239 AC_DEFINE(BUILD_ARM_NEON)
240 BUILD_ARM_NEON=1
241 fi
242 fi
243 fi
244
245 fi # CPU_ARCH = arm
246
247 AC_SUBST(HAVE_ARM_SIMD)
248 AC_SUBST(HAVE_ARM_NEON)
249 AC_SUBST(BUILD_ARM_NEON)
250 AC_SUBST(ARM_ARCH)
251
252 if test -n "$MOZ_ARCH"; then
253 NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-arch=$MOZ_ARCH"
254 NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-thumb=$MOZ_THUMB"
255 NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-thumb-interwork=$MOZ_THUMB_INTERWORK"
256 NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-fpu=$MOZ_FPU"
257 NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-float-abi=$MOZ_FLOAT_ABI"
258 NSPR_CONFIGURE_ARGS="$NSPR_CONFIGURE_ARGS --with-soft-float=$MOZ_SOFT_FLOAT"
259 fi
260
261 ])

mercurial