1def _v8_disable_pointer_compression(settings, attr): 2 return { 3 "//:v8_enable_pointer_compression": "False", 4 } 5 6v8_disable_pointer_compression = transition( 7 implementation = _v8_disable_pointer_compression, 8 inputs = [], 9 outputs = ["//:v8_enable_pointer_compression"], 10) 11 12# The implementation of transition_rule: all this does is copy the 13# cc_binary's output to its own output and propagate its runfiles 14# and executable to use for "$ bazel run". 15# 16# This makes transition_rule as close to a pure wrapper of cc_binary 17# as possible. 18def _v8_binary_non_pointer_compression(ctx): 19 binary = ctx.attr.binary[0] 20 outfile = ctx.actions.declare_file(ctx.label.name) 21 cc_binary_outfile = binary[DefaultInfo].files.to_list()[0] 22 23 ctx.actions.run_shell( 24 inputs = [cc_binary_outfile], 25 outputs = [outfile], 26 command = "cp %s %s" % (cc_binary_outfile.path, outfile.path), 27 ) 28 return [ 29 DefaultInfo( 30 executable = outfile, 31 data_runfiles = binary[DefaultInfo].data_runfiles, 32 ), 33 ] 34 35# The purpose of this rule is to transition to a config where v8_target_cpu is 36# set to the appropriate architecture, which will remain in place through exec 37# transitions, so mksnapshot can for instance build on x64 but for arm64. 38v8_binary_non_pointer_compression = rule( 39 implementation = _v8_binary_non_pointer_compression, 40 attrs = { 41 # This is the cc_binary whose deps will select() on that feature. 42 # Note specificaly how it's configured with v8_target_cpu_transition, which 43 # ensures that setting propagates down the graph. 44 "binary": attr.label(cfg = v8_disable_pointer_compression), 45 # This is a stock Bazel requirement for any rule that uses Starlark 46 # transitions. It's okay to copy the below verbatim for all such rules. 47 # 48 # The purpose of this requirement is to give the ability to restrict 49 # which packages can invoke these rules, since Starlark transitions 50 # make much larger graphs possible that can have memory and performance 51 # consequences for your build. The whitelist defaults to "everything". 52 # But you can redefine it more strictly if you feel that's prudent. 53 "_allowlist_function_transition": attr.label( 54 default = "@bazel_tools//tools/allowlists/function_transition_allowlist", 55 ), 56 }, 57 # Making this executable means it works with "$ bazel run". 58 executable = True, 59) 60