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

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

Issue 2893973003: not working update.py to build fuchsia builtins
Patch Set: Created 3 years, 7 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 | « no previous file | no next file » | 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 """This script is used to download prebuilt clang binaries. 6 """This script is used to download prebuilt clang binaries.
7 7
8 It is also used by package.py to build the prebuilt clang binaries.""" 8 It is also used by package.py to build the prebuilt clang binaries."""
9 9
10 import argparse 10 import argparse
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 os.path.join(LLVM_DIR, '..', 'llvm-build-tools')) 66 os.path.join(LLVM_DIR, '..', 'llvm-build-tools'))
67 STAMP_FILE = os.path.normpath( 67 STAMP_FILE = os.path.normpath(
68 os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision')) 68 os.path.join(LLVM_DIR, '..', 'llvm-build', 'cr_build_revision'))
69 BINUTILS_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils', 'Linux_x64', 'Release') 69 BINUTILS_DIR = os.path.join(THIRD_PARTY_DIR, 'binutils', 'Linux_x64', 'Release')
70 BINUTILS_BIN_DIR = os.path.join(BINUTILS_DIR, 'bin') 70 BINUTILS_BIN_DIR = os.path.join(BINUTILS_DIR, 'bin')
71 BINUTILS_LIB_DIR = os.path.join(BINUTILS_DIR, 'lib') 71 BINUTILS_LIB_DIR = os.path.join(BINUTILS_DIR, 'lib')
72 BFD_PLUGINS_DIR = os.path.join(BINUTILS_LIB_DIR, 'bfd-plugins') 72 BFD_PLUGINS_DIR = os.path.join(BINUTILS_LIB_DIR, 'bfd-plugins')
73 VERSION = '5.0.0' 73 VERSION = '5.0.0'
74 ANDROID_NDK_DIR = os.path.join( 74 ANDROID_NDK_DIR = os.path.join(
75 CHROMIUM_DIR, 'third_party', 'android_tools', 'ndk') 75 CHROMIUM_DIR, 'third_party', 'android_tools', 'ndk')
76 FUCHSIA_SDK_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'fuchsia-sdk')
76 77
77 # URL for pre-built binaries. 78 # URL for pre-built binaries.
78 CDS_URL = os.environ.get('CDS_CLANG_BUCKET_OVERRIDE', 79 CDS_URL = os.environ.get('CDS_CLANG_BUCKET_OVERRIDE',
79 'https://commondatastorage.googleapis.com/chromium-browser-clang') 80 'https://commondatastorage.googleapis.com/chromium-browser-clang')
80 81
81 LLVM_REPO_URL='https://llvm.org/svn/llvm-project' 82 LLVM_REPO_URL='https://llvm.org/svn/llvm-project'
82 if 'LLVM_REPO_URL' in os.environ: 83 if 'LLVM_REPO_URL' in os.environ:
83 LLVM_REPO_URL = os.environ['LLVM_REPO_URL'] 84 LLVM_REPO_URL = os.environ['LLVM_REPO_URL']
84 85
85 # Bump after VC updates. 86 # Bump after VC updates.
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 return 1 442 return 1
442 443
443 if args.with_android and not os.path.exists(ANDROID_NDK_DIR): 444 if args.with_android and not os.path.exists(ANDROID_NDK_DIR):
444 print 'Android NDK not found at ' + ANDROID_NDK_DIR 445 print 'Android NDK not found at ' + ANDROID_NDK_DIR
445 print 'The Android NDK is needed to build a Clang whose -fsanitize=address' 446 print 'The Android NDK is needed to build a Clang whose -fsanitize=address'
446 print 'works on Android. See ' 447 print 'works on Android. See '
447 print 'https://www.chromium.org/developers/how-tos/android-build-instruction s' 448 print 'https://www.chromium.org/developers/how-tos/android-build-instruction s'
448 print 'for how to install the NDK, or pass --without-android.' 449 print 'for how to install the NDK, or pass --without-android.'
449 return 1 450 return 1
450 451
452 if args.with_fuchsia and not os.path.exists(FUCHSIA_SDK_DIR):
453 print 'Fuchsia SDK not found at ' + FUCHSIA_SDK_DIR
454 print 'Either install it there by including target_os=[\'fuchsia\'] in '
455 print '.gclient and rerunning gclient runhooks, or pass --without-fuchsia.'
456 return 1
457
451 DownloadHostGcc(args) 458 DownloadHostGcc(args)
452 AddCMakeToPath() 459 AddCMakeToPath()
453 AddGnuWinToPath() 460 AddGnuWinToPath()
454 461
455 DeleteChromeToolsShim() 462 DeleteChromeToolsShim()
456 463
457 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR) 464 Checkout('LLVM', LLVM_REPO_URL + '/llvm/trunk', LLVM_DIR)
458 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR) 465 Checkout('Clang', LLVM_REPO_URL + '/cfe/trunk', CLANG_DIR)
459 if sys.platform != 'darwin': 466 if sys.platform != 'darwin':
460 Checkout('LLD', LLVM_REPO_URL + '/lld/trunk', LLD_DIR) 467 Checkout('LLD', LLVM_REPO_URL + '/lld/trunk', LLD_DIR)
461 elif os.path.exists(LLD_DIR): 468 elif os.path.exists(LLD_DIR):
462 # In case someone sends a tryjob that temporary adds lld to the checkout, 469 # In case someone sends a tryjob that temporarily adds lld to the checkout,
463 # make sure it's not around on future builds. 470 # make sure it's not around on future builds.
464 RmTree(LLD_DIR) 471 RmTree(LLD_DIR)
465 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR) 472 Checkout('compiler-rt', LLVM_REPO_URL + '/compiler-rt/trunk', COMPILER_RT_DIR)
466 if sys.platform == 'darwin': 473 if sys.platform == 'darwin':
467 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes 474 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes
468 # (i.e. this is needed for bootstrap builds). 475 # (i.e. this is needed for bootstrap builds).
469 Checkout('libcxx', LLVM_REPO_URL + '/libcxx/trunk', LIBCXX_DIR) 476 Checkout('libcxx', LLVM_REPO_URL + '/libcxx/trunk', LIBCXX_DIR)
470 # We used to check out libcxxabi on OS X; we no longer need that. 477 # We used to check out libcxxabi on OS X; we no longer need that.
471 if os.path.exists(LIBCXXABI_DIR): 478 if os.path.exists(LIBCXXABI_DIR):
472 RmTree(LIBCXXABI_DIR) 479 RmTree(LIBCXXABI_DIR)
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 696
690 VeryifyVersionOfBuiltClangMatchesVERSION() 697 VeryifyVersionOfBuiltClangMatchesVERSION()
691 698
692 # Do an out-of-tree build of compiler-rt. 699 # Do an out-of-tree build of compiler-rt.
693 # On Windows, this is used to get the 32-bit ASan run-time. 700 # On Windows, this is used to get the 32-bit ASan run-time.
694 # TODO(hans): Remove once the regular build above produces this. 701 # TODO(hans): Remove once the regular build above produces this.
695 # On Mac and Linux, this is used to get the regular 64-bit run-time. 702 # On Mac and Linux, this is used to get the regular 64-bit run-time.
696 # Do a clobbered build due to cmake changes. 703 # Do a clobbered build due to cmake changes.
697 if os.path.isdir(COMPILER_RT_BUILD_DIR): 704 if os.path.isdir(COMPILER_RT_BUILD_DIR):
698 RmTree(COMPILER_RT_BUILD_DIR) 705 RmTree(COMPILER_RT_BUILD_DIR)
699 os.makedirs(COMPILER_RT_BUILD_DIR) 706 EnsureDirExists(COMPILER_RT_BUILD_DIR)
700 os.chdir(COMPILER_RT_BUILD_DIR) 707 os.chdir(COMPILER_RT_BUILD_DIR)
701 # TODO(thakis): Add this once compiler-rt can build with clang-cl (see 708 # TODO(thakis): Add this once compiler-rt can build with clang-cl (see
702 # above). 709 # above).
703 #if args.bootstrap and sys.platform == 'win32': 710 #if args.bootstrap and sys.platform == 'win32':
704 # The bootstrap compiler produces 64-bit binaries by default. 711 # The bootstrap compiler produces 64-bit binaries by default.
705 #cflags += ['-m32'] 712 #cflags += ['-m32']
706 #cxxflags += ['-m32'] 713 #cxxflags += ['-m32']
707 compiler_rt_args = base_cmake_args + [ 714 compiler_rt_args = base_cmake_args + [
708 '-DLLVM_ENABLE_THREADS=OFF', 715 '-DLLVM_ENABLE_THREADS=OFF',
709 '-DCMAKE_C_FLAGS=' + ' '.join(cflags), 716 '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 RmCmakeCache('.') 825 RmCmakeCache('.')
819 RunCommand(['cmake'] + android_args + [COMPILER_RT_DIR]) 826 RunCommand(['cmake'] + android_args + [COMPILER_RT_DIR])
820 RunCommand(['ninja', 'libclang_rt.asan-%s-android.so' % target_arch]) 827 RunCommand(['ninja', 'libclang_rt.asan-%s-android.so' % target_arch])
821 828
822 # And copy it into the main build tree. 829 # And copy it into the main build tree.
823 runtime = 'libclang_rt.asan-%s-android.so' % target_arch 830 runtime = 'libclang_rt.asan-%s-android.so' % target_arch
824 for root, _, files in os.walk(build_dir): 831 for root, _, files in os.walk(build_dir):
825 if runtime in files: 832 if runtime in files:
826 shutil.copy(os.path.join(root, runtime), asan_rt_lib_dst_dir) 833 shutil.copy(os.path.join(root, runtime), asan_rt_lib_dst_dir)
827 834
835 if args.with_fuchsia:
836 # TODO(fuchsia): There's no aarch64 sysroot in the SDK yet.
837 for target_arch in ('x86_64',):
838 build_dir = os.path.join(LLVM_BUILD_DIR, 'fuchsia-' + target_arch)
839 if not os.path.exists(build_dir):
840 os.mkdir(os.path.join(build_dir))
841 os.chdir(build_dir)
842 sysroot = '%s/sysroot/%s-fuchsia' % (FUCHSIA_SDK_DIR, target_arch)
843 cflags = ['--target=%s-fuchsia' % target_arch,
844 '--sysroot=' + sysroot]
845 fuchsia_args = base_cmake_args + [
846 '-DLLVM_ENABLE_THREADS=OFF',
847 '-DCMAKE_C_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang'),
848 '-DCMAKE_CXX_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang'),
849 '-DCMAKE_C_COMPILER_WORKS=ON',
850 '-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON',
851 '-DCMAKE_C_COMPILER_TARGET=%s-fuchsia-none' % target_arch,
852 '-DCMAKE_CXX_COMPILER_WORKS=ON',
853 '-DLLVM_CONFIG_PATH=' + os.path.join(LLVM_BUILD_DIR, 'bin/llvm-config'),
854 '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
855 '-DCMAKE_CXX_FLAGS=' + ' '.join(cflags)]
856
857 RmCmakeCache('.')
858 RunCommand(['cmake'] + fuchsia_args + [COMPILER_RT_DIR])
859 RunCommand(['ninja', 'builtins'])
860
828 # Run tests. 861 # Run tests.
829 if args.run_tests or use_head_revision: 862 if args.run_tests or use_head_revision:
830 os.chdir(LLVM_BUILD_DIR) 863 os.chdir(LLVM_BUILD_DIR)
831 RunCommand(['ninja', 'cr-check-all'], msvc_arch='x64') 864 RunCommand(['ninja', 'cr-check-all'], msvc_arch='x64')
832 if args.run_tests: 865 if args.run_tests:
833 if sys.platform == 'win32': 866 if sys.platform == 'win32':
834 CopyDiaDllTo(os.path.join(LLVM_BUILD_DIR, 'bin')) 867 CopyDiaDllTo(os.path.join(LLVM_BUILD_DIR, 'bin'))
835 os.chdir(LLVM_BUILD_DIR) 868 os.chdir(LLVM_BUILD_DIR)
836 RunCommand(['ninja', 'check-all'], msvc_arch='x64') 869 RunCommand(['ninja', 'check-all'], msvc_arch='x64')
837 870
838 WriteStampFile(PACKAGE_VERSION) 871 WriteStampFile(PACKAGE_VERSION)
839 print 'Clang update was successful.' 872 print 'Clang update was successful.'
840 return 0 873 return 0
841 874
842 875
843 def main(): 876 def main():
844 parser = argparse.ArgumentParser(description='Build Clang.') 877 parser = argparse.ArgumentParser(description='Build Clang.')
845 parser.add_argument('--bootstrap', action='store_true', 878 parser.add_argument('--bootstrap', action='store_true',
846 help='first build clang with CC, then with itself.') 879 help='first build clang with CC, then with itself.')
847 parser.add_argument('--if-needed', action='store_true', 880 parser.add_argument('--if-needed', action='store_true',
848 help="run only if the script thinks clang is needed") 881 help="run only if the script thinks clang is needed")
849 parser.add_argument('--force-local-build', action='store_true', 882 parser.add_argument('--force-local-build', action='store_true',
850 help="don't try to download prebuild binaries") 883 help="don't try to download prebuilt binaries")
851 parser.add_argument('--gcc-toolchain', help='set the version for which gcc ' 884 parser.add_argument('--gcc-toolchain', help='set the version for which gcc '
852 'version be used for building; --gcc-toolchain=/opt/foo ' 885 'version be used for building; --gcc-toolchain=/opt/foo '
853 'picks /opt/foo/bin/gcc') 886 'picks /opt/foo/bin/gcc')
854 parser.add_argument('--lto-gold-plugin', action='store_true', 887 parser.add_argument('--lto-gold-plugin', action='store_true',
855 help='build LLVM Gold plugin with LTO') 888 help='build LLVM Gold plugin with LTO')
856 parser.add_argument('--llvm-force-head-revision', action='store_true', 889 parser.add_argument('--llvm-force-head-revision', action='store_true',
857 help=('use the revision in the repo when printing ' 890 help=('use the revision in the repo when printing '
858 'the revision')) 891 'the revision'))
859 parser.add_argument('--print-revision', action='store_true', 892 parser.add_argument('--print-revision', action='store_true',
860 help='print current clang revision and exit.') 893 help='print current clang revision and exit.')
861 parser.add_argument('--print-clang-version', action='store_true', 894 parser.add_argument('--print-clang-version', action='store_true',
862 help='print current clang version (e.g. x.y.z) and exit.') 895 help='print current clang version (e.g. x.y.z) and exit.')
863 parser.add_argument('--run-tests', action='store_true', 896 parser.add_argument('--run-tests', action='store_true',
864 help='run tests after building; only for local builds') 897 help='run tests after building; only for local builds')
865 parser.add_argument('--extra-tools', nargs='*', default=[], 898 parser.add_argument('--extra-tools', nargs='*', default=[],
866 help='select additional chrome tools to build') 899 help='select additional chrome tools to build')
867 parser.add_argument('--without-android', action='store_false', 900 parser.add_argument('--without-android', action='store_false',
868 help='don\'t build Android ASan runtime (linux only)', 901 help='don\'t build Android ASan runtime (linux only)',
869 dest='with_android', 902 dest='with_android',
870 default=sys.platform.startswith('linux')) 903 default=sys.platform.startswith('linux'))
904 parser.add_argument('--without-fuchsia', action='store_false',
905 help='don\'t build Fuchsia runtime (linux only)',
906 dest='with_fuchsia',
907 default=sys.platform.startswith('linux'))
871 args = parser.parse_args() 908 args = parser.parse_args()
872 909
873 if args.lto_gold_plugin and not args.bootstrap: 910 if args.lto_gold_plugin and not args.bootstrap:
874 print '--lto-gold-plugin requires --bootstrap' 911 print '--lto-gold-plugin requires --bootstrap'
875 return 1 912 return 1
876 if args.lto_gold_plugin and not sys.platform.startswith('linux'): 913 if args.lto_gold_plugin and not sys.platform.startswith('linux'):
877 print '--lto-gold-plugin is only effective on Linux. Ignoring the option.' 914 print '--lto-gold-plugin is only effective on Linux. Ignoring the option.'
878 args.lto_gold_plugin = False 915 args.lto_gold_plugin = False
879 916
880 if args.if_needed: 917 if args.if_needed:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 args.force_local_build = True 951 args.force_local_build = True
915 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''): 952 if 'OS=android' not in os.environ.get('GYP_DEFINES', ''):
916 # Only build the Android ASan rt on ToT bots when targetting Android. 953 # Only build the Android ASan rt on ToT bots when targetting Android.
917 args.with_android = False 954 args.with_android = False
918 955
919 return UpdateClang(args) 956 return UpdateClang(args)
920 957
921 958
922 if __name__ == '__main__': 959 if __name__ == '__main__':
923 sys.exit(main()) 960 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698