--- 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" ] - } } } }