From a6902e19edc77b316f5cd502145ac0556fc569b4 Mon Sep 17 00:00:00 2001 From: klzgrad Date: Tue, 14 Jan 2025 19:29:28 +0800 Subject: [PATCH] base: Remove Rust --- src/base/BUILD.gn | 59 ------------------------------------ src/base/json/json_reader.cc | 10 +++--- src/base/logging.cc | 4 +-- 3 files changed, 7 insertions(+), 66 deletions(-) diff --git a/src/base/BUILD.gn b/src/base/BUILD.gn index 55420dcb6e..ed2fa351ff 100644 --- a/src/base/BUILD.gn +++ b/src/base/BUILD.gn @@ -1040,12 +1040,6 @@ component("base") { if (!is_nacl) { # Used by metrics/crc32, except on NaCl builds. deps += [ "//third_party/zlib" ] - - # NaCl does not support Rust. - deps += [ - ":rust_logger", - "//third_party/rust/serde_json_lenient/v0_2/wrapper", - ] } # `raw_ptr` cannot be made a component due to CRT symbol issues. @@ -1085,17 +1079,6 @@ component("base") { # accidentally (transitively) depend on it anymore. public_deps += [ "//build:chromeos_buildflags" ] - if (!is_nacl) { - sources += [ - "containers/span_rust.h", - "strings/string_view_rust.h", - ] - - # Base provides conversions between CXX types and base types (e.g. - # std::string_view). - public_deps += [ "//build/rust:cxx_cppdeps" ] - } - # Needed for if using newer C++ library than sysroot, except if # building inside the cros_sdk environment - use host_toolchain as a # more robust check for this. @@ -1563,8 +1546,6 @@ component("base") { "files/scoped_temp_file.h", "json/json_file_value_serializer.cc", "json/json_file_value_serializer.h", - "logging/rust_log_integration.cc", - "logging/rust_log_integration.h", "memory/discardable_memory.cc", "memory/discardable_memory.h", "memory/discardable_memory_allocator.cc", @@ -2497,46 +2478,6 @@ component("base") { } } -rust_bindgen("logging_log_severity_bindgen") { - # TODO(danakj): Maybe combine all base bindgen targets, or all base/logging - # ones even) into a single GN target? But the GN rule needs to handle multiple - # headers then. - header = "logging/log_severity.h" - cpp = true - visibility = [ ":*" ] - - # Transitive generated header dependency. - deps = [ ":debugging_buildflags" ] -} - -rust_static_library("rust_logger") { - allow_unsafe = true # Unsafe needed for FFI. - deps = [ - ":debugging_buildflags", - ":logging_log_severity_bindgen", - ":tracing_buildflags", - "//build:chromeos_buildflags", - "//third_party/rust/log/v0_4:lib", - - # Needed because of circular dependency: base depends on this target and by - # extension the cxx-generated C++ code, but the cxx-generated code includes - # base headers and calls base code. This seems to generally not cause - # issues, except for partition_alloc which applies configs when depended on. - # - # This allows the generated C++ code to transitively include partition alloc - # headers without issue. - # - # TODO(collinbaker): determine how to handle these cxx bindings-induced - # circular dependencies more robustly. - "//base/allocator/partition_allocator:raw_ptr", - ] - visibility = [ ":base" ] - sources = [ "logging/rust_logger.rs" ] - crate_root = "logging/rust_logger.rs" - - cxx_bindings = [ "logging/rust_logger.rs" ] -} - if (is_linux || is_chromeos) { # Split out as a separate target for two reasons: # - the line number reader is 2x slower in debug builds if not optimized, diff --git a/src/base/json/json_reader.cc b/src/base/json/json_reader.cc index 48a9b893d3..a83833ea66 100644 --- a/src/base/json/json_reader.cc +++ b/src/base/json/json_reader.cc @@ -13,7 +13,7 @@ #include "base/metrics/histogram_macros.h" #include "build/build_config.h" -#if !BUILDFLAG(IS_NACL) +#if 0 // Disables Rust #include "base/strings/string_view_rust.h" #include "third_party/rust/serde_json_lenient/v0_2/wrapper/functions.h" #include "third_party/rust/serde_json_lenient/v0_2/wrapper/lib.rs.h" @@ -21,7 +21,7 @@ // TODO(crbug.com/40811643): Move the C++ parser into components/nacl to just // run in-process there. Don't compile base::JSONReader on NaCL at all. -#if !BUILDFLAG(IS_NACL) +#if 0 // Disables Rust namespace { const char kSecurityJsonParsingTime[] = "Security.JSONParser.ParsingTime"; @@ -138,7 +138,7 @@ namespace base { std::optional JSONReader::Read(std::string_view json, int options, size_t max_depth) { -#if BUILDFLAG(IS_NACL) +#if 1 // Disables Rust internal::JSONParser parser(options, max_depth); return parser.Parse(json); #else // BUILDFLAG(IS_NACL) @@ -183,7 +183,7 @@ std::optional JSONReader::ReadList(std::string_view json, JSONReader::Result JSONReader::ReadAndReturnValueWithError( std::string_view json, int options) { -#if BUILDFLAG(IS_NACL) +#if 1 // Disables Rust internal::JSONParser parser(options); auto value = parser.Parse(json); if (!value) { @@ -224,7 +224,7 @@ bool JSONReader::UsingRust() { if (!base::FeatureList::GetInstance()) { return false; } -#if BUILDFLAG(IS_NACL) +#if 1 // Disables Rust return false; #else return base::FeatureList::IsEnabled(base::features::kUseRustJsonParser); diff --git a/src/base/logging.cc b/src/base/logging.cc index 26ba1a286e..602c514074 100644 --- a/src/base/logging.cc +++ b/src/base/logging.cc @@ -118,7 +118,7 @@ typedef FILE* FileHandle; #include "base/fuchsia/scoped_fx_logger.h" #endif -#if !BUILDFLAG(IS_NACL) +#if 0 // Disables Rust #include "base/logging/rust_logger.rs.h" #endif @@ -530,7 +530,7 @@ bool BaseInitLoggingImpl(const LoggingSettings& settings) { } #endif -#if !BUILDFLAG(IS_NACL) +#if 0 // Disables Rust // Connects Rust logging with the //base logging functionality. internal::init_rust_log_crate(); #endif