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

Unified Diff: tools/clang/scripts/update.py

Issue 2897463003: fuchsia libprofile wip
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/scripts/update.py
diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py
index 3571d3159462e951e913a72eb89ca1e4cba98652..725fd6a82505e1b545c489efd998767e22dd049b 100755
--- a/tools/clang/scripts/update.py
+++ b/tools/clang/scripts/update.py
@@ -27,7 +27,7 @@ import zipfile
# Do NOT CHANGE this if you don't know what you're doing -- see
# https://chromium.googlesource.com/chromium/src/+/master/docs/updating_clang.md
# Reverting problematic clang rolls is safe, though.
-CLANG_REVISION = '303369'
+CLANG_REVISION = '303370'
use_head_revision = 'LLVM_FORCE_HEAD_REVISION' in os.environ
if use_head_revision:
@@ -73,6 +73,7 @@ BFD_PLUGINS_DIR = os.path.join(BINUTILS_LIB_DIR, 'bfd-plugins')
VERSION = '5.0.0'
ANDROID_NDK_DIR = os.path.join(
CHROMIUM_DIR, 'third_party', 'android_tools', 'ndk')
+FUCHSIA_SDK_DIR = os.path.join(CHROMIUM_DIR, 'third_party', 'fuchsia-sdk')
# URL for pre-built binaries.
CDS_URL = os.environ.get('CDS_CLANG_BUCKET_OVERRIDE',
@@ -186,6 +187,7 @@ def RmTree(dir):
def RmCmakeCache(dir):
"""Delete CMake cache related files from dir."""
+ return
for dirpath, dirs, files in os.walk(dir):
if 'CMakeCache.txt' in files:
os.remove(os.path.join(dirpath, 'CMakeCache.txt'))
@@ -448,6 +450,16 @@ def UpdateClang(args):
print 'for how to install the NDK, or pass --without-android.'
return 1
+ if args.with_fuchsia and not os.path.exists(FUCHSIA_SDK_DIR):
+ print 'Fuchsia SDK not found at ' + FUCHSIA_SDK_DIR
+ print 'The Fuchsia SDK is needed to build libclang_rt for Fuchsia.'
+ print 'Install the Fuchsia SDK by adding fuchsia to the '
+ print 'target_os section in your .gclient and running hooks, '
+ print 'or pass --without-fuchsia.'
+ # TODO(thakis): Link to "chromium/fuchsia build instructions" page once it
+ # exists.
+ return 1
+
DownloadHostGcc(args)
AddCMakeToPath()
AddGnuWinToPath()
@@ -694,9 +706,9 @@ def UpdateClang(args):
# TODO(hans): Remove once the regular build above produces this.
# On Mac and Linux, this is used to get the regular 64-bit run-time.
# Do a clobbered build due to cmake changes.
- if os.path.isdir(COMPILER_RT_BUILD_DIR):
- RmTree(COMPILER_RT_BUILD_DIR)
- os.makedirs(COMPILER_RT_BUILD_DIR)
+ #if os.path.isdir(COMPILER_RT_BUILD_DIR):
+ #RmTree(COMPILER_RT_BUILD_DIR)
+ #os.makedirs(COMPILER_RT_BUILD_DIR)
os.chdir(COMPILER_RT_BUILD_DIR)
# TODO(thakis): Add this once compiler-rt can build with clang-cl (see
# above).
@@ -824,6 +836,43 @@ def UpdateClang(args):
for root, _, files in os.walk(build_dir):
if runtime in files:
shutil.copy(os.path.join(root, runtime), asan_rt_lib_dst_dir)
+ if args.with_fuchsia:
+ # Fuchsia links against libclang_rt.builtins-<arch>.a instead of libgcc.a.
+ for target_arch in ['aarch64', 'x86_64']:
+ toolchain_dir = os.path.join(
+ FUCHSIA_SDK_DIR, 'sysroot', '%s-fuchsia' % target_arch)
+ # Build clang_rt runtime for Fuchsia in a separate build tree.
+ build_dir = os.path.join(LLVM_BUILD_DIR, 'fuchsia-' + target_arch)
+ if not os.path.exists(build_dir):
+ os.mkdir(os.path.join(build_dir))
+ os.chdir(build_dir)
+ # TODO(thakis): Might have to pass -B here once sysroot contains
+ # binaries (e.g. gas for arm64?)
+ cflags = ['--target=%s-fuchsia' % target_arch,
+ '--sysroot=%s' % toolchain_dir]
+ ldflags = ['--sysroot=%s' % toolchain_dir]
+ fuchsia_args = base_cmake_args + [
+ '-DLLVM_ENABLE_THREADS=OFF',
+ '-DCMAKE_C_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang'),
+ '-DCMAKE_CXX_COMPILER=' + os.path.join(LLVM_BUILD_DIR, 'bin/clang++'),
+ '-DLLVM_CONFIG_PATH=' + os.path.join(LLVM_BUILD_DIR, 'bin/llvm-config'),
+ '-DCMAKE_C_FLAGS=' + ' '.join(cflags),
+ '-DCMAKE_CXX_FLAGS=' + ' '.join(cflags),
+ '-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(ldflags),
+ '-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(ldflags),
+ '-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(ldflags),
+ ]
+ RmCmakeCache('.')
+ RunCommand(['cmake'] + fuchsia_args + [COMPILER_RT_DIR])
+ RunCommand(['ninja', 'libclang_rt.builtins-%s.a' % target_arch])
+
+ # And copy it into the main build tree.
+ fuchsia_lib_dst_dir = os.path.join(LLVM_BUILD_DIR, 'lib', 'clang',
+ VERSION, 'lib', 'fuchsia')
+ runtime = 'libclang_rt.builtins-%s.a' % target_arch
+ for root, _, files in os.walk(build_dir):
+ if runtime in files:
+ shutil.copy(os.path.join(root, runtime), fuchsia_lib_dst_dir)
# Run tests.
if args.run_tests or use_head_revision:
@@ -868,6 +917,10 @@ def main():
help='don\'t build Android ASan runtime (linux only)',
dest='with_android',
default=sys.platform.startswith('linux'))
+ parser.add_argument('--without-fuchsia', action='store_false',
+ help='don\'t build Fuchsia clang_rt runtime (linux only)',
+ dest='with_fuchsia',
+ default=sys.platform.startswith('linux'))
args = parser.parse_args()
if args.lto_gold_plugin and not args.bootstrap:
@@ -915,6 +968,8 @@ def main():
if 'OS=android' not in os.environ.get('GYP_DEFINES', ''):
# Only build the Android ASan rt on ToT bots when targetting Android.
args.with_android = False
+ # Don't build fuchsia runtime on ToT bots at all.
+ args.with_fuchsia = False
return UpdateClang(args)
« 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