v8-non-pointer-compression.bzl 2.4 KB

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