Bug 1540082 - add support for extra runtime targets in build-clang.py; r=firefox-build-system-reviewers,chmanchester
authorNathan Froyd <froydnj@mozilla.com>
Tue, 23 Apr 2019 19:45:06 +0000
changeset 530208 9f95b1b2f9e11690859f415e0ceceba7b0e5b403
parent 530207 27527aa560046fe68ccacfc96e5580351b4b51e7
child 530209 6cbad9f5b259fb156e93d30a66298fd2a93ae46b
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfirefox-build-system-reviewers, chmanchester
bugs1540082
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1540082 - add support for extra runtime targets in build-clang.py; r=firefox-build-system-reviewers,chmanchester This change enables us to build compiler-rt and related libraries (e.g. address sanitizer, etc.) for whatever targets we like, assuming that we have an accessible sysroot for the target on the build machine. Depends on D28404 Differential Revision: https://phabricator.services.mozilla.com/D28405
build/build-clang/build-clang.py
--- a/build/build-clang/build-clang.py
+++ b/build/build-clang/build-clang.py
@@ -218,18 +218,19 @@ def is_windows():
 
 
 def build_one_stage(cc, cxx, asm, ld, ar, ranlib, libtool,
                     src_dir, stage_dir, package_name, build_libcxx,
                     osx_cross_compile, build_type, assertions,
                     python_path, gcc_dir, libcxx_include_dir,
                     compiler_rt_source_dir=None, runtimes_source_link=None,
                     compiler_rt_source_link=None,
-                    is_final_stage=False, android_targets=None):
-    if is_final_stage and android_targets:
+                    is_final_stage=False, android_targets=None,
+                    extra_targets=None):
+    if is_final_stage and (android_targets or extra_targets):
         # Linking compiler-rt under "runtimes" activates LLVM_RUNTIME_TARGETS
         # and related arguments.
         symlink(compiler_rt_source_dir, runtimes_source_link)
         try:
             os.unlink(compiler_rt_source_link)
         except Exception:
             pass
 
@@ -298,16 +299,18 @@ def build_one_stage(cc, cxx, asm, ld, ar
         return cmake_args
 
     cmake_args = []
 
     runtime_targets = []
     if is_final_stage:
         if android_targets:
             runtime_targets = list(sorted(android_targets.keys()))
+        if extra_targets:
+            runtime_targets.extend(sorted(extra_targets))
 
     if runtime_targets:
         cmake_args += [
             "-DLLVM_BUILTIN_TARGETS=%s" % ";".join(runtime_targets),
             "-DLLVM_RUNTIME_TARGETS=%s" % ";".join(runtime_targets),
         ]
 
         for target in runtime_targets:
@@ -654,16 +657,23 @@ if __name__ == "__main__":
     android_targets = None
     if "android_targets" in config:
         android_targets = config["android_targets"]
         for attr in ("ndk_toolchain", "ndk_sysroot", "ndk_includes", "api_level"):
             for target, cfg in android_targets.iteritems():
                 if attr not in cfg:
                     raise ValueError("must specify '%s' as a key for android target: %s" %
                                      (attr, target))
+    extra_targets = None
+    if "extra_targets" in config:
+        extra_targets = config["extra_targets"]
+        if not isinstance(extra_targets, list):
+            raise ValueError("extra_targets must be a list")
+        if not all(isinstance(t, (str, unicode)) for t in extra_targets):
+            raise ValueError("members of extra_targets should be strings")
     if is_linux() and gcc_dir is None:
         raise ValueError("Config file needs to set gcc_dir")
     cc = get_tool(config, "cc")
     cxx = get_tool(config, "cxx")
     asm = get_tool(config, "ml" if is_windows() else "as")
     ld = get_tool(config, "link" if is_windows() else "ld")
     ar = get_tool(config, "lib" if is_windows() else "ar")
     ranlib = None if is_windows() else get_tool(config, "ranlib")
@@ -813,34 +823,35 @@ if __name__ == "__main__":
                 (cxx_name, exe_ext)] + extra_cxxflags2,
             [stage1_inst_dir + "/bin/%s%s" %
                 (cc_name, exe_ext)] + extra_asmflags,
             [ld] + extra_ldflags,
             ar, ranlib, libtool,
             llvm_source_dir, stage2_dir, package_name, build_libcxx, osx_cross_compile,
             build_type, assertions, python_path, gcc_dir, libcxx_include_dir,
             compiler_rt_source_dir, runtimes_source_link, compiler_rt_source_link,
-            is_final_stage=(stages == 2), android_targets=android_targets)
+            is_final_stage=(stages == 2), android_targets=android_targets,
+            extra_targets=extra_targets)
 
     if stages > 2:
         stage3_dir = build_dir + '/stage3'
         final_stage_dir = stage3_dir
         build_one_stage(
             [stage2_inst_dir + "/bin/%s%s" %
                 (cc_name, exe_ext)] + extra_cflags2,
             [stage2_inst_dir + "/bin/%s%s" %
                 (cxx_name, exe_ext)] + extra_cxxflags2,
             [stage2_inst_dir + "/bin/%s%s" %
                 (cc_name, exe_ext)] + extra_asmflags,
             [ld] + extra_ldflags,
             ar, ranlib, libtool,
             llvm_source_dir, stage3_dir, package_name, build_libcxx, osx_cross_compile,
             build_type, assertions, python_path, gcc_dir, libcxx_include_dir,
             compiler_rt_source_dir, runtimes_source_link, compiler_rt_source_link,
-            (stages == 3))
+            (stages == 3), extra_targets=extra_targets)
 
     if build_clang_tidy:
         prune_final_dir_for_clang_tidy(os.path.join(final_stage_dir, package_name),
                                        osx_cross_compile)
 
     if not args.skip_tar:
         ext = "bz2" if is_darwin() or is_windows() else "xz"
         build_tar_package("tar", "%s.tar.%s" % (package_name, ext), final_stage_dir, package_name)