BUILD.bazel 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. """
  10. Defines configuration attributes for the systems we target.
  11. You can configure builds in Bazel using "configurable attributes" generally via
  12. the `select(...)` function. The following setting groups define the targets we
  13. support building Materialize for.
  14. """
  15. load("@bazel_skylib//lib:selects.bzl", "selects")
  16. load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
  17. # A flag that we can specify on the command line to configure whether or not we
  18. # build with a sanitizer.
  19. string_flag(
  20. name = "sanitizer",
  21. build_setting_default = "none",
  22. values = [
  23. "none",
  24. "address",
  25. "hwaddress",
  26. ],
  27. )
  28. config_setting(
  29. name = "sanitizer_none",
  30. flag_values = {":sanitizer": "none"},
  31. )
  32. config_setting(
  33. name = "sanitizer_address",
  34. flag_values = {":sanitizer": "address"},
  35. )
  36. config_setting(
  37. name = "sanitizer_hwaddress",
  38. flag_values = {":sanitizer": "hwaddress"},
  39. )
  40. bool_flag(
  41. name = "xlang_lto",
  42. build_setting_default = False,
  43. )
  44. config_setting(
  45. name = "use_xlang_lto",
  46. flag_values = {":xlang_lto": "True"},
  47. )
  48. # With our current toolchain setup, cross language LTO is only supported when building for Linux.
  49. #
  50. # See <https://github.com/rust-lang/rust/issues/60059> for macOS support.
  51. selects.config_setting_group(
  52. name = "xlang_lto_enabled",
  53. match_all = [
  54. "@platforms//os:linux",
  55. ":use_xlang_lto",
  56. # ASAN doesn't support being built when cross language LTO is enabled.
  57. ":sanitizer_none",
  58. ],
  59. visibility = ["//visibility:public"],
  60. )
  61. # We only want to use jemalloc if we're building for Linux and we're not using sanitizers.
  62. selects.config_setting_group(
  63. name = "use_jemalloc",
  64. match_all = [
  65. "@platforms//os:linux",
  66. ":sanitizer_none",
  67. ],
  68. visibility = ["//visibility:public"],
  69. )
  70. selects.config_setting_group(
  71. name = "linux_x86_64",
  72. match_all = [
  73. "@platforms//os:linux",
  74. "@platforms//cpu:x86_64",
  75. ],
  76. visibility = ["//visibility:public"],
  77. )
  78. selects.config_setting_group(
  79. name = "linux_arm",
  80. match_all = [
  81. "@platforms//os:linux",
  82. "@platforms//cpu:arm64",
  83. ],
  84. visibility = ["//visibility:public"],
  85. )
  86. selects.config_setting_group(
  87. name = "macos_x86_64",
  88. match_all = [
  89. "@platforms//os:macos",
  90. "@platforms//cpu:x86_64",
  91. ],
  92. visibility = ["//visibility:public"],
  93. )
  94. selects.config_setting_group(
  95. name = "macos_arm",
  96. match_all = [
  97. "@platforms//os:macos",
  98. "@platforms//cpu:arm64",
  99. ],
  100. visibility = ["//visibility:public"],
  101. )