1From: Mike Hommey <mh@glandium.org>
2Date: Wed, 27 Apr 2011 08:58:01 +0200
3Subject: Bug 626035 - Modify the way arm compiler flags are set in configure
4
5---
6 configure.in | 292 ++++++++++++++++++++++++++++++++-------------------
7 js/src/configure.in | 284 ++++++++++++++++++++++++++++++++-----------------
8 2 files changed, 372 insertions(+), 204 deletions(-)
9
10Index: mozjs-1.8.5-1.0.0+dfsg/js/src/configure.in
11===================================================================
12--- mozjs-1.8.5-1.0.0+dfsg.orig/js/src/configure.in 2012-01-21 15:57:37.507703219 +0100
13+++ mozjs-1.8.5-1.0.0+dfsg/js/src/configure.in 2012-01-21 15:58:04.951703302 +0100
14@@ -3535,34 +3535,6 @@
15 AC_CHECK_LIB(socket, socket)
16 esac
17
18-AC_MSG_CHECKING(for ARM SIMD support in compiler)
19-AC_TRY_COMPILE([],
20- [asm("uqadd8 r1, r1, r2");],
21- result="yes", result="no")
22-AC_MSG_RESULT("$result")
23-if test "$result" = "yes"; then
24- AC_DEFINE(HAVE_ARM_SIMD)
25- HAVE_ARM_SIMD=1
26-fi
27-AC_SUBST(HAVE_ARM_SIMD)
28-
29-AC_MSG_CHECKING(for ARM NEON support in compiler)
30-_SAVE_CFLAGS="$CFLAGS"
31-if test "$GNU_CC"; then
32- # gcc needs -mfpu=neon to recognize NEON instructions
33- CFLAGS="$CFLAGS -mfpu=neon -mfloat-abi=softfp"
34-fi
35-AC_TRY_COMPILE([],
36- [asm("vadd.i8 d0, d0, d0");],
37- result="yes", result="no")
38-AC_MSG_RESULT("$result")
39-if test "$result" = "yes"; then
40- AC_DEFINE(HAVE_ARM_NEON)
41- HAVE_ARM_NEON=1
42-fi
43-CFLAGS="$_SAVE_CFLAGS"
44-AC_SUBST(HAVE_ARM_NEON)
45-
46 dnl ========================================================
47 dnl = pthread support
48 dnl = Start by checking whether the system support pthreads
49@@ -4614,13 +4586,11 @@
50 BUILD_STATIC_LIBS=
51 ENABLE_TESTS=1
52
53-MOZ_THUMB2=
54 USE_ARM_KUSER=
55
56 case "${target}" in
57 arm-android-eabi)
58 USE_ARM_KUSER=1
59- MOZ_THUMB2=1
60 ;;
61 esac
62
63@@ -4666,80 +4636,204 @@
64 dnl ========================================================
65 MOZ_ARG_HEADER(Individual module options)
66
67-dnl Setup default CPU arch for arm target
68-case "$target_cpu" in
69- arm*)
70- MOZ_ARM_ARCH=armv7
71- ;;
72-esac
73 dnl ========================================================
74-dnl = Enable building the Thumb2 instruction set
75+dnl = ARM toolchain tweaks
76 dnl ========================================================
77-MOZ_ARG_ENABLE_BOOL(thumb2,
78- [ --enable-thumb2 Enable Thumb2 instruction set (implies ARMv7)],
79- MOZ_THUMB2=1,
80- MOZ_THUMB2=)
81-if test -n "$MOZ_THUMB2"; then
82- MOZ_ARM_ARCH=armv7
83+
84+dnl Defaults
85+case "${target}" in
86+arm-android-eabi)
87+ MOZ_THUMB=yes
88+ MOZ_ARCH=armv7-a
89+ MOZ_FPU=vfp
90+ MOZ_FLOAT_ABI=softfp
91+ ;;
92+arm*-*)
93+ if test -n "$MOZ_PLATFORM_MAEMO"; then
94+ MOZ_THUMB=no
95+ MOZ_ARCH=armv7-a
96+ MOZ_FLOAT_ABI=softfp
97+ fi
98+ if test "$MOZ_PLATFORM_MAEMO" = 6; then
99+ MOZ_THUMB=yes
100+ fi
101+ ;;
102+esac
103+
104+dnl Kept for compatibility with some buildbot mozconfig
105+MOZ_ARG_DISABLE_BOOL(thumb2, [], MOZ_THUMB=no, MOZ_THUMB=yes)
106+
107+MOZ_ARG_WITH_STRING(thumb,
108+[ --with-thumb[[=yes|no|toolchain]]]
109+[ Use Thumb instruction set (-mthumb)],
110+ if test -z "$GNU_CC"; then
111+ AC_MSG_ERROR([--with-thumb is not supported on non-GNU toolchains])
112+ fi
113+ MOZ_THUMB=$withval)
114+
115+MOZ_ARG_WITH_STRING(thumb-interwork,
116+[ --with-thumb-interwork[[=yes|no|toolchain]]
117+ Use Thumb/ARM instuctions interwork (-mthumb-interwork)],
118+ if test -z "$GNU_CC"; then
119+ AC_MSG_ERROR([--with-thumb-interwork is not supported on non-GNU toolchains])
120+ fi
121+ MOZ_THUMB_INTERWORK=$withval)
122+
123+MOZ_ARG_WITH_STRING(arch,
124+[ --with-arch=[[type|toolchain]]
125+ Use specific CPU features (-march=type)],
126+ if test -z "$GNU_CC"; then
127+ AC_MSG_ERROR([--with-arch is not supported on non-GNU toolchains])
128+ fi
129+ MOZ_ARCH=$withval)
130+
131+MOZ_ARG_WITH_STRING(fpu,
132+[ --with-fpu=[[type|toolchain]]
133+ Use specific FPU type (-mfpu=type)],
134+ if test -z "$GNU_CC"; then
135+ AC_MSG_ERROR([--with-fpu is not supported on non-GNU toolchains])
136+ fi
137+ MOZ_FPU=$withval)
138+
139+MOZ_ARG_WITH_STRING(float-abi,
140+[ --with-float-abi=[[type|toolchain]]
141+ Use specific arm float ABI (-mfloat-abi=type)],
142+ if test -z "$GNU_CC"; then
143+ AC_MSG_ERROR([--with-float-abi is not supported on non-GNU toolchains])
144+ fi
145+ MOZ_FLOAT_ABI=$withval)
146+
147+MOZ_ARG_WITH_STRING(soft-float,
148+[ --with-soft-float[[=yes|no|toolchain]]
149+ Use soft float library (-msoft-float)],
150+ if test -z "$GNU_CC"; then
151+ AC_MSG_ERROR([--with-soft-float is not supported on non-GNU toolchains])
152+ fi
153+ MOZ_SOFT_FLOAT=$withval)
154+
155+case "$MOZ_ARCH" in
156+toolchain|"")
157+ arch_flag=""
158+ ;;
159+*)
160+ arch_flag="-march=$MOZ_ARCH"
161+ ;;
162+esac
163+
164+case "$MOZ_THUMB" in
165+yes)
166+ MOZ_THUMB2=1
167+ thumb_flag="-mthumb"
168+ ;;
169+no)
170+ MOZ_THUMB2=
171+ thumb_flag="-marm"
172+ ;;
173+*)
174+ _SAVE_CFLAGS="$CFLAGS"
175+ CFLAGS="$arch_flag"
176+ AC_TRY_COMPILE([],[return sizeof(__thumb2__);],
177+ MOZ_THUMB2=1,
178+ MOZ_THUMB2=)
179+ CFLAGS="$_SAVE_CFLAGS"
180+ thumb_flag=""
181+ ;;
182+esac
183+
184+if test "$MOZ_THUMB2" = 1; then
185+ AC_DEFINE(MOZ_THUMB2)
186 fi
187
188-dnl ========================================================
189-dnl = Enable building for ARM specific CPU features
190-dnl ========================================================
191-MOZ_ARG_WITH_STRING(cpu-arch,
192-[ --with-cpu-arch=arch Use specific arm architecture CPU features, default armv7],
193- MOZ_ARM_ARCH=$withval)
194+case "$MOZ_THUMB_INTERWORK" in
195+yes)
196+ thumb_interwork_flag="-mthumb-interwork"
197+ ;;
198+no)
199+ thumb_interwork_flag="-mno-thumb-interwork"
200+ ;;
201+*) # toolchain
202+ thumb_interwork_flag=""
203+ ;;
204+esac
205
206-if test -n "$MOZ_THUMB2"; then
207- case "$target_cpu" in
208- arm*)
209- if test "$MOZ_ARM_ARCH" != "armv7"; then
210- AC_MSG_ERROR([--enable-thumb2 is not compatible with cpu-arch=$MOZ_ARM_ARCH])
211- fi
212- if test "$GNU_CC"; then
213- AC_DEFINE(MOZ_THUMB2)
214- AC_DEFINE(MOZ_ARM_ARCH)
215- CFLAGS="$CFLAGS -march=armv7-a -mthumb -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
216- CXXFLAGS="$CXXFLAGS -march=armv7-a -mthumb -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
217- ASFLAGS="$ASFLAGS -march=armv7-a -mthumb -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
218- else
219- AC_MSG_ERROR([--enable-thumb2 is not supported for non-GNU toolchains])
220- fi
221+case "$MOZ_FPU" in
222+toolchain|"")
223+ fpu_flag=""
224 ;;
225- *)
226- AC_MSG_ERROR([--enable-thumb2 is not supported for non-ARM CPU architectures])
227+*)
228+ fpu_flag="-mfpu=$MOZ_FPU"
229 ;;
230- esac
231-elif test "$MOZ_ARM_ARCH" = "armv7"; then
232- case "$target_cpu" in
233- arm*)
234- if test "$GNU_CC"; then
235- AC_DEFINE(MOZ_ARM_ARCH)
236- CFLAGS="$CFLAGS -march=armv7-a -marm -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
237- CXXFLAGS="$CXXFLAGS -march=armv7-a -marm -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
238- ASFLAGS="$ASFLAGS -march=armv7-a -marm -mfloat-abi=softfp $MOZ_ARM_VFP_FLAGS"
239- else
240- AC_MSG_ERROR([--with-cpu-arch=armv7 is not supported for non-GNU toolchains])
241- fi
242+esac
243+
244+case "$MOZ_FLOAT_ABI" in
245+toolchain|"")
246+ float_abi_flag=""
247 ;;
248- *)
249- AC_MSG_ERROR([--with-cpu-arch=armv7 is not supported for non-ARM CPU architectures])
250+*)
251+ float_abi_flag="-mfloat-abi=$MOZ_FLOAT_ABI"
252 ;;
253- esac
254-else
255- case "$target_cpu" in
256- arm*)
257- if test "$GNU_CC"; then
258- CFLAGS="$CFLAGS -march=armv5te -mthumb-interwork -msoft-float"
259- CXXFLAGS="$CXXFLAGS -march=armv5te -mthumb-interwork -msoft-float"
260- ASFLAGS="$ASFLAGS -march=armv5te -mthumb-interwork -msoft-float"
261- fi
262- ;;
263- esac
264+esac
265+
266+case "$MOZ_SOFT_FLOAT" in
267+yes)
268+ soft_float_flag="-msoft-float"
269+ ;;
270+no)
271+ soft_float_flag="-mno-soft-float"
272+ ;;
273+*) # toolchain
274+ soft_float_flag=""
275+ ;;
276+esac
277+
278+dnl Use echo to avoid accumulating space characters
279+all_flags=`echo $arch_flag $thumb_flag $thumb_interwork_flag $fpu_flag $float_abi_flag $soft_float_flag`
280+if test -n "$all_flags"; then
281+ _SAVE_CFLAGS="$CFLAGS"
282+ CFLAGS="$all_flags"
283+ AC_MSG_CHECKING(whether the chosen combination of compiler flags ($all_flags) works)
284+ AC_TRY_COMPILE([],[return 0;],
285+ AC_MSG_RESULT([yes]),
286+ AC_MSG_ERROR([no]))
287+
288+ CFLAGS="$_SAVE_CFLAGS $all_flags"
289+ CXXFLAGS="$CXXFLAGS $all_flags"
290+ ASFLAGS="$ASFLAGS $all_flags"
291+ if test -n "$thumb_flag"; then
292+ LDFLAGS="$LDFLAGS $thumb_flag"
293+ fi
294 fi
295
296 AC_SUBST(MOZ_THUMB2)
297-AC_SUBST(MOZ_ARM_ARCH)
298+
299+if test "$CPU_ARCH" = "arm"; then
300+ AC_MSG_CHECKING(for ARM SIMD support in compiler)
301+ # We try to link so that this also fails when
302+ # building with LTO.
303+ AC_TRY_LINK([],
304+ [asm("uqadd8 r1, r1, r2");],
305+ result="yes", result="no")
306+ AC_MSG_RESULT("$result")
307+ if test "$result" = "yes"; then
308+ AC_DEFINE(HAVE_ARM_SIMD)
309+ HAVE_ARM_SIMD=1
310+ fi
311+
312+ AC_MSG_CHECKING(for ARM NEON support in compiler)
313+ # We try to link so that this also fails when
314+ # building with LTO.
315+ AC_TRY_LINK([],
316+ [asm(".fpu neon\n vadd.i8 d0, d0, d0");],
317+ result="yes", result="no")
318+ AC_MSG_RESULT("$result")
319+ if test "$result" = "yes"; then
320+ AC_DEFINE(HAVE_ARM_NEON)
321+ HAVE_ARM_NEON=1
322+ fi
323+fi # CPU_ARCH = arm
324+
325+AC_SUBST(HAVE_ARM_SIMD)
326+AC_SUBST(HAVE_ARM_NEON)
327
328 dnl ========================================================
329 dnl =
330@@ -6147,12 +6241,6 @@
331 if test "$OS_ARCH" = "OS2"; then
332 ac_configure_args="$ac_configure_args CFLAGS=-Zomf AR=emxomfar"
333 fi
334- if test -n "$MOZ_THUMB2"; then
335- ac_configure_args="$ac_configure_args --enable-thumb2"
336- fi
337- if test -n "$MOZ_ARM_ARCH"; then
338- ac_configure_args="$ac_configure_args --with-cpu-arch=$MOZ_ARM_ARCH"
339- fi
340
341 # Use a separate cache file for libffi, since it does things differently
342 # from our configure.