ASC-4041: Skip two spidermonkey regression tests due to stack overflow when compiling...
[tamarin-stm.git] / configure.py
blob15265dcafd433725232eb8b2b7620142d586cb70
1 #!/usr/bin/env python
2 # -*- Mode: Python; indent-tabs-mode: nil -*-
3 # vi: set ts=4 sw=4 expandtab:
4 # ***** BEGIN LICENSE BLOCK *****
5 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 # The contents of this file are subject to the Mozilla Public License Version
8 # 1.1 (the "License"); you may not use this file except in compliance with
9 # the License. You may obtain a copy of the License at
10 # http://www.mozilla.org/MPL/
12 # Software distributed under the License is distributed on an "AS IS" basis,
13 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 # for the specific language governing rights and limitations under the
15 # License.
17 # The Original Code is [Open Source Virtual Machine].
19 # The Initial Developer of the Original Code is
20 # Adobe System Incorporated.
21 # Portions created by the Initial Developer are Copyright (C) 2005-2006
22 # the Initial Developer. All Rights Reserved.
24 # Contributor(s):
26 # Alternatively, the contents of this file may be used under the terms of
27 # either the GNU General Public License Version 2 or later (the "GPL"), or
28 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 # in which case the provisions of the GPL or the LGPL are applicable instead
30 # of those above. If you wish to allow use of your version of this file only
31 # under the terms of either the GPL or the LGPL, and not to allow others to
32 # use your version of this file under the terms of the MPL, indicate your
33 # decision by deleting the provisions above and replace them with the notice
34 # and other provisions required by the GPL or the LGPL. If you do not delete
35 # the provisions above, a recipient may use your version of this file under
36 # the terms of any one of the MPL, the GPL or the LGPL.
38 # ***** END LICENSE BLOCK *****
41 # This script runs just like a traditional configure script, to do configuration
42 # testing and makefile generation.
44 import os
45 import os.path
46 import sys
47 import build.process
48 import re
49 import subprocess
51 thisdir = os.path.dirname(os.path.abspath(__file__))
53 # Look for additional modules in our build/ directory.
54 sys.path.append(thisdir)
56 from build.configuration import *
57 import build.getopt
58 import build.avmfeatures
61 def _setSDKParams(sdk_version,os_ver):
63 # On 10.5/6 systems, and only if "--mac-sdk=104u" is passed in, compile for the 10.4u SDK and override CC/CXX (set in configuration.py) to use gcc/gxx 4.0.x
64 if sdk_version == '104u':
65 os_ver,sdk_number = '10.4','10.4u'
66 config._acvars['CXX'] = 'g++-4.0'
67 config._acvars['CC'] = 'gcc-4.0'
68 elif sdk_version == '105':
69 os_ver,sdk_number = '10.5','10.5'
70 elif sdk_version == '106':
71 os_ver,sdk_number = '10.6','10.6'
72 # For future expansion
73 #elif sdk_version == '107':
74 #os_ver,sdk_number = '10.7','10.7'
75 else:
76 print'Unknown SDK version -> %s. Expected values are 104u, 105 or 106.' % sdk_version
77 sys.exit(2)
79 if not os.path.exists("/Developer/SDKs/MacOSX%s.sdk" % sdk_number):
80 print'Could not find /Developer/SDKs/MacOSX%s.sdk' % sdk_number
81 sys.exit(2)
82 else:
83 return os_ver,sdk_number
85 o = build.getopt.Options()
87 config = Configuration(thisdir, options = o,
88 sourcefile = 'core/avmplus.h')
90 buildTamarin = o.getBoolArg('tamarin', True)
91 if buildTamarin:
92 config.subst("ENABLE_TAMARIN", 1)
94 buildShell = o.getBoolArg("shell", False)
95 if (buildShell):
96 config.subst("ENABLE_SHELL", 1)
99 APP_CPPFLAGS = "-DAVMSHELL_BUILD "
100 APP_CXXFLAGS = ""
101 APP_CFLAGS = ""
102 OPT_CXXFLAGS = "-O3 "
103 OPT_CPPFLAGS = ""
104 DEBUG_CPPFLAGS = "-DDEBUG -D_DEBUG "
105 DEBUG_CXXFLAGS = ""
106 DEBUG_CFLAGS = ""
107 DEBUG_LDFLAGS = ""
108 OS_LIBS = []
109 OS_LDFLAGS = ""
110 MMGC_CPPFLAGS = "-DAVMSHELL_BUILD "
111 AVMSHELL_CPPFLAGS = ""
112 AVMSHELL_LDFLAGS = ""
113 MMGC_DEFINES = {'SOFT_ASSERTS': None}
114 NSPR_INCLUDES = ""
115 NSPR_LDOPTS = ""
117 # See build/avmfeatures.py for the code that processes switches for
118 # standard feature names.
119 APP_CPPFLAGS += build.avmfeatures.featureSettings(o)
121 if not o.getBoolArg("methodenv-impl32", True):
122 APP_CPPFLAGS += "-DVMCFG_METHODENV_IMPL32=0 "
124 memoryProfiler = o.getBoolArg("memory-profiler", False)
125 if memoryProfiler:
126 APP_CPPFLAGS += "-DMMGC_MEMORY_PROFILER "
128 MMGC_INTERIOR_PTRS = o.getBoolArg('mmgc-interior-pointers', False)
129 if MMGC_INTERIOR_PTRS:
130 MMGC_DEFINES['MMGC_INTERIOR_PTRS'] = None
132 MMGC_DYNAMIC = o.getBoolArg('mmgc-shared', False)
133 if MMGC_DYNAMIC:
134 MMGC_DEFINES['MMGC_DLL'] = None
135 MMGC_CPPFLAGS += "-DMMGC_IMPL "
137 arm_fpu = o.getBoolArg("arm-fpu",False)
138 arm_neon = o.getBoolArg("arm-neon",False)
139 arm_arch = o.arm_arch
141 the_os, cpu = config.getTarget()
143 # For -Wreorder, see https://bugzilla.mozilla.org/show_bug.cgi?id=475750
144 if config.getCompiler() == 'GCC':
145 if 'CXX' in os.environ:
146 rawver = build.process.run_for_output(['$CXX', '--version'])
147 else:
148 rawver = build.process.run_for_output(['gcc', '--version'])
149 vre = re.compile(".* ([3-9]\.[0-9]+\.[0-9]+)[ \n]")
150 ver = vre.match(rawver).group(1)
151 ver_arr = ver.split('.')
152 GCC_MAJOR_VERSION = int(ver_arr[0])
153 GCC_MINOR_VERSION = int(ver_arr[1])
154 # can't enable -Werror for gcc prior to 4.3 due to unavoidable "clobbered" warnings in Interpreter.cpp
155 # warnings have been updated to try to include all those enabled by current Flash/AIR builds -- disable with caution, or risk integration pain
156 APP_CXXFLAGS = "-Wall -Wcast-align -Wdisabled-optimization -Wextra -Wformat=2 -Winit-self -Winvalid-pch -Wno-invalid-offsetof -Wno-switch -Wparentheses -Wpointer-arith -Wreorder -Wsign-compare -Wunused-parameter -Wwrite-strings -Wno-ctor-dtor-privacy -Woverloaded-virtual -Wsign-promo -Wno-char-subscripts -fmessage-length=0 -fno-exceptions -fno-rtti -fno-check-new -fstrict-aliasing -fsigned-char "
157 if GCC_MAJOR_VERSION >= 4:
158 APP_CXXFLAGS += "-Wstrict-null-sentinel "
159 if (GCC_MAJOR_VERSION == 4 and GCC_MINOR_VERSION <= 2) or cpu == 'mips': # 4.0 - 4.2
160 APP_CXXFLAGS += "-Wstrict-aliasing=0 "
161 else: # gcc 4.3 or later
162 APP_CXXFLAGS += "-Werror -Wempty-body -Wno-logical-op -Wmissing-field-initializers -Wstrict-aliasing=3 -Wno-array-bounds -Wno-clobbered -Wstrict-overflow=0 -funit-at-a-time "
163 if cpu == 'sh4':
164 APP_CXXFLAGS += "-mieee "
166 if arm_fpu:
167 ARM_FPU_FLAGS = "-mfloat-abi=softfp -mfpu=vfp -march=%s -Wno-cast-align " % arm_arch # compile to use hardware fpu
168 OPT_CXXFLAGS += ARM_FPU_FLAGS
169 DEBUG_CXXFLAGS += ARM_FPU_FLAGS
170 if arm_neon:
171 ARM_NEON_FLAGS = "-mfloat-abi=softfp -mfpu=neon -march=%s -Wno-cast-align " % arm_arch # compile to use neon vfp
172 OPT_CXXFLAGS += ARM_NEON_FLAGS
173 DEBUG_CXXFLAGS += ARM_NEON_FLAGS
174 #if arm_arch:
175 #OPT_CXXFLAGS += "-march=%s " % arm_arch
176 #DEBUG_CXXFLAGS += "-march=%s " % arm_arch
178 if config.getDebug():
179 APP_CXXFLAGS += ""
180 else:
181 APP_CXXFLAGS += "-Wuninitialized "
182 DEBUG_CXXFLAGS += "-g "
183 elif config.getCompiler() == 'VS':
184 if cpu == "arm":
185 APP_CXXFLAGS = "-W4 -WX -wd4291 -wd4201 -wd4189 -wd4740 -wd4127 -fp:fast -GF -GS- -Zc:wchar_t- "
186 OS_LDFLAGS += "-MAP "
187 if config.getDebug():
188 DEBUG_CXXFLAGS = "-Od "
189 DEBUG_CFLAGS = "-Od "
190 APP_CXXFLAGS += "-GR- -fp:fast -GS- -Zc:wchar_t- -Zc:forScope "
191 else:
192 OPT_CXXFLAGS = "-O2 -GR- "
193 if arm_arch:
194 OPT_CXXFLAGS += "-QR%s " % arm_arch
195 if arm_fpu:
196 OPT_CXXFLAGS += "-QRfpe- " # compile to use hardware fpu
197 else:
198 APP_CXXFLAGS = "-W4 -WX -wd4291 -GF -GS- -Zc:wchar_t- "
199 APP_CFLAGS = "-W4 -WX -wd4291 -GF -GS- -Zc:wchar_t- "
200 if cpu == 'x86_64':
201 pass # 64 bit VC does NaN comparisons incorrectly with fp:fast
202 else:
203 APP_CXXFLAGS += "-fp:fast "
204 APP_CFLAGS += "-fp:fast "
205 OS_LDFLAGS += "-MAP "
206 if config.getDebug():
207 DEBUG_CXXFLAGS = "-Od "
208 DEBUG_CFLAGS = "-Od "
209 else:
210 OPT_CXXFLAGS = "-O2 -Ob1 -GR- "
211 OPT_CFLAGS = "-O2 -Ob1 -GR- "
212 if memoryProfiler:
213 OPT_CXXFLAGS += "-Oy- -Zi "
214 DEBUG_CXXFLAGS += "-Zi "
215 DEBUG_CFLAGS += "-Zi "
216 DEBUG_LDFLAGS += "-DEBUG "
217 elif config.getCompiler() == 'SunStudio':
218 APP_CXXFLAGS = "-template=no%extdef -erroff"
219 OPT_CXXFLAGS = "-xO2 "
220 DEBUG_CXXFLAGS += "-g "
221 else:
222 raise Exception('Unrecognized compiler: ' + config.getCompiler())
224 zlib_include_dir = o.getStringArg('zlib-include-dir')
225 if zlib_include_dir is not None:
226 AVMSHELL_CPPFLAGS += "-I%s " % zlib_include_dir
228 zlib_lib = o.getStringArg('zlib-lib')
229 if zlib_lib is not None:
230 AVMSHELL_LDFLAGS = zlib_lib
231 else:
232 AVMSHELL_LDFLAGS = '$(call EXPAND_LIBNAME,zlib)'
234 sys_root_dir = o.getStringArg('sys-root-dir')
235 if sys_root_dir is not None:
236 OS_LDFLAGS += " --sysroot=%s " % sys_root_dir
237 OPT_CXXFLAGS += " --sysroot=%s " % sys_root_dir
239 if the_os == "darwin":
240 # Get machine's OS version number and trim off anything after '10.x'
241 p = subprocess.Popen('sw_vers -productVersion', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
242 os_ver = p.stdout.read()
243 parts = os_ver.split('.')
244 os_ver = parts[0] + '.' + parts[1]
246 AVMSHELL_LDFLAGS += " -exported_symbols_list " + thisdir + "/platform/mac/avmshell/exports.exp"
247 MMGC_DEFINES.update({'TARGET_API_MAC_CARBON': 1,
248 'DARWIN': 1,
249 '_MAC': None,
250 'AVMPLUS_MAC': None,
251 'TARGET_RT_MAC_MACHO': 1})
252 APP_CXXFLAGS += "-fpascal-strings -faltivec -fasm-blocks "
254 # If an sdk is selected align OS and gcc/g++ versions to it
255 if o.mac_sdk_version is not None:
256 os_ver,sdk_number = _setSDKParams(o.mac_sdk_version, os_ver)
257 APP_CXXFLAGS += "-mmacosx-version-min=%s -isysroot /Developer/SDKs/MACOSX%s.sdk " % (os_ver,sdk_number)
258 else:
259 APP_CXXFLAGS += "-mmacosx-version-min=%s " % os_ver
261 config.subst("MACOSX_DEPLOYMENT_TARGET",os_ver)
263 if cpu == 'ppc64':
264 APP_CXXFLAGS += "-arch ppc64 "
265 APP_CFLAGS += "-arch ppc64 "
266 OS_LDFLAGS += "-arch ppc64 "
267 elif cpu == 'x86_64':
268 APP_CXXFLAGS += "-arch x86_64 "
269 APP_CFLAGS += "-arch x86_64 "
270 OS_LDFLAGS += "-arch x86_64 "
272 elif the_os == "windows" or the_os == "cygwin":
273 MMGC_DEFINES.update({'WIN32': None,
274 '_CRT_SECURE_NO_DEPRECATE': None})
275 OS_LDFLAGS += "-MAP "
276 if cpu == "arm":
277 APP_CPPFLAGS += "-DARM -D_ARM_ -DUNICODE -DUNDER_CE=1 -DMMGC_ARM "
278 if arm_fpu:
279 APP_CPPFLAGS += "-DARMV6 -QRarch6 "
280 else:
281 APP_CPPFLAGS += "-DARMV5 -QRarch5t "
282 OS_LIBS.append('mmtimer corelibc coredll')
283 else:
284 APP_CPPFLAGS += "-DWIN32_LEAN_AND_MEAN -D_CONSOLE "
285 OS_LIBS.append('winmm')
286 OS_LIBS.append('shlwapi')
287 OS_LIBS.append('AdvAPI32')
288 elif the_os == "linux":
289 MMGC_DEFINES.update({'UNIX': None,
290 'AVMPLUS_UNIX': None})
291 OS_LIBS.append('pthread')
292 # if cpu == "x86_64":
293 # # workaround https://bugzilla.mozilla.org/show_bug.cgi?id=467776
294 # OPT_CXXFLAGS += '-fno-schedule-insns2 '
295 if config.getDebug():
296 OS_LIBS.append("dl")
297 elif the_os == "sunos":
298 if config.getCompiler() != 'GCC':
299 APP_CXXFLAGS = "-template=no%extdef -erroff"
300 OPT_CXXFLAGS = "-xO2 "
301 DEBUG_CXXFLAGS = "-g "
302 MMGC_DEFINES.update({'UNIX': None,
303 'AVMPLUS_UNIX': None,
304 'SOLARIS': None})
305 OS_LIBS.append('pthread')
306 APP_CPPFLAGS += '-DAVMPLUS_CDECL '
307 if config.getDebug():
308 OS_LIBS.append("dl")
309 else:
310 raise Exception("Unsupported OS")
312 if cpu == "i686":
313 if config.getCompiler() == 'GCC' and the_os == 'darwin':
314 #only mactel always has sse2
315 APP_CPPFLAGS += "-msse2 "
316 elif cpu == "powerpc":
317 # we detect this in core/avmbuild.h and MMgc/*build.h
318 None
319 elif cpu == "ppc64":
320 # we detect this in core/avmbuild.h and MMgc/*build.h
321 None
322 elif cpu == "sparc":
323 APP_CPPFLAGS += "-DAVMPLUS_SPARC "
324 elif cpu == "x86_64":
325 # we detect this in core/avmbuild.h and MMgc/*build.h
326 None
327 elif cpu == "arm":
328 # we detect this in core/avmbuild.h and MMgc/*build.h
329 None
330 elif cpu == "mips":
331 # we detect this in core/avmbuild.h and MMgc/*build.h
332 None
333 elif cpu == "sh4":
334 # work around for a problem with tas.b instruction on some sh4 boards
335 APP_CPPFLAGS += "-DUSE_PTHREAD_MUTEX "
336 else:
337 raise Exception("Unsupported CPU")
339 if o.getBoolArg('perfm'):
340 APP_CPPFLAGS += "-DPERFM "
342 if o.help:
343 sys.stdout.write(o.getHelp())
344 sys.exit(1)
347 # We do two things with MMGC_DEFINES: we append it to APP_CPPFLAGS and we also write MMgc-config.h
348 APP_CPPFLAGS += ''.join(val is None and ('-D%s ' % var) or ('-D%s=%s ' % (var, val))
349 for (var, val) in MMGC_DEFINES.iteritems())
351 definePattern = \
352 """#ifndef %(var)s
353 #define %(var)s %(val)s
354 #endif
357 outpath = "%s/MMgc-config.h" % config.getObjDir()
358 contents = ''.join(definePattern % {'var': var,
359 'val': val is not None and val or ''}
360 for (var, val) in MMGC_DEFINES.iteritems())
361 writeFileIfChanged(outpath, contents)
363 config.subst("APP_CPPFLAGS", APP_CPPFLAGS)
364 config.subst("APP_CXXFLAGS", APP_CXXFLAGS)
365 config.subst("OPT_CPPFLAGS", OPT_CPPFLAGS)
366 config.subst("OPT_CXXFLAGS", OPT_CXXFLAGS)
367 config.subst("DEBUG_CPPFLAGS", DEBUG_CPPFLAGS)
368 config.subst("DEBUG_CXXFLAGS", DEBUG_CXXFLAGS)
369 config.subst("DEBUG_LDFLAGS", DEBUG_LDFLAGS)
370 config.subst("OS_LIBS", " ".join(OS_LIBS))
371 config.subst("OS_LDFLAGS", OS_LDFLAGS)
372 config.subst("MMGC_CPPFLAGS", MMGC_CPPFLAGS)
373 config.subst("AVMSHELL_CPPFLAGS", AVMSHELL_CPPFLAGS)
374 config.subst("AVMSHELL_LDFLAGS", AVMSHELL_LDFLAGS)
375 config.subst("MMGC_DYNAMIC", MMGC_DYNAMIC and 1 or '')
376 config.generate("Makefile")
378 o.finish()