summaryrefslogtreecommitdiff
path: root/www/chromium/files/patch-build_rust_std_BUILD.gn
blob: c6c2801bd47d663f1be536bc26c3085b2ae00a65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
--- build/rust/std/BUILD.gn.orig	2025-05-20 09:16:26 UTC
+++ build/rust/std/BUILD.gn
@@ -15,51 +15,12 @@
 # allocator functions to PartitionAlloc when `use_partition_alloc_as_malloc` is
 # true, so that Rust and C++ use the same allocator backend.
 
-import("//build/buildflag_header.gni")
 import("//build/config/compiler/compiler.gni")
 import("//build/config/coverage/coverage.gni")
 import("//build/config/rust.gni")
 import("//build/config/sanitizers/sanitizers.gni")
 
-rust_allocator_uses_partition_alloc = false
-if (build_with_chromium) {
-  import("//base/allocator/partition_allocator/partition_alloc.gni")
-  rust_allocator_uses_partition_alloc = use_partition_alloc_as_malloc
-}
-
-buildflag_header("buildflags") {
-  header = "buildflags.h"
-  flags = [
-    "RUST_ALLOCATOR_USES_PARTITION_ALLOC=$rust_allocator_uses_partition_alloc",
-  ]
-  visibility = [ ":*" ]
-}
-
 if (toolchain_has_rust) {
-  # If clang performs the link step, we need to provide the allocator symbols
-  # that are normally injected by rustc during linking.
-  #
-  # We also "happen to" use this to redirect allocations to PartitionAlloc,
-  # though that would be better done through a #[global_allocator] crate (see
-  # above).
-  source_set("remap_alloc") {
-    public_deps = []
-    if (rust_allocator_uses_partition_alloc) {
-      public_deps += [ "//base/allocator/partition_allocator:partition_alloc" ]
-    }
-    deps = [ ":buildflags" ]
-    sources = [
-      # `alias.*`, `compiler_specific.h`, and `immediate_crash.*` have been
-      # copied from `//base`.
-      # TODO(crbug.com/40279749): Avoid duplication / reuse code.
-      "alias.cc",
-      "alias.h",
-      "compiler_specific.h",
-      "immediate_crash.h",
-      "remap_alloc.cc",
-    ]
-  }
-
   # List of Rust stdlib rlibs which are present in the official Rust toolchain
   # we are using from the Android team. This is usually a version or two behind
   # nightly. Generally this matches the toolchain we build ourselves, but if
@@ -89,13 +50,20 @@ if (toolchain_has_rust) {
     # These are no longer present in the Windows toolchain.
     stdlib_files += [
       "addr2line",
-      "adler2",
       "gimli",
       "libc",
       "memchr",
       "miniz_oxide",
       "object",
     ]
+
+    rust_revision_pieces = string_split(rustc_revision, " ")
+    rust_version_pieces = string_split(rust_revision_pieces[1], ".")
+    if (rust_version_pieces[1] == "85") {
+      stdlib_files += [ "adler" ]
+    } else {
+      stdlib_files += [ "adler2" ]
+    }
   }
 
   if (toolchain_for_rust_host_build_tools) {
@@ -115,7 +83,6 @@ if (toolchain_has_rust) {
   # don't need to pass to the C++ linker because they're used for specialized
   # purposes.
   skip_stdlib_files = [
-    "profiler_builtins",
     "rustc_std_workspace_alloc",
     "rustc_std_workspace_core",
     "rustc_std_workspace_std",
@@ -269,8 +236,6 @@ if (toolchain_has_rust) {
       foreach(libname, stdlib_files + skip_stdlib_files) {
         deps += [ "rules:$libname" ]
       }
-
-      public_deps = [ ":remap_alloc" ]
     }
   } else {
     action("find_stdlib") {
@@ -396,12 +361,6 @@ if (toolchain_has_rust) {
         ":stdlib_public_dependent_libs",
       ]
       deps = [ ":prebuilt_rustc_copy_to_sysroot" ]
-
-      # The host builds tools toolchain supports Rust only and does not use
-      # the allocator remapping to point it to PartitionAlloc.
-      if (!toolchain_for_rust_host_build_tools) {
-        deps += [ ":remap_alloc" ]
-      }
     }
   }
 }