OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2015 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 """This script will check out llvm and clang, and then package the results up | 6 """This script will check out llvm and clang, and then package the results up |
7 to a tgz file.""" | 7 to a tgz file.""" |
8 | 8 |
9 import argparse | 9 import argparse |
10 import fnmatch | 10 import fnmatch |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 exit_code = RunGsutil(gsutil_args) | 156 exit_code = RunGsutil(gsutil_args) |
157 if exit_code != 0: | 157 if exit_code != 0: |
158 print "gsutil failed, exit_code: %s" % exit_code | 158 print "gsutil failed, exit_code: %s" % exit_code |
159 sys.exit(exit_code) | 159 sys.exit(exit_code) |
160 | 160 |
161 | 161 |
162 def main(): | 162 def main(): |
163 parser = argparse.ArgumentParser(description='build and package clang') | 163 parser = argparse.ArgumentParser(description='build and package clang') |
164 parser.add_argument('--upload', action='store_true', | 164 parser.add_argument('--upload', action='store_true', |
165 help='Upload the target archive to Google Cloud Storage.') | 165 help='Upload the target archive to Google Cloud Storage.') |
166 parser.add_argument('--enable-pgo', action='store_true', | |
167 help='Build clang with GO enabled.') | |
Nico
2017/04/07 15:58:53
Typo GO.
Also, why have a flag for this? Shouldn'
matthewtff.asm
2017/04/11 12:14:43
I believe it should be default. Made a flag just i
| |
166 args = parser.parse_args() | 168 args = parser.parse_args() |
167 | 169 |
168 # Check that the script is not going to upload a toolchain built from HEAD. | 170 # Check that the script is not going to upload a toolchain built from HEAD. |
169 use_head_revision = 'LLVM_FORCE_HEAD_REVISION' in os.environ | 171 use_head_revision = 'LLVM_FORCE_HEAD_REVISION' in os.environ |
170 if args.upload and use_head_revision: | 172 if args.upload and use_head_revision: |
171 print ("--upload and LLVM_FORCE_HEAD_REVISION could not be used " | 173 print ("--upload and LLVM_FORCE_HEAD_REVISION could not be used " |
172 "at the same time.") | 174 "at the same time.") |
173 return 1 | 175 return 1 |
174 | 176 |
175 expected_stamp = GetExpectedStamp() | 177 expected_stamp = GetExpectedStamp() |
176 pdir = 'clang-' + expected_stamp | 178 pdir = 'clang-' + expected_stamp |
177 golddir = 'llvmgold-' + expected_stamp | 179 golddir = 'llvmgold-' + expected_stamp |
178 print pdir | 180 print pdir |
179 | 181 |
180 if sys.platform == 'darwin': | 182 if sys.platform == 'darwin': |
181 platform = 'Mac' | 183 platform = 'Mac' |
182 elif sys.platform == 'win32': | 184 elif sys.platform == 'win32': |
183 platform = 'Win' | 185 platform = 'Win' |
184 else: | 186 else: |
185 platform = 'Linux_x64' | 187 platform = 'Linux_x64' |
186 | 188 |
187 # Check if Google Cloud Storage already has the artifacts we want to build. | 189 # Check if Google Cloud Storage already has the artifacts we want to build. |
188 if (args.upload and GsutilArchiveExists(pdir, platform) and | 190 if (args.upload and GsutilArchiveExists(pdir, platform) and |
189 not sys.platform.startswith('linux') or | 191 (not sys.platform.startswith('linux') or |
190 GsutilArchiveExists(golddir, platform)): | 192 GsutilArchiveExists(golddir, platform))): |
Nico
2017/04/07 15:58:53
This looks like a good change, but also unrelated.
| |
191 print ('Desired toolchain revision %s is already available ' | 193 print ('Desired toolchain revision %s is already available ' |
192 'in Google Cloud Storage:') % expected_stamp | 194 'in Google Cloud Storage:') % expected_stamp |
193 print 'gs://chromium-browser-clang-staging/%s/%s.tgz' % (platform, pdir) | 195 print 'gs://chromium-browser-clang-staging/%s/%s.tgz' % (platform, pdir) |
194 if sys.platform.startswith('linux'): | 196 if sys.platform.startswith('linux'): |
195 print 'gs://chromium-browser-clang-staging/%s/%s.tgz' % (platform, | 197 print 'gs://chromium-browser-clang-staging/%s/%s.tgz' % (platform, |
196 golddir) | 198 golddir) |
197 return 0 | 199 return 0 |
198 | 200 |
199 with open('buildlog.txt', 'w') as log: | 201 with open('buildlog.txt', 'w') as log: |
200 Tee('Diff in llvm:\n', log) | 202 Tee('Diff in llvm:\n', log) |
(...skipping 21 matching lines...) Expand all Loading... | |
222 Tee('Starting build\n', log) | 224 Tee('Starting build\n', log) |
223 | 225 |
224 # Do a clobber build. | 226 # Do a clobber build. |
225 shutil.rmtree(LLVM_BOOTSTRAP_DIR, ignore_errors=True) | 227 shutil.rmtree(LLVM_BOOTSTRAP_DIR, ignore_errors=True) |
226 shutil.rmtree(LLVM_BOOTSTRAP_INSTALL_DIR, ignore_errors=True) | 228 shutil.rmtree(LLVM_BOOTSTRAP_INSTALL_DIR, ignore_errors=True) |
227 shutil.rmtree(LLVM_BUILD_DIR, ignore_errors=True) | 229 shutil.rmtree(LLVM_BUILD_DIR, ignore_errors=True) |
228 | 230 |
229 opt_flags = [] | 231 opt_flags = [] |
230 if sys.platform.startswith('linux'): | 232 if sys.platform.startswith('linux'): |
231 opt_flags += ['--lto-gold-plugin'] | 233 opt_flags += ['--lto-gold-plugin'] |
234 | |
235 if sys.platform != 'win32' and args.enable_pgo: | |
236 opt_flags += ['--enable-pgo'] | |
237 else: | |
238 opt_flags += ['--bootstrap'] | |
239 | |
232 build_cmd = [sys.executable, os.path.join(THIS_DIR, 'update.py'), | 240 build_cmd = [sys.executable, os.path.join(THIS_DIR, 'update.py'), |
233 '--bootstrap', '--force-local-build', | 241 '--force-local-build', '--run-tests'] + opt_flags |
234 '--run-tests'] + opt_flags | |
235 TeeCmd(build_cmd, log) | 242 TeeCmd(build_cmd, log) |
236 | 243 |
244 if args.enable_pgo: | |
245 global LLVM_RELEASE_DIR | |
246 LLVM_RELEASE_DIR = os.path.join(LLVM_RELEASE_DIR, 'tools', 'clang', | |
247 'stage2-instrumented-bins', 'tools', 'clang', 'stage2-bins') | |
248 | |
237 stamp = open(STAMP_FILE).read().rstrip() | 249 stamp = open(STAMP_FILE).read().rstrip() |
238 if stamp != expected_stamp: | 250 if stamp != expected_stamp: |
239 print 'Actual stamp (%s) != expected stamp (%s).' % (stamp, expected_stamp) | 251 print 'Actual stamp (%s) != expected stamp (%s).' % (stamp, expected_stamp) |
240 return 1 | 252 return 1 |
241 | 253 |
242 shutil.rmtree(pdir, ignore_errors=True) | 254 shutil.rmtree(pdir, ignore_errors=True) |
243 | 255 |
244 # Copy a whitelist of files to the directory we're going to tar up. | 256 # Copy a whitelist of files to the directory we're going to tar up. |
245 # This supports the same patterns that the fnmatch module understands. | 257 # This supports the same patterns that the fnmatch module understands. |
246 exe_ext = '.exe' if sys.platform == 'win32' else '' | 258 exe_ext = '.exe' if sys.platform == 'win32' else '' |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 # Set up symlinks. | 324 # Set up symlinks. |
313 if sys.platform != 'win32': | 325 if sys.platform != 'win32': |
314 os.symlink('clang', os.path.join(pdir, 'bin', 'clang++')) | 326 os.symlink('clang', os.path.join(pdir, 'bin', 'clang++')) |
315 os.symlink('clang', os.path.join(pdir, 'bin', 'clang-cl')) | 327 os.symlink('clang', os.path.join(pdir, 'bin', 'clang-cl')) |
316 | 328 |
317 if sys.platform.startswith('linux'): | 329 if sys.platform.startswith('linux'): |
318 os.symlink('lld', os.path.join(pdir, 'bin', 'ld.lld')) | 330 os.symlink('lld', os.path.join(pdir, 'bin', 'ld.lld')) |
319 | 331 |
320 # Copy libc++ headers. | 332 # Copy libc++ headers. |
321 if sys.platform == 'darwin': | 333 if sys.platform == 'darwin': |
322 shutil.copytree(os.path.join(LLVM_BOOTSTRAP_INSTALL_DIR, 'include', 'c++'), | 334 install_dir = LLVM_RELEASE_DIR if args.enable_pgo else \ |
335 LLVM_BOOTSTRAP_INSTALL_DIR | |
336 shutil.copytree(os.path.join(install_dir, 'include', 'c++'), | |
323 os.path.join(pdir, 'include', 'c++')) | 337 os.path.join(pdir, 'include', 'c++')) |
324 | 338 |
325 # Copy buildlog over. | 339 # Copy buildlog over. |
326 shutil.copy('buildlog.txt', pdir) | 340 shutil.copy('buildlog.txt', pdir) |
327 | 341 |
328 # Create archive. | 342 # Create archive. |
329 tar_entries = ['bin', 'lib', 'buildlog.txt'] | 343 tar_entries = ['bin', 'lib', 'buildlog.txt'] |
330 if sys.platform == 'darwin': | 344 if sys.platform == 'darwin': |
331 tar_entries += ['include'] | 345 tar_entries += ['include'] |
332 with tarfile.open(pdir + '.tgz', 'w:gz') as tar: | 346 with tarfile.open(pdir + '.tgz', 'w:gz') as tar: |
(...skipping 25 matching lines...) Expand all Loading... | |
358 MaybeUpload(args, objdumpdir, platform) | 372 MaybeUpload(args, objdumpdir, platform) |
359 | 373 |
360 if sys.platform == 'win32' and args.upload: | 374 if sys.platform == 'win32' and args.upload: |
361 UploadPDBToSymbolServer() | 375 UploadPDBToSymbolServer() |
362 | 376 |
363 # FIXME: Warn if the file already exists on the server. | 377 # FIXME: Warn if the file already exists on the server. |
364 | 378 |
365 | 379 |
366 if __name__ == '__main__': | 380 if __name__ == '__main__': |
367 sys.exit(main()) | 381 sys.exit(main()) |
OLD | NEW |