Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: tools/clang/scripts/update.py

Issue 1412893004: Rolling forward clang, hiding some warnings (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Added some untracked files which have been added by Chromium Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/clang/scripts/package.py ('k') | tools/clang/scripts/update.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Windows can't run .sh files, so this is a Python implementation of 6 """Windows can't run .sh files, so this is a Python implementation of
7 update.sh. This script should replace update.sh on all platforms eventually.""" 7 update.sh. This script should replace update.sh on all platforms eventually."""
8 8
9 import argparse 9 import argparse
10 import contextlib 10 import contextlib
11 import cStringIO 11 import cStringIO
12 import glob
12 import os 13 import os
14 import pipes
13 import re 15 import re
14 import shutil 16 import shutil
15 import subprocess 17 import subprocess
16 import stat 18 import stat
17 import sys 19 import sys
18 import tarfile 20 import tarfile
19 import time 21 import time
20 import urllib2 22 import urllib2
21 import zipfile 23 import zipfile
22 24
23 # Do NOT CHANGE this if you don't know what you're doing -- see 25 # Do NOT CHANGE this if you don't know what you're doing -- see
24 # https://code.google.com/p/chromium/wiki/UpdatingClang 26 # https://code.google.com/p/chromium/wiki/UpdatingClang
25 # Reverting problematic clang rolls is safe, though. 27 # Reverting problematic clang rolls is safe, though.
26 # Note: this revision is only used for Windows. Other platforms use update.sh. 28 # Note: this revision is only used for Windows. Other platforms use update.sh.
27 # TODO(thakis): Use the same revision on Windows and non-Windows. 29 # TODO(thakis): Use the same revision on Windows and non-Windows.
28 # TODO(thakis): Remove update.sh, use update.py everywhere. 30 # TODO(thakis): Remove update.sh, use update.py everywhere.
29 LLVM_WIN_REVISION = '238562' 31 LLVM_WIN_REVISION = '247874'
30 32
31 use_head_revision = 'LLVM_FORCE_HEAD_REVISION' in os.environ 33 use_head_revision = 'LLVM_FORCE_HEAD_REVISION' in os.environ
32 if use_head_revision: 34 if use_head_revision:
33 LLVM_WIN_REVISION = 'HEAD' 35 LLVM_WIN_REVISION = 'HEAD'
34 36
35 # This is incremented when pushing a new build of Clang at the same revision. 37 # This is incremented when pushing a new build of Clang at the same revision.
36 CLANG_SUB_REVISION=1 38 CLANG_SUB_REVISION=1
37 39
38 PACKAGE_VERSION = "%s-%s" % (LLVM_WIN_REVISION, CLANG_SUB_REVISION) 40 PACKAGE_VERSION = "%s-%s" % (LLVM_WIN_REVISION, CLANG_SUB_REVISION)
39 41
40 # Path constants. (All of these should be absolute paths.) 42 # Path constants. (All of these should be absolute paths.)
41 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) 43 THIS_DIR = os.path.abspath(os.path.dirname(__file__))
42 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..')) 44 CHROMIUM_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..', '..'))
43 THIRD_PARTY_DIR = os.path.join(CHROMIUM_DIR, 'third_party') 45 THIRD_PARTY_DIR = os.path.join(CHROMIUM_DIR, 'third_party')
44 LLVM_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm') 46 LLVM_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm')
45 LLVM_BOOTSTRAP_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-bootstrap') 47 LLVM_BOOTSTRAP_DIR = os.path.join(THIRD_PARTY_DIR, 'llvm-bootstrap')
46 LLVM_BOOTSTRAP_INSTALL_DIR = os.path.join(THIRD_PARTY_DIR, 48 LLVM_BOOTSTRAP_INSTALL_DIR = os.path.join(THIRD_PARTY_DIR,
47 'llvm-bootstrap-install') 49 'llvm-bootstrap-install')
48 CHROME_TOOLS_SHIM_DIR = os.path.join(LLVM_DIR, 'tools', 'chrometools') 50 CHROME_TOOLS_SHIM_DIR = os.path.join(LLVM_DIR, 'tools', 'chrometools')
49 LLVM_BUILD_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm-build', 51 LLVM_BUILD_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'llvm-build',
50 'Release+Asserts') 52 'Release+Asserts')
51 COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, '32bit-compiler-rt') 53 COMPILER_RT_BUILD_DIR = os.path.join(LLVM_BUILD_DIR, '32bit-compiler-rt')
52 CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang') 54 CLANG_DIR = os.path.join(LLVM_DIR, 'tools', 'clang')
53 LLD_DIR = os.path.join(LLVM_DIR, 'tools', 'lld') 55 LLD_DIR = os.path.join(LLVM_DIR, 'tools', 'lld')
54 COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt') 56 COMPILER_RT_DIR = os.path.join(LLVM_DIR, 'projects', 'compiler-rt')
57 LIBCXX_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxx')
58 LIBCXXABI_DIR = os.path.join(LLVM_DIR, 'projects', 'libcxxabi')
55 LLVM_BUILD_TOOLS_DIR = os.path.abspath( 59 LLVM_BUILD_TOOLS_DIR = os.path.abspath(
56 os.path.join(LLVM_DIR, '..', 'llvm-build-tools')) 60 os.path.join(LLVM_DIR, '..', 'llvm-build-tools'))
57 STAMP_FILE = os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision') 61 STAMP_FILE = os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision')
58 BINUTILS_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils') 62 BINUTILS_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils')
59 VERSION = '3.7.0' 63 VERSION = '3.8.0'
60 64
61 # URL for pre-built binaries. 65 # URL for pre-built binaries.
62 CDS_URL = 'https://commondatastorage.googleapis.com/chromium-browser-clang' 66 CDS_URL = 'https://commondatastorage.googleapis.com/chromium-browser-clang'
63 67
64 LLVM_REPO_URL='https://llvm.org/svn/llvm-project' 68 LLVM_REPO_URL='https://llvm.org/svn/llvm-project'
65 if 'LLVM_REPO_URL' in os.environ: 69 if 'LLVM_REPO_URL' in os.environ:
66 LLVM_REPO_URL = os.environ['LLVM_REPO_URL'] 70 LLVM_REPO_URL = os.environ['LLVM_REPO_URL']
67 71
68 72
69 def DownloadUrl(url, output_file): 73 def DownloadUrl(url, output_file):
(...skipping 16 matching lines...) Expand all
86 sys.stdout.write('.' * (num_dots - dots_printed)) 90 sys.stdout.write('.' * (num_dots - dots_printed))
87 sys.stdout.flush() 91 sys.stdout.flush()
88 dots_printed = num_dots 92 dots_printed = num_dots
89 print ' Done.' 93 print ' Done.'
90 94
91 95
92 def ReadStampFile(): 96 def ReadStampFile():
93 """Return the contents of the stamp file, or '' if it doesn't exist.""" 97 """Return the contents of the stamp file, or '' if it doesn't exist."""
94 try: 98 try:
95 with open(STAMP_FILE, 'r') as f: 99 with open(STAMP_FILE, 'r') as f:
96 return f.read(); 100 return f.read()
97 except IOError: 101 except IOError:
98 return '' 102 return ''
99 103
100 104
101 def WriteStampFile(s): 105 def WriteStampFile(s):
102 """Write s to the stamp file.""" 106 """Write s to the stamp file."""
103 if not os.path.exists(LLVM_BUILD_DIR): 107 if not os.path.exists(os.path.dirname(STAMP_FILE)):
104 os.makedirs(LLVM_BUILD_DIR) 108 os.makedirs(os.path.dirname(STAMP_FILE))
105 with open(STAMP_FILE, 'w') as f: 109 with open(STAMP_FILE, 'w') as f:
106 f.write(s) 110 f.write(s)
107 111
108 112
109 def GetSvnRevision(svn_repo): 113 def GetSvnRevision(svn_repo):
110 """Returns current revision of the svn repo at svn_repo.""" 114 """Returns current revision of the svn repo at svn_repo."""
111 svn_info = subprocess.check_output(['svn', 'info', svn_repo], shell=True) 115 svn_info = subprocess.check_output('svn info ' + svn_repo, shell=True)
112 m = re.search(r'Revision: (\d+)', svn_info) 116 m = re.search(r'Revision: (\d+)', svn_info)
113 return m.group(1) 117 return m.group(1)
114 118
115 119
116 def RmTree(dir): 120 def RmTree(dir):
117 """Delete dir.""" 121 """Delete dir."""
118 def ChmodAndRetry(func, path, _): 122 def ChmodAndRetry(func, path, _):
119 # Subversion can leave read-only files around. 123 # Subversion can leave read-only files around.
120 if not os.access(path, os.W_OK): 124 if not os.access(path, os.W_OK):
121 os.chmod(path, stat.S_IWUSR) 125 os.chmod(path, stat.S_IWUSR)
122 return func(path) 126 return func(path)
123 raise 127 raise
124 128
125 shutil.rmtree(dir, onerror=ChmodAndRetry) 129 shutil.rmtree(dir, onerror=ChmodAndRetry)
126 130
127 131
128 def RunCommand(command, fail_hard=True): 132 def RunCommand(command, msvc_arch=None, env=None, fail_hard=True):
129 """Run command and return success (True) or failure; or if fail_hard is 133 """Run command and return success (True) or failure; or if fail_hard is
130 True, exit on failure.""" 134 True, exit on failure. If msvc_arch is set, runs the command in a
135 shell with the msvc tools for that architecture."""
131 136
132 print 'Running %s' % (str(command)) 137 if msvc_arch and sys.platform == 'win32':
133 if subprocess.call(command, shell=True) == 0: 138 command = GetVSVersion().SetupScript(msvc_arch) + ['&&'] + command
139
140 # https://docs.python.org/2/library/subprocess.html:
141 # "On Unix with shell=True [...] if args is a sequence, the first item
142 # specifies the command string, and any additional items will be treated as
143 # additional arguments to the shell itself. That is to say, Popen does the
144 # equivalent of:
145 # Popen(['/bin/sh', '-c', args[0], args[1], ...])"
146 #
147 # We want to pass additional arguments to command[0], not to the shell,
148 # so manually join everything into a single string.
149 # Annoyingly, for "svn co url c:\path", pipes.quote() thinks that it should
150 # quote c:\path but svn can't handle quoted paths on Windows. Since on
151 # Windows follow-on args are passed to args[0] instead of the shell, don't
152 # do the single-string transformation there.
153 if sys.platform != 'win32':
154 command = ' '.join([pipes.quote(c) for c in command])
155 print 'Running', command
156 if subprocess.call(command, env=env, shell=True) == 0:
134 return True 157 return True
135 print 'Failed.' 158 print 'Failed.'
136 if fail_hard: 159 if fail_hard:
137 sys.exit(1) 160 sys.exit(1)
138 return False 161 return False
139 162
140 163
141 def CopyFile(src, dst): 164 def CopyFile(src, dst):
142 """Copy a file from src to dst.""" 165 """Copy a file from src to dst."""
143 shutil.copy(src, dst) 166 shutil.copy(src, dst)
(...skipping 21 matching lines...) Expand all
165 return 188 return
166 189
167 if os.path.isdir(dir): 190 if os.path.isdir(dir):
168 print "Removing %s." % (dir) 191 print "Removing %s." % (dir)
169 RmTree(dir) 192 RmTree(dir)
170 193
171 print "Retrying." 194 print "Retrying."
172 RunCommand(command) 195 RunCommand(command)
173 196
174 197
198 def RevertPreviouslyPatchedFiles():
199 print 'Reverting previously patched files'
200 files = [
201 '%(clang)s/test/Index/crash-recovery-modules.m',
202 '%(clang)s/unittests/libclang/LibclangTest.cpp',
203 '%(compiler_rt)s/lib/asan/asan_rtl.cc',
204 '%(compiler_rt)s/test/asan/TestCases/Linux/new_array_cookie_test.cc',
205 '%(llvm)s/test/DebugInfo/gmlt.ll',
206 '%(llvm)s/lib/CodeGen/SpillPlacement.cpp',
207 '%(llvm)s/lib/CodeGen/SpillPlacement.h',
208 '%(llvm)s/lib/Transforms/Instrumentation/MemorySanitizer.cpp',
209 '%(clang)s/test/Driver/env.c',
210 '%(clang)s/lib/Frontend/InitPreprocessor.cpp',
211 '%(clang)s/test/Frontend/exceptions.c',
212 '%(clang)s/test/Preprocessor/predefined-exceptions.m',
213 '%(llvm)s/test/Bindings/Go/go.test',
214 '%(clang)s/lib/Parse/ParseExpr.cpp',
215 '%(clang)s/lib/Parse/ParseTemplate.cpp',
216 '%(clang)s/lib/Sema/SemaDeclCXX.cpp',
217 '%(clang)s/lib/Sema/SemaExprCXX.cpp',
218 '%(clang)s/test/SemaCXX/default2.cpp',
219 '%(clang)s/test/SemaCXX/typo-correction-delayed.cpp',
220 '%(compiler_rt)s/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.c c',
221 '%(compiler_rt)s/test/tsan/signal_segv_handler.cc',
222 '%(compiler_rt)s/lib/sanitizer_common/sanitizer_coverage_libcdep.cc',
223 '%(compiler_rt)s/cmake/config-ix.cmake',
224 '%(compiler_rt)s/CMakeLists.txt',
225 '%(compiler_rt)s/lib/ubsan/ubsan_platform.h',
226 ]
227 for f in files:
228 f = f % {
229 'clang': CLANG_DIR,
230 'compiler_rt': COMPILER_RT_DIR,
231 'llvm': LLVM_DIR,
232 }
233 if os.path.exists(f):
234 os.remove(f) # For unversioned files.
235 RunCommand(['svn', 'revert', f])
236
237
238 def ApplyLocalPatches():
239 # There's no patch program on Windows by default. We don't need patches on
240 # Windows yet, and maybe this not working on Windows will motivate us to
241 # remove patches over time.
242 assert sys.platform != 'win32'
243
244 # No patches.
245
246
175 def DeleteChromeToolsShim(): 247 def DeleteChromeToolsShim():
248 OLD_SHIM_DIR = os.path.join(LLVM_DIR, 'tools', 'zzz-chrometools')
249 shutil.rmtree(OLD_SHIM_DIR, ignore_errors=True)
176 shutil.rmtree(CHROME_TOOLS_SHIM_DIR, ignore_errors=True) 250 shutil.rmtree(CHROME_TOOLS_SHIM_DIR, ignore_errors=True)
177 251
178 252
179 def CreateChromeToolsShim(): 253 def CreateChromeToolsShim():
180 """Hooks the Chrome tools into the LLVM build. 254 """Hooks the Chrome tools into the LLVM build.
181 255
182 Several Chrome tools have dependencies on LLVM/Clang libraries. The LLVM build 256 Several Chrome tools have dependencies on LLVM/Clang libraries. The LLVM build
183 detects implicit tools in the tools subdirectory, so this helper install a 257 detects implicit tools in the tools subdirectory, so this helper install a
184 shim CMakeLists.txt that forwards to the real directory for the Chrome tools. 258 shim CMakeLists.txt that forwards to the real directory for the Chrome tools.
185 259
(...skipping 28 matching lines...) Expand all
214 if not os.path.exists(cmake_dir): 288 if not os.path.exists(cmake_dir):
215 if not os.path.exists(LLVM_BUILD_TOOLS_DIR): 289 if not os.path.exists(LLVM_BUILD_TOOLS_DIR):
216 os.makedirs(LLVM_BUILD_TOOLS_DIR) 290 os.makedirs(LLVM_BUILD_TOOLS_DIR)
217 # The cmake archive is smaller than 20 MB, small enough to keep in memory: 291 # The cmake archive is smaller than 20 MB, small enough to keep in memory:
218 with contextlib.closing(cStringIO.StringIO()) as f: 292 with contextlib.closing(cStringIO.StringIO()) as f:
219 DownloadUrl(CDS_URL + '/tools/' + zip_name, f) 293 DownloadUrl(CDS_URL + '/tools/' + zip_name, f)
220 f.seek(0) 294 f.seek(0)
221 if zip_name.endswith('.zip'): 295 if zip_name.endswith('.zip'):
222 zipfile.ZipFile(f).extractall(path=LLVM_BUILD_TOOLS_DIR) 296 zipfile.ZipFile(f).extractall(path=LLVM_BUILD_TOOLS_DIR)
223 else: 297 else:
224 tarfile.open(mode='r:gz', fileobj=f).extractall(path=LLVM_BUILD_DIR) 298 tarfile.open(mode='r:gz', fileobj=f).extractall(path=
299 LLVM_BUILD_TOOLS_DIR)
225 os.environ['PATH'] = cmake_dir + os.pathsep + os.environ.get('PATH', '') 300 os.environ['PATH'] = cmake_dir + os.pathsep + os.environ.get('PATH', '')
226 301
227 vs_version = None 302 vs_version = None
228 def GetVSVersion(): 303 def GetVSVersion():
229 global vs_version 304 global vs_version
230 if vs_version: 305 if vs_version:
231 return vs_version 306 return vs_version
232 307
233 # Try using the toolchain in depot_tools. 308 # Try using the toolchain in depot_tools.
234 # This sets environment variables used by SelectVisualStudioVersion below. 309 # This sets environment variables used by SelectVisualStudioVersion below.
(...skipping 25 matching lines...) Expand all
260 # Check if there's a prebuilt binary and if so just fetch that. That's 335 # Check if there's a prebuilt binary and if so just fetch that. That's
261 # faster, and goma relies on having matching binary hashes on client and 336 # faster, and goma relies on having matching binary hashes on client and
262 # server too. 337 # server too.
263 print 'Trying to download prebuilt clang' 338 print 'Trying to download prebuilt clang'
264 339
265 # clang packages are smaller than 50 MB, small enough to keep in memory. 340 # clang packages are smaller than 50 MB, small enough to keep in memory.
266 with contextlib.closing(cStringIO.StringIO()) as f: 341 with contextlib.closing(cStringIO.StringIO()) as f:
267 try: 342 try:
268 DownloadUrl(cds_full_url, f) 343 DownloadUrl(cds_full_url, f)
269 f.seek(0) 344 f.seek(0)
345 # TODO(thakis): Delete LLVM_BUILD_DIR before extracting.
270 tarfile.open(mode='r:gz', fileobj=f).extractall(path=LLVM_BUILD_DIR) 346 tarfile.open(mode='r:gz', fileobj=f).extractall(path=LLVM_BUILD_DIR)
271 print 'clang %s unpacked' % PACKAGE_VERSION 347 print 'clang %s unpacked' % PACKAGE_VERSION
348 # Download the gold plugin if requested to by an environment variable.
349 # This is used by the CFI ClusterFuzz bot.
350 if 'LLVM_DOWNLOAD_GOLD_PLUGIN' in os.environ:
351 RunCommand(['python', CHROMIUM_DIR+'/build/download_gold_plugin.py'])
272 WriteStampFile(PACKAGE_VERSION) 352 WriteStampFile(PACKAGE_VERSION)
273 return 0 353 return 0
274 except urllib2.HTTPError: 354 except urllib2.HTTPError:
275 print 'Did not find prebuilt clang %s, building locally' % cds_file 355 print 'Did not find prebuilt clang %s, building locally' % cds_file
276 356
277 AddCMakeToPath() 357 AddCMakeToPath()
278 358
279 DeleteChromeToolsShim(); 359 RevertPreviouslyPatchedFiles()
360 DeleteChromeToolsShim()
361
280 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) 362 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR)
281 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) 363 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR)
282 Checkout('LLD', LLVM_REPO_URL + '/lld/trunk', LLD_DIR) 364 if sys.platform == 'win32':
365 Checkout('LLD', LLVM_REPO_URL + '/lld/trunk', LLD_DIR)
283 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) 366 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR)
284 CreateChromeToolsShim(); 367 if sys.platform == 'darwin':
368 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes
369 # (i.e. this is needed for bootstrap builds).
370 Checkout('libcxx', LLVM_REPO_URL + '/libcxx/trunk', LIBCXX_DIR)
371 # While we're bundling our own libc++ on OS X, we need to compile libc++abi
372 # into it too (since OS X 10.6 doesn't have libc++abi.dylib either).
373 Checkout('libcxxabi', LLVM_REPO_URL + '/libcxxabi/trunk', LIBCXXABI_DIR)
285 374
286 # If building at head, define a macro that plugins can use for #ifdefing 375 if args.with_patches and sys.platform != 'win32':
287 # out code that builds at head, but not at CLANG_REVISION or vice versa. 376 ApplyLocalPatches()
288 cflags = cxxflags = ''
289 377
290 # If building at head, define a macro that plugins can use for #ifdefing 378 cc, cxx = None, None
291 # out code that builds at head, but not at LLVM_WIN_REVISION or vice versa. 379 libstdcpp = None
292 if use_head_revision: 380 if args.gcc_toolchain: # This option is only used on Linux.
293 cflags += ' -DLLVM_FORCE_HEAD_REVISION' 381 # Use the specified gcc installation for building.
294 cxxflags += ' -DLLVM_FORCE_HEAD_REVISION' 382 cc = os.path.join(args.gcc_toolchain, 'bin', 'gcc')
383 cxx = os.path.join(args.gcc_toolchain, 'bin', 'g++')
384
385 if not os.access(cc, os.X_OK):
386 print 'Invalid --gcc-toolchain: "%s"' % args.gcc_toolchain
387 print '"%s" does not appear to be valid.' % cc
388 return 1
389
390 # Set LD_LIBRARY_PATH to make auxiliary targets (tablegen, bootstrap
391 # compiler, etc.) find the .so.
392 libstdcpp = subprocess.check_output(
393 [cxx, '-print-file-name=libstdc++.so.6']).rstrip()
394 os.environ['LD_LIBRARY_PATH'] = os.path.dirname(libstdcpp)
395
396 cflags = cxxflags = ldflags = []
397
398 # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is
399 # needed, on OS X it requires libc++. clang only automatically links to libc++
400 # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run
401 # on OS X versions as old as 10.7.
402 # TODO(thakis): Some bots are still on 10.6 (nacl...), so for now bundle
403 # libc++.dylib. Remove this once all bots are on 10.7+, then use
404 # -DLLVM_ENABLE_LIBCXX=ON and change deployment_target to 10.7.
405 deployment_target = ''
406
407 if sys.platform == 'darwin':
408 # When building on 10.9, /usr/include usually doesn't exist, and while
409 # Xcode's clang automatically sets a sysroot, self-built clangs don't.
410 cflags = ['-isysroot', subprocess.check_output(
411 ['xcrun', '--show-sdk-path']).rstrip()]
412 cxxflags = ['-stdlib=libc++', '-nostdinc++',
413 '-I' + os.path.join(LIBCXX_DIR, 'include')] + cflags
414 if args.bootstrap:
415 deployment_target = '10.6'
295 416
296 base_cmake_args = ['-GNinja', 417 base_cmake_args = ['-GNinja',
297 '-DCMAKE_BUILD_TYPE=Release', 418 '-DCMAKE_BUILD_TYPE=Release',
298 '-DLLVM_ENABLE_ASSERTIONS=ON', 419 '-DLLVM_ENABLE_ASSERTIONS=ON',
299 '-DLLVM_ENABLE_THREADS=OFF', 420 '-DLLVM_ENABLE_THREADS=OFF',
300 ] 421 ]
301 422
302 cc, cxx = None, None
303 if args.bootstrap: 423 if args.bootstrap:
304 print 'Building bootstrap compiler' 424 print 'Building bootstrap compiler'
305 if not os.path.exists(LLVM_BOOTSTRAP_DIR): 425 if not os.path.exists(LLVM_BOOTSTRAP_DIR):
306 os.makedirs(LLVM_BOOTSTRAP_DIR) 426 os.makedirs(LLVM_BOOTSTRAP_DIR)
307 os.chdir(LLVM_BOOTSTRAP_DIR) 427 os.chdir(LLVM_BOOTSTRAP_DIR)
308 bootstrap_args = base_cmake_args + [ 428 bootstrap_args = base_cmake_args + [
309 '-DLLVM_TARGETS_TO_BUILD=host', 429 '-DLLVM_TARGETS_TO_BUILD=host',
310 '-DCMAKE_INSTALL_PREFIX=' + LLVM_BOOTSTRAP_INSTALL_DIR, 430 '-DCMAKE_INSTALL_PREFIX=' + LLVM_BOOTSTRAP_INSTALL_DIR,
311 '-DCMAKE_C_FLAGS=' + cflags, 431 '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
312 '-DCMAKE_CXX_FLAGS=' + cxxflags, 432 '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags),
313 ] 433 ]
314 if cc is not None: bootstrap_args.append('-DCMAKE_C_COMPILER=' + cc) 434 if cc is not None: bootstrap_args.append('-DCMAKE_C_COMPILER=' + cc)
315 if cxx is not None: bootstrap_args.append('-DCMAKE_CXX_COMPILER=' + cxx) 435 if cxx is not None: bootstrap_args.append('-DCMAKE_CXX_COMPILER=' + cxx)
316 RunCommand(GetVSVersion().SetupScript('x64') + 436 RunCommand(['cmake'] + bootstrap_args + [LLVM_DIR], msvc_arch='x64')
317 ['&&', 'cmake'] + bootstrap_args + [LLVM_DIR]) 437 RunCommand(['ninja'], msvc_arch='x64')
318 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja'])
319 if args.run_tests: 438 if args.run_tests:
320 RunCommand(GetVSVersion().SetupScript('x64') + 439 RunCommand(['ninja', 'check-all'], msvc_arch='x64')
321 ['&&', 'ninja', 'check-all']) 440 RunCommand(['ninja', 'install'], msvc_arch='x64')
322 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'install']) 441 if args.gcc_toolchain:
323 # TODO(thakis): Set these to clang / clang++ on posix once this script 442 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap
324 # is used on posix. 443 # compiler can start.
325 cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe') 444 CopyFile(libstdcpp, os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'lib'))
326 cxx = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe') 445
327 # CMake has a hard time with backslashes in compiler paths: 446 if sys.platform == 'win32':
328 # https://stackoverflow.com/questions/13050827 447 cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe')
329 cc = cc.replace('\\', '/') 448 cxx = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang-cl.exe')
330 cxx = cxx.replace('\\', '/') 449 # CMake has a hard time with backslashes in compiler paths:
450 # https://stackoverflow.com/questions/13050827
451 cc = cc.replace('\\', '/')
452 cxx = cxx.replace('\\', '/')
453 else:
454 cc = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang')
455 cxx = os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'bin', 'clang++')
456
457 if args.gcc_toolchain:
458 # Tell the bootstrap compiler to use a specific gcc prefix to search
459 # for standard library headers and shared object files.
460 cflags = ['--gcc-toolchain=' + args.gcc_toolchain]
461 cxxflags = ['--gcc-toolchain=' + args.gcc_toolchain]
331 print 'Building final compiler' 462 print 'Building final compiler'
332 463
464 if sys.platform == 'darwin':
465 # Build libc++.dylib while some bots are still on OS X 10.6.
466 libcxxbuild = os.path.join(LLVM_BUILD_DIR, 'libcxxbuild')
467 if os.path.isdir(libcxxbuild):
468 RmTree(libcxxbuild)
469 libcxxflags = ['-O3', '-std=c++11', '-fstrict-aliasing']
470
471 # libcxx and libcxxabi both have a file stdexcept.cpp, so put their .o files
472 # into different subdirectories.
473 os.makedirs(os.path.join(libcxxbuild, 'libcxx'))
474 os.chdir(os.path.join(libcxxbuild, 'libcxx'))
475 RunCommand(['c++', '-c'] + cxxflags + libcxxflags +
476 glob.glob(os.path.join(LIBCXX_DIR, 'src', '*.cpp')))
477
478 os.makedirs(os.path.join(libcxxbuild, 'libcxxabi'))
479 os.chdir(os.path.join(libcxxbuild, 'libcxxabi'))
480 RunCommand(['c++', '-c'] + cxxflags + libcxxflags +
481 glob.glob(os.path.join(LIBCXXABI_DIR, 'src', '*.cpp')) +
482 ['-I' + os.path.join(LIBCXXABI_DIR, 'include')])
483
484 os.chdir(libcxxbuild)
485 libdir = os.path.join(LIBCXX_DIR, 'lib')
486 RunCommand(['cc'] + glob.glob('libcxx/*.o') + glob.glob('libcxxabi/*.o') +
487 ['-o', 'libc++.1.dylib', '-dynamiclib', '-nodefaultlibs',
488 '-current_version', '1', '-compatibility_version', '1', '-lSystem',
489 '-install_name', '@executable_path/libc++.dylib',
490 '-Wl,-unexported_symbols_list,' + libdir + '/libc++unexp.exp',
491 '-Wl,-force_symbols_not_weak_list,' + libdir + '/notweak.exp',
492 '-Wl,-force_symbols_weak_list,' + libdir + '/weak.exp'])
493 if os.path.exists('libc++.dylib'):
494 os.remove('libc++.dylib')
495 os.symlink('libc++.1.dylib', 'libc++.dylib')
496 ldflags += ['-stdlib=libc++', '-L' + libcxxbuild]
497
498 if args.bootstrap:
499 # Now that the libc++ headers have been installed and libc++.dylib is
500 # built, delete the libc++ checkout again so that it's not part of the
501 # main build below -- the libc++(abi) tests don't pass on OS X in
502 # bootstrap builds (http://llvm.org/PR24068)
503 RmTree(LIBCXX_DIR)
504 RmTree(LIBCXXABI_DIR)
505 cxxflags = ['-stdlib=libc++', '-nostdinc++',
506 '-I' + os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR,
507 'include/c++/v1')
508 ] + cflags
509
333 # Build clang. 510 # Build clang.
334 binutils_incdir = '' 511 binutils_incdir = ''
335 if sys.platform.startswith('linux'): 512 if sys.platform.startswith('linux'):
336 binutils_incdir = os.path.join(BINUTILS_DIR, 'Linux_x64/Release/include') 513 binutils_incdir = os.path.join(BINUTILS_DIR, 'Linux_x64/Release/include')
337 514
515 # If building at head, define a macro that plugins can use for #ifdefing
516 # out code that builds at head, but not at LLVM_WIN_REVISION or vice versa.
517 if use_head_revision:
518 cflags += ['-DLLVM_FORCE_HEAD_REVISION']
519 cxxflags += ['-DLLVM_FORCE_HEAD_REVISION']
520
521 CreateChromeToolsShim()
522
523 deployment_env = None
524 if deployment_target:
525 deployment_env = os.environ.copy()
526 deployment_env['MACOSX_DEPLOYMENT_TARGET'] = deployment_target
527
338 cmake_args = base_cmake_args + [ 528 cmake_args = base_cmake_args + [
339 '-DLLVM_BINUTILS_INCDIR=' + binutils_incdir, 529 '-DLLVM_BINUTILS_INCDIR=' + binutils_incdir,
340 '-DCMAKE_C_FLAGS=' + cflags, 530 '-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly',
341 '-DCMAKE_CXX_FLAGS=' + cxxflags, 531 '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
532 '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags),
533 '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags),
534 '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(ldflags),
535 '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(ldflags),
536 '-DCMAKE_INSTALL_PREFIX=' + LLVM_BUILD_DIR,
342 '-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(CHROMIUM_DIR, 'tools', 'clang'), 537 '-DCHROMIUM_TOOLS_SRC=%s' % os.path.join(CHROMIUM_DIR, 'tools', 'clang'),
343 '-DCHROMIUM_TOOLS=%s' % ';'.join(args.tools)] 538 '-DCHROMIUM_TOOLS=%s' % ';'.join(args.tools)]
344 # TODO(thakis): Append this to base_cmake_args instead once compiler-rt 539 # TODO(thakis): Unconditionally append this to base_cmake_args instead once
345 # can build with clang-cl (http://llvm.org/PR23698) 540 # compiler-rt can build with clang-cl on Windows (http://llvm.org/PR23698)
346 if cc is not None: cmake_args.append('-DCMAKE_C_COMPILER=' + cc) 541 cc_args = base_cmake_args if sys.platform != 'win32' else cmake_args
347 if cxx is not None: cmake_args.append('-DCMAKE_CXX_COMPILER=' + cxx) 542 if cc is not None: cc_args.append('-DCMAKE_C_COMPILER=' + cc)
543 if cxx is not None: cc_args.append('-DCMAKE_CXX_COMPILER=' + cxx)
348 544
349 if not os.path.exists(LLVM_BUILD_DIR): 545 if not os.path.exists(LLVM_BUILD_DIR):
350 os.makedirs(LLVM_BUILD_DIR) 546 os.makedirs(LLVM_BUILD_DIR)
351 os.chdir(LLVM_BUILD_DIR) 547 os.chdir(LLVM_BUILD_DIR)
352 RunCommand(GetVSVersion().SetupScript('x64') + 548 RunCommand(['cmake'] + cmake_args + [LLVM_DIR],
353 ['&&', 'cmake'] + cmake_args + [LLVM_DIR]) 549 msvc_arch='x64', env=deployment_env)
354 RunCommand(GetVSVersion().SetupScript('x64') + ['&&', 'ninja', 'all']) 550
551 if args.gcc_toolchain:
552 # Copy in the right stdlibc++.so.6 so clang can start.
553 if not os.path.exists(os.path.join(LLVM_BUILD_DIR, 'lib')):
554 os.mkdir(os.path.join(LLVM_BUILD_DIR, 'lib'))
555 libstdcpp = subprocess.check_output(
556 [cxx] + cxxflags + ['-print-file-name=libstdc++.so.6']).rstrip()
557 CopyFile(libstdcpp, os.path.join(LLVM_BUILD_DIR, 'lib'))
558
559 RunCommand(['ninja'], msvc_arch='x64')
560
561 if args.tools:
562 # If any Chromium tools were built, install those now.
563 RunCommand(['ninja', 'cr-install'], msvc_arch='x64')
564
565 if sys.platform == 'darwin':
566 CopyFile(os.path.join(LLVM_BUILD_DIR, 'libc++.1.dylib'),
567 os.path.join(LLVM_BUILD_DIR, 'bin'))
568 # See http://crbug.com/256342
569 RunCommand(['strip', '-x', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')])
570 elif sys.platform.startswith('linux'):
571 RunCommand(['strip', os.path.join(LLVM_BUILD_DIR, 'bin', 'clang')])
355 572
356 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time. 573 # Do an x86 build of compiler-rt to get the 32-bit ASan run-time.
357 # TODO(hans): Remove once the regular build above produces this. 574 # TODO(hans): Remove once the regular build above produces this.
358 if not os.path.exists(COMPILER_RT_BUILD_DIR): 575 if not os.path.exists(COMPILER_RT_BUILD_DIR):
359 os.makedirs(COMPILER_RT_BUILD_DIR) 576 os.makedirs(COMPILER_RT_BUILD_DIR)
360 os.chdir(COMPILER_RT_BUILD_DIR) 577 os.chdir(COMPILER_RT_BUILD_DIR)
361 # TODO(thakis): Add this once compiler-rt can build with clang-cl (see 578 # TODO(thakis): Add this once compiler-rt can build with clang-cl (see
362 # above). 579 # above).
363 #if args.bootstrap: 580 #if args.bootstrap and sys.platform == 'win32':
364 # The bootstrap compiler produces 64-bit binaries by default. 581 # The bootstrap compiler produces 64-bit binaries by default.
365 #cflags += ' -m32' 582 #cflags += ['-m32']
366 #cxxflags += ' -m32' 583 #cxxflags += ['-m32']
367 compiler_rt_args = base_cmake_args + [ 584 compiler_rt_args = base_cmake_args + [
368 '-DCMAKE_C_FLAGS=' + cflags, 585 '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
369 '-DCMAKE_CXX_FLAGS=' + cxxflags] 586 '-DCMAKE_CXX_FLAGS=' + ' '.join(cxxflags)]
370 RunCommand(GetVSVersion().SetupScript('x86') + 587 if sys.platform != 'win32':
371 ['&&', 'cmake'] + compiler_rt_args + [LLVM_DIR]) 588 compiler_rt_args += ['-DLLVM_CONFIG_PATH=' +
372 RunCommand(GetVSVersion().SetupScript('x86') + ['&&', 'ninja', 'compiler-rt']) 589 os.path.join(LLVM_BUILD_DIR, 'bin', 'llvm-config'),
590 '-DSANITIZER_MIN_OSX_VERSION="10.7"']
591 RunCommand(['cmake'] + compiler_rt_args + [LLVM_DIR],
592 msvc_arch='x86', env=deployment_env)
593 RunCommand(['ninja', 'compiler-rt'], msvc_arch='x86')
373 594
374 # TODO(hans): Make this (and the .gypi and .isolate files) version number 595 # TODO(hans): Make this (and the .gypi and .isolate files) version number
375 # independent. 596 # independent.
597 if sys.platform == 'win32':
598 platform = 'windows'
599 elif sys.platform == 'darwin':
600 platform = 'darwin'
601 else:
602 assert sys.platform.startswith('linux')
603 platform = 'linux'
376 asan_rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang', 604 asan_rt_lib_src_dir = os.path.join(COMPILER_RT_BUILD_DIR, 'lib', 'clang',
377 VERSION, 'lib', 'windows') 605 VERSION, 'lib', platform)
378 asan_rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', 606 asan_rt_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang',
379 VERSION, 'lib', 'windows') 607 VERSION, 'lib', platform)
380 CopyDirectoryContents(asan_rt_lib_src_dir, asan_rt_lib_dst_dir, 608 CopyDirectoryContents(asan_rt_lib_src_dir, asan_rt_lib_dst_dir,
381 r'^.*-i386\.lib$') 609 r'^.*-i386\.lib$')
382 CopyDirectoryContents(asan_rt_lib_src_dir, asan_rt_lib_dst_dir, 610 CopyDirectoryContents(asan_rt_lib_src_dir, asan_rt_lib_dst_dir,
383 r'^.*-i386\.dll$') 611 r'^.*-i386\.dll$')
384 612
385 CopyFile(os.path.join(asan_rt_lib_src_dir, '..', '..', 'asan_blacklist.txt'), 613 CopyFile(os.path.join(asan_rt_lib_src_dir, '..', '..', 'asan_blacklist.txt'),
386 os.path.join(asan_rt_lib_dst_dir, '..', '..')) 614 os.path.join(asan_rt_lib_dst_dir, '..', '..'))
387 615
388 # Make an extra copy of the sanitizer headers, to be put on the include path 616 if sys.platform == 'win32':
389 # of the fallback compiler. 617 # Make an extra copy of the sanitizer headers, to be put on the include path
390 sanitizer_include_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', VERSION, 618 # of the fallback compiler.
391 'include', 'sanitizer') 619 sanitizer_include_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang',
392 aux_sanitizer_include_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang', 620 VERSION, 'include', 'sanitizer')
393 VERSION, 'include_sanitizer', 621 aux_sanitizer_include_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang',
394 'sanitizer') 622 VERSION, 'include_sanitizer',
395 if not os.path.exists(aux_sanitizer_include_dir): 623 'sanitizer')
396 os.makedirs(aux_sanitizer_include_dir) 624 if not os.path.exists(aux_sanitizer_include_dir):
397 for _, _, files in os.walk(sanitizer_include_dir): 625 os.makedirs(aux_sanitizer_include_dir)
398 for f in files: 626 for _, _, files in os.walk(sanitizer_include_dir):
399 CopyFile(os.path.join(sanitizer_include_dir, f), 627 for f in files:
400 aux_sanitizer_include_dir) 628 CopyFile(os.path.join(sanitizer_include_dir, f),
629 aux_sanitizer_include_dir)
401 630
402 # Run tests. 631 # Run tests.
403 if args.run_tests or use_head_revision: 632 if args.run_tests or use_head_revision:
404 os.chdir(LLVM_BUILD_DIR) 633 os.chdir(LLVM_BUILD_DIR)
405 RunCommand(GetVSVersion().SetupScript('x64') + 634 RunCommand(GetVSVersion().SetupScript('x64') +
406 ['&&', 'ninja', 'cr-check-all']) 635 ['&&', 'ninja', 'cr-check-all'])
407 if args.run_tests: 636 if args.run_tests:
408 os.chdir(LLVM_BUILD_DIR) 637 os.chdir(LLVM_BUILD_DIR)
409 RunCommand(GetVSVersion().SetupScript('x64') + 638 RunCommand(GetVSVersion().SetupScript('x64') +
410 ['&&', 'ninja', 'check-all']) 639 ['&&', 'ninja', 'check-all'])
(...skipping 29 matching lines...) Expand all
440 [os.path.join(os.path.dirname(__file__), 'update.sh')] + sys.argv[1:], 669 [os.path.join(os.path.dirname(__file__), 'update.sh')] + sys.argv[1:],
441 stderr=stderr) 670 stderr=stderr)
442 671
443 parser = argparse.ArgumentParser(description='Build Clang.') 672 parser = argparse.ArgumentParser(description='Build Clang.')
444 parser.add_argument('--bootstrap', action='store_true', 673 parser.add_argument('--bootstrap', action='store_true',
445 help='first build clang with CC, then with itself.') 674 help='first build clang with CC, then with itself.')
446 parser.add_argument('--if-needed', action='store_true', 675 parser.add_argument('--if-needed', action='store_true',
447 help="run only if the script thinks clang is needed") 676 help="run only if the script thinks clang is needed")
448 parser.add_argument('--force-local-build', action='store_true', 677 parser.add_argument('--force-local-build', action='store_true',
449 help="don't try to download prebuild binaries") 678 help="don't try to download prebuild binaries")
679 parser.add_argument('--gcc-toolchain', help='set the version for which gcc '
680 'version be used for building; --gcc-toolchain=/opt/foo '
681 'picks /opt/foo/bin/gcc')
450 parser.add_argument('--print-revision', action='store_true', 682 parser.add_argument('--print-revision', action='store_true',
451 help='print current clang revision and exit.') 683 help='print current clang revision and exit.')
684 parser.add_argument('--print-clang-version', action='store_true',
685 help='print current clang version (e.g. x.y.z) and exit.')
452 parser.add_argument('--run-tests', action='store_true', 686 parser.add_argument('--run-tests', action='store_true',
453 help='run tests after building; only for local builds') 687 help='run tests after building; only for local builds')
454 parser.add_argument('--tools', nargs='*', 688 parser.add_argument('--tools', nargs='*',
455 help='select which chrome tools to build', 689 help='select which chrome tools to build',
456 default=['plugins', 'blink_gc_plugin']) 690 default=['plugins', 'blink_gc_plugin'])
691 parser.add_argument('--without-patches', action='store_false',
692 help="don't apply patches (default)", dest='with_patches',
693 default=True)
694
457 # For now, these flags are only used for the non-Windows flow, but argparser 695 # For now, these flags are only used for the non-Windows flow, but argparser
458 # gets mad if it sees a flag it doesn't recognize. 696 # gets mad if it sees a flag it doesn't recognize.
459 parser.add_argument('--no-stdin-hack', action='store_true') 697 parser.add_argument('--no-stdin-hack', action='store_true')
460 698
461 args = parser.parse_args() 699 args = parser.parse_args()
462 700
463 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')):
464 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).'
465 return 0
466 if args.if_needed: 701 if args.if_needed:
467 is_clang_required = False 702 is_clang_required = False
468 # clang is always used on Mac and Linux. 703 # clang is always used on Mac and Linux.
469 if sys.platform == 'darwin' or sys.platform.startswith('linux'): 704 if sys.platform == 'darwin' or sys.platform.startswith('linux'):
470 is_clang_required = True 705 is_clang_required = True
471 # clang requested via $GYP_DEFINES. 706 # clang requested via $GYP_DEFINES.
472 if re.search(r'\b(clang|asan|lsan|msan|tsan)=1', 707 if re.search(r'\b(clang|asan|lsan|msan|tsan)=1',
473 os.environ.get('GYP_DEFINES', '')): 708 os.environ.get('GYP_DEFINES', '')):
474 is_clang_required = True 709 is_clang_required = True
475 # clang previously downloaded, keep it up-to-date. 710 # clang previously downloaded, keep it up-to-date.
476 # If you don't want this, delete third_party/llvm-build on your machine. 711 # If you don't want this, delete third_party/llvm-build on your machine.
477 if os.path.isdir(LLVM_BUILD_DIR): 712 if os.path.isdir(LLVM_BUILD_DIR):
478 is_clang_required = True 713 is_clang_required = True
479 if not is_clang_required: 714 if not is_clang_required:
480 return 0 715 return 0
716 if re.search(r'\b(make_clang_dir)=', os.environ.get('GYP_DEFINES', '')):
717 print 'Skipping Clang update (make_clang_dir= was set in GYP_DEFINES).'
718 return 0
481 719
482 global LLVM_WIN_REVISION, PACKAGE_VERSION 720 global LLVM_WIN_REVISION, PACKAGE_VERSION
483 if args.print_revision: 721 if args.print_revision:
484 if use_head_revision: 722 if use_head_revision:
485 print GetSvnRevision(LLVM_DIR) 723 print GetSvnRevision(LLVM_DIR)
486 else: 724 else:
487 print PACKAGE_VERSION 725 print PACKAGE_VERSION
488 return 0 726 return 0
489 727
490 if LLVM_WIN_REVISION == 'HEAD': 728 if args.print_clang_version:
729 sys.stdout.write(VERSION)
730 return 0
731
732 # Don't buffer stdout, so that print statements are immediately flushed.
733 # Do this only after --print-revision has been handled, else we'll get
734 # an error message when this script is run from gn for some reason.
735 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
736
737 if use_head_revision:
491 # Use a real revision number rather than HEAD to make sure that the stamp 738 # Use a real revision number rather than HEAD to make sure that the stamp
492 # file logic works. 739 # file logic works.
493 LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL) 740 LLVM_WIN_REVISION = GetSvnRevision(LLVM_REPO_URL)
494 PACKAGE_VERSION = LLVM_WIN_REVISION + '-0' 741 PACKAGE_VERSION = LLVM_WIN_REVISION + '-0'
495 742
743 args.force_local_build = True
744 # Skip local patches when using HEAD: they probably don't apply anymore.
745 args.with_patches = False
746
496 return UpdateClang(args) 747 return UpdateClang(args)
497 748
498 749
499 if __name__ == '__main__': 750 if __name__ == '__main__':
500 sys.exit(main()) 751 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/clang/scripts/package.py ('k') | tools/clang/scripts/update.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698