tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

clang_exception.star (4553B)


      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 """workaround for exceptional clang actions. e.g. exit=137 (OOM?),
      6  or DeadlineExceeded.
      7 """
      8 
      9 load("@builtin//runtime.star", "runtime")
     10 load("@builtin//struct.star", "module")
     11 
     12 def __step_config(ctx, step_config):
     13     exceptions = [
     14         {
     15             # TODO: crbug.com/380755128 - Make each compile unit smaller.
     16             "name": "fuzzer_large_compile",
     17             "action_outs": [
     18                 # keep-sorted start
     19                 "./obj/chrome/test/fuzzing/htmlfuzzer_proto_gen/htmlfuzzer_sub.pb.o",
     20                 "./obj/chrome/test/fuzzing/jsfuzzer/jsfuzzer.o",
     21                 "./obj/chrome/test/fuzzing/jsfuzzer_proto_gen/jsfuzzer.pb.o",
     22                 "./obj/chrome/test/fuzzing/jsfuzzer_proto_gen/jsfuzzer_sub.pb.o",
     23                 "./obj/chrome/test/fuzzing/renderer_fuzzing/renderer_in_process_mojolpm_fuzzer/renderer_in_process_mojolpm_fuzzer.o",
     24                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidl_fuzzer_grammar/webidl_fuzzer_grammar.o",
     25                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidl_fuzzer_grammar_proto_gen/webidl_fuzzer_grammar.pb.o",
     26                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidl_in_process_fuzzer/webidl_in_process_fuzzer.o",
     27                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer/webidlfuzzer.o",
     28                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer/webidlfuzzer_sub0.o",
     29                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer/webidlfuzzer_sub9.o",
     30                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer.pb.o",
     31                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub0.pb.o",
     32                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub1.pb.o",
     33                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub10.pb.o",
     34                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub11.pb.o",
     35                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub2.pb.o",
     36                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub3.pb.o",
     37                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub4.pb.o",
     38                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub5.pb.o",
     39                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub6.pb.o",
     40                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub7.pb.o",
     41                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub8.pb.o",
     42                 "./obj/chrome/test/fuzzing/webidl_fuzzing/webidlfuzzer_proto_gen/webidlfuzzer_sub9.pb.o",
     43                 # keep-sorted end
     44             ],
     45             "timeout": "15m",
     46             # need 9G for debug build
     47             "use_large": True,
     48         },
     49     ]
     50     new_rules = []
     51     for rule in step_config["rules"]:
     52         if not rule["name"].endswith("/cxx"):
     53             new_rules.append(rule)
     54             continue
     55         if "action_outs" in rule:
     56             fail("unexpeced \"action_outs\" in cxx rule %s" % rule["name"])
     57         for ex in exceptions:
     58             r = {}
     59             r.update(rule)
     60             r["name"] += "/exception/" + ex["name"]
     61             outs = ex["action_outs"]
     62             if runtime.os == "windows":
     63                 outs = [obj.removesuffix(".o") + ".obj" for obj in outs if obj.startswith("./obj/")]
     64             r["action_outs"] = outs
     65             if "timeout" in ex:
     66                 r["timeout"] = ex["timeout"]
     67             if "use_large" in ex and ex["use_large"]:
     68                 # use `_large` variant of platform if it doesn't use default platform,
     69                 # i.e. mac/win case.
     70                 if "platform_ref" in r:
     71                     r["platform_ref"] = r["platform_ref"] + "_large"
     72                 else:
     73                     r["platform_ref"] = "large"
     74             if r.get("handler") == "rewrite_rewrapper":
     75                 r["handler"] = "rewrite_rewrapper_large"
     76             new_rules.append(r)
     77         new_rules.append(rule)
     78     step_config["rules"] = new_rules
     79     return step_config
     80 
     81 clang_exception = module(
     82     "clang_exception",
     83     step_config = __step_config,
     84 )