1# -*- bazel-starlark -*- 2# Copyright 2023 The Chromium Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5"""Siso configuration for clang-cl/windows.""" 6 7load("@builtin//lib/gn.star", "gn") 8load("@builtin//struct.star", "module") 9load("./clang_all.star", "clang_all") 10load("./clang_code_coverage_wrapper.star", "clang_code_coverage_wrapper") 11load("./config.star", "config") 12load("./gn_logs.star", "gn_logs") 13load("./reproxy.star", "reproxy") 14load("./rewrapper_cfg.star", "rewrapper_cfg") 15load("./win_sdk.star", "win_sdk") 16 17def __filegroups(ctx): 18 fg = {} 19 fg.update(win_sdk.filegroups(ctx)) 20 fg.update(clang_all.filegroups(ctx)) 21 return fg 22 23def __clang_compile_coverage(ctx, cmd): 24 clang_command = clang_code_coverage_wrapper.run(ctx, list(cmd.args)) 25 ctx.actions.fix(args = clang_command) 26 27__handlers = { 28 "clang_compile_coverage": __clang_compile_coverage, 29} 30__handlers.update(clang_all.handlers) 31 32def __step_config(ctx, step_config): 33 cfg = "buildtools/reclient_cfgs/chromium-browser-clang/rewrapper_windows.cfg" 34 if ctx.fs.exists(cfg): 35 reproxy_config = rewrapper_cfg.parse(ctx, cfg) 36 largePlatform = {} 37 for k, v in reproxy_config["platform"].items(): 38 if k.startswith("label:action"): 39 continue 40 largePlatform[k] = v 41 42 # no "action_large" Windows worker pool 43 windowsWorker = True 44 if reproxy_config["platform"]["OSFamily"] != "Windows": 45 largePlatform["label:action_large"] = "1" 46 windowsWorker = False 47 step_config["platforms"].update({ 48 "clang-cl": reproxy_config["platform"], 49 "clang-cl_large": largePlatform, 50 "lld-link": largePlatform, 51 }) 52 step_config["input_deps"].update(clang_all.input_deps) 53 54 # when win_toolchain_dir is unknown (e.g. 55 # missing build/win_toolchain.json), we can't run 56 # clang-cl remotely as we can find sysroot files 57 # under exec_root, so just run locally. 58 # When building with ToT Clang, we can't run clang-cl 59 # remotely, too. 60 remote = False 61 win_toolchain_dir = win_sdk.toolchain_dir(ctx) 62 if win_toolchain_dir: 63 remote = True 64 if reproxy_config["platform"]["OSFamily"] == "Windows": 65 step_config["input_deps"].update({ 66 win_toolchain_dir + ":headers": [ 67 win_toolchain_dir + ":headers-ci", 68 ], 69 }) 70 else: 71 win_sdk.step_config(ctx, step_config) 72 remote_wrapper = reproxy_config.get("remote_wrapper") 73 input_root_absolute_path = gn_logs.read(ctx).get("clang_need_input_root_absolute_path") == "true" 74 canonicalize_dir = not input_root_absolute_path 75 76 timeout = "2m" 77 if (not reproxy.enabled(ctx)) and windowsWorker: 78 # use longer timeout for siso native 79 # it takes long time for input fetch (many files in sysroot etc) 80 timeout = "4m" 81 82 step_config["rules"].extend([ 83 { 84 "name": "clang-cl/cxx", 85 "action": "(.*_)?cxx", 86 "command_prefix": "..\\..\\third_party\\llvm-build\\Release+Asserts\\bin\\clang-cl.exe", 87 "inputs": [ 88 "third_party/llvm-build/Release+Asserts/bin/clang-cl.exe", 89 ], 90 "platform_ref": "clang-cl", 91 "remote": remote, 92 "input_root_absolute_path": input_root_absolute_path, 93 "canonicalize_dir": canonicalize_dir, 94 "remote_wrapper": remote_wrapper, 95 "timeout": timeout, 96 }, 97 { 98 "name": "clang-cl/cc", 99 "action": "(.*_)?cc", 100 "command_prefix": "..\\..\\third_party\\llvm-build\\Release+Asserts\\bin\\clang-cl.exe", 101 "inputs": [ 102 "third_party/llvm-build/Release+Asserts/bin/clang-cl.exe", 103 ], 104 "platform_ref": "clang-cl", 105 "remote": remote, 106 "input_root_absolute_path": input_root_absolute_path, 107 "canonicalize_dir": canonicalize_dir, 108 "remote_wrapper": remote_wrapper, 109 "timeout": timeout, 110 }, 111 { 112 "name": "clang-coverage/cxx", 113 "action": "(.*_)?cxx", 114 "command_prefix": "python3.exe ../../build/toolchain/clang_code_coverage_wrapper.py", 115 "inputs": [ 116 "third_party/llvm-build/Release+Asserts/bin/clang++", 117 ], 118 "handler": "clang_compile_coverage", 119 "platform_ref": "clang-cl", 120 "remote": remote, 121 "input_root_absolute_path": input_root_absolute_path, 122 "canonicalize_dir": canonicalize_dir, 123 "remote_wrapper": remote_wrapper, 124 "timeout": timeout, 125 }, 126 { 127 "name": "clang-coverage/cc", 128 "action": "(.*_)?cc", 129 "command_prefix": "python3.exe ../../build/toolchain/clang_code_coverage_wrapper.py", 130 "inputs": [ 131 "third_party/llvm-build/Release+Asserts/bin/clang", 132 ], 133 "handler": "clang_compile_coverage", 134 "platform_ref": "clang-cl", 135 "remote": remote, 136 "input_root_absolute_path": input_root_absolute_path, 137 "canonicalize_dir": canonicalize_dir, 138 "remote_wrapper": remote_wrapper, 139 "timeout": timeout, 140 }, 141 { 142 "name": "lld-link/alink", 143 "action": "(.*_)?alink", 144 "command_prefix": "..\\..\\third_party\\llvm-build\\Release+Asserts\\bin\\lld-link.exe /lib", 145 "handler": "lld_thin_archive", 146 "remote": False, 147 "accumulate": True, 148 }, 149 { 150 "name": "lld-link/solink", 151 "action": "(.*_)?solink", 152 "command_prefix": "..\\..\\third_party\\llvm-build\\Release+Asserts\\bin\\lld-link.exe", 153 "handler": "lld_link", 154 "inputs": [ 155 "third_party/llvm-build/Release+Asserts/bin/lld-link.exe", 156 win_sdk.toolchain_dir(ctx) + ":libs", 157 ], 158 "exclude_input_patterns": [ 159 "*.cc", 160 "*.h", 161 "*.js", 162 "*.pak", 163 "*.py", 164 ], 165 "remote": config.get(ctx, "remote-link"), 166 "remote_wrapper": remote_wrapper, 167 "platform_ref": "lld-link", 168 "input_root_absolute_path": input_root_absolute_path, 169 "canonicalize_dir": canonicalize_dir, 170 "timeout": "2m", 171 }, 172 { 173 "name": "lld-link/solink_module", 174 "action": "(.*_)?solink_module", 175 "command_prefix": "..\\..\\third_party\\llvm-build\\Release+Asserts\\bin\\lld-link.exe", 176 "handler": "lld_link", 177 "inputs": [ 178 "third_party/llvm-build/Release+Asserts/bin/lld-link.exe", 179 win_sdk.toolchain_dir(ctx) + ":libs", 180 ], 181 "exclude_input_patterns": [ 182 "*.cc", 183 "*.h", 184 "*.js", 185 "*.pak", 186 "*.py", 187 ], 188 "remote": config.get(ctx, "remote-link"), 189 "remote_wrapper": remote_wrapper, 190 "platform_ref": "lld-link", 191 "input_root_absolute_path": input_root_absolute_path, 192 "canonicalize_dir": canonicalize_dir, 193 "timeout": "2m", 194 }, 195 { 196 "name": "lld-link/link", 197 "action": "(.*_)?link", 198 "command_prefix": "..\\..\\third_party\\llvm-build\\Release+Asserts\\bin\\lld-link.exe", 199 "handler": "lld_link", 200 "inputs": [ 201 "third_party/llvm-build/Release+Asserts/bin/lld-link.exe", 202 win_sdk.toolchain_dir(ctx) + ":libs", 203 ], 204 "exclude_input_patterns": [ 205 "*.cc", 206 "*.h", 207 "*.js", 208 "*.pak", 209 "*.py", 210 ], 211 "remote": config.get(ctx, "remote-link"), 212 "remote_wrapper": remote_wrapper, 213 "platform_ref": "lld-link", 214 "input_root_absolute_path": input_root_absolute_path, 215 "canonicalize_dir": canonicalize_dir, 216 "timeout": "2m", 217 }, 218 ]) 219 elif gn.args(ctx).get("use_remoteexec") == "true": 220 fail("remoteexec requires rewrapper config") 221 return step_config 222 223clang = module( 224 "clang", 225 step_config = __step_config, 226 filegroups = __filegroups, 227 handlers = __handlers, 228) 229