Add backtrace dependency for libafl crate usage

Due to the size of crrev.com/c/7564051, this CL works to split all of
the unsafe dependencies into separate CLs for individual review. The end
goal is to have all unsafe transitive dependencies for libafl imported
and reviewed prior to importing the remaining dependencies (including
libafl). We have approval for importing libafl by Chrome TSCs/ATLs (see
https://groups.google.com/a/google.com/g/chrome-tsc-discuss/c/jvyNkbHOLhM).

The backtrace crate has also been marked as `group = test` and
`allow_first_party_usage = false`.

Bug: 495772162
Change-Id: I973207bf387bcdd1ba497226da7a76d7fc683bcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7697596
Reviewed-by: Ɓukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Antonio Alphonse <alphonsea@google.com>
Cr-Commit-Position: refs/heads/main@{#1609463}
NOKEYCHECK=True
GitOrigin-RevId: 3b101ccecc71a7743783e7a68b8fc7113b1accc1
251 files changed
tree: 2314328aa56573ad033cf00ea392520c883f3f1b
  1. addr2line/
  2. adler2/
  3. ahash/
  4. aho_corasick/
  5. android_system_properties/
  6. anstyle/
  7. antlr4rust/
  8. anyhow/
  9. arbitrary_int/
  10. array_init/
  11. arrayvec/
  12. autocfg/
  13. backtrace/
  14. base64/
  15. better_any/
  16. bit_set/
  17. bit_vec/
  18. bitflags/
  19. bytemuck/
  20. bytemuck_derive/
  21. byteorder/
  22. byteorder_lite/
  23. bytes/
  24. calendrical_calculations/
  25. cc/
  26. cfg_if/
  27. chromium_crates_io/
  28. chrono/
  29. clap/
  30. clap_builder/
  31. clap_lex/
  32. codespan_reporting/
  33. core_foundation_sys/
  34. core_maths/
  35. crc32fast/
  36. cxx/
  37. cxxbridge_cmd/
  38. cxxbridge_flags/
  39. cxxbridge_macro/
  40. derivre/
  41. diplomat/
  42. diplomat_core/
  43. diplomat_runtime/
  44. displaydoc/
  45. either/
  46. encoding_rs/
  47. equivalent/
  48. fdeflate/
  49. fend_core/
  50. fixed_decimal/
  51. flate2/
  52. foldhash/
  53. font_types/
  54. getrandom/
  55. gimli/
  56. hashbrown/
  57. heck/
  58. hex/
  59. hmac_sha256/
  60. iana_time_zone/
  61. icu_calendar/
  62. icu_calendar_data/
  63. icu_casemap/
  64. icu_casemap_data/
  65. icu_collections/
  66. icu_decimal/
  67. icu_decimal_data/
  68. icu_experimental/
  69. icu_experimental_data/
  70. icu_list/
  71. icu_list_data/
  72. icu_locale/
  73. icu_locale_core/
  74. icu_locale_data/
  75. icu_normalizer/
  76. icu_normalizer_data/
  77. icu_pattern/
  78. icu_plurals/
  79. icu_plurals_data/
  80. icu_properties/
  81. icu_properties_data/
  82. icu_provider/
  83. icu_time/
  84. image/
  85. indexmap/
  86. itertools/
  87. itoa/
  88. ixdtf/
  89. jiff_tzdb/
  90. jxl/
  91. jxl_macros/
  92. jxl_simd/
  93. jxl_transforms/
  94. lazy_static/
  95. libc/
  96. libm/
  97. litemap/
  98. llguidance/
  99. lock_api/
  100. log/
  101. memchr/
  102. memo_map/
  103. minijinja/
  104. miniz_oxide/
  105. moxcms/
  106. murmur3/
  107. num_bigint/
  108. num_derive/
  109. num_integer/
  110. num_rational/
  111. num_traits/
  112. object/
  113. once_cell/
  114. opusic_sys/
  115. ordered_float/
  116. parking_lot/
  117. parking_lot_core/
  118. png/
  119. potential_utf/
  120. proc_macro2/
  121. proc_macro_error2/
  122. proc_macro_error_attr2/
  123. prost/
  124. prost_derive/
  125. pxfm/
  126. qr_code/
  127. quote/
  128. read_fonts/
  129. regex_automata/
  130. regex_syntax/
  131. resb/
  132. rustc_demangle/
  133. rustc_demangle_capi/
  134. rustversion/
  135. ryu/
  136. scopeguard/
  137. serde/
  138. serde_core/
  139. serde_derive/
  140. serde_json/
  141. serde_json_lenient/
  142. simd_adler32/
  143. skrifa/
  144. small_ctor/
  145. smallvec/
  146. src/
  147. stable_deref_trait/
  148. static_assertions/
  149. strck/
  150. strsim/
  151. strum/
  152. strum_macros/
  153. subtle/
  154. symphonia/
  155. symphonia_adapter_libopus/
  156. symphonia_bundle_flac/
  157. symphonia_bundle_mp3/
  158. symphonia_codec_pcm/
  159. symphonia_codec_vorbis/
  160. symphonia_core/
  161. symphonia_metadata/
  162. symphonia_utils_xiph/
  163. syn/
  164. synstructure/
  165. temporal_capi/
  166. temporal_rs/
  167. termcolor/
  168. thiserror/
  169. thiserror_impl/
  170. timezone_provider/
  171. tinystr/
  172. toktrie/
  173. typed_arena/
  174. typed_path/
  175. tzif/
  176. unicode_ident/
  177. unicode_width/
  178. utf8_iter/
  179. uuid/
  180. version_check/
  181. winapi_util/
  182. windows_aarch64_msvc/
  183. windows_i686_msvc/
  184. windows_link/
  185. windows_sys/
  186. windows_targets/
  187. windows_x86_64_msvc/
  188. writeable/
  189. xml/
  190. yoke/
  191. yoke_derive/
  192. zerocopy/
  193. zerofrom/
  194. zerofrom_derive/
  195. zerotrie/
  196. zerovec/
  197. zerovec_derive/
  198. zip/
  199. zmij/
  200. zoneinfo64/
  201. .clang-format
  202. DEPS
  203. OWNERS
  204. OWNERS-review-checklist.md
  205. PRESUBMIT.py
  206. README-importing-new-crates.md
  207. README.md
README.md

Rust third-party code

This directory contains third-party Rust libraries from https://crates.io (and sometimes thin wrappers around them for Chromium interop).

gnrt: Cargo.toml => vendor + BUILD.gn + README.chromium

Third-party libraries from crates.io, depend on Cargo as a build system. Chromium uses gnrt tool to automate

  • Vendoring crates sources into Chromium repository
  • Generating BUILD.gn and README.chromium files based on crate's Cargo.toml.

The tool can be found in //tools/crates/gnrt and is typically invoked using //tools/crates/run_gnrt.py.

Directory structure for third-party crates

The directory structure for a crate “foo” version 3.4.2 is:

//third_party/
    rust/
        foo/
            wrapper/             (optional FFI glue or Chromium integration)
            v3/                  (version 3.4.2 maps to the v3 epoch)
                BUILD.gn         (generated by gnrt gen)
                README.chromium  (generated by gnrt vendor)
        chromium_crates_io/
            vendor/
                foo-v3/  (sources downloaded from crates.io by gnrt vendor)
            patches/
                foo-v3/  (patches automatically applied during gnrt vendor)
                    0001-Some-changes.diff
                    0002-Other-changes.diff
            Cargo.toml        (version and enabled features of "foo")
            Cargo.lock
            gnrt_config.toml  (additional configuration of "foo")

TODO(https://crbug.com/417250983): Patch directory should be epoch-specific.

Most of the files above are managed automatically by gnrt. The only “foo”-specific manually-authored files and directories are:

There are also other, non-crate-specific files such as:

  • //third_party/rust:
    • .md - this doc and other docs
    • OWNERS, PRESUBMIT.py
  • //third_party/rust/chromium_crates_io:
    • BUILD.gn.hbs - template for BUILD.gn files
    • README.chromium.hbs - template for README.chromium files
    • PRESUBMIT.py
    • .py helper scripts used by PRESUBMIT.py and by //tools/crates.
    • Somewhat obsolete cargo vet-support items - we keep supply-chain/audits.toml to preserve Chromium audits that are imported into https://github.com/google/rust-crate-audits/blob/main/sources.list)
    • Various infrastructure pieces to disable auto-formatting of the vendored files (e.g. .gitattributes, .rustfmt.toml, .style.yapf, etc.)

Importing new third-party crates

See //third_party/rust/README-importing-new-crates.md for instructions on how to import a crate from https://crates.io into Chromium.

Updating existing third-party crates

Third-party crates will get updated semi-automatically through the process described in ../tools/crates/create_update_cl.md. If you nevertheless need to manually update a crate to its latest minor or major version, then follow the steps below. To facilitate easier review, we recommend uploading separate patchsets for 1) manual changes, and 2) tool-driven, automated changes.

  1. Change directory to the root src/ dir of Chromium.
  2. Update the versions in //third_party/rust/chromium_crates_io/Cargo.toml.
    • vpython3 ./tools/crates/run_gnrt.py update <crate name>.
    • Under the hood this invokes cargo update and accepts the same command line parameters. In particular, you may need to specify --breaking when working on major version updates.
  3. Download any updated crate's files:
    • ./tools/crates/run_gnrt.py vendor
  4. Add the downloaded files to git:
    • git add -f third_party/rust/chromium_crates_io/vendor
    • The -f is important, as files may be skipped otherwise from a .gitignore inside the crate.
  5. Generate the BUILD.gn files
    • vpython3 ./tools/crates/run_gnrt.py gen
    • Or, directly through (nightly) cargo: cargo run --release --manifest-path tools/crates/gnrt/Cargo.toml --target-dir out/gnrt gen
  6. Add the generated files to git:
    • git add third_party/rust

Writing a wrapper for binding generation

Most Rust libraries will need a more C++-friendly API written on top of them in order to generate C++ bindings to them. The wrapper library can be placed in //third_party/rust/<cratename>/wrapper or at another single place that all C++ goes through to access the library. The CXX is used to generate bindings between C++ and Rust.

See //third_party/rust/serde_json_lenient/v0_1/wrapper/ and //components/qr_code_generator for examples.

See //docs/rust-ffi.md for information on C++/Rust FFI.