From 3f73bf503847e5b28cd6880336716284559f74ef Mon Sep 17 00:00:00 2001 From: bridiver Date: Thu, 20 Oct 2022 07:45:57 -0700 Subject: [PATCH] bump to rust 1.59 --- browser/sources.gni | 20 -------------------- build/cargo.gni | 10 +++++++++- build/rust/BUILD.gn | 22 ++++++++++++++++++++++ build/rust/config.gni | 16 ++++++++++------ ios/BUILD.gn | 10 ---------- script/cargo.py | 2 +- script/deps_config.py | 2 +- 7 files changed, 43 insertions(+), 39 deletions(-) diff --git a/browser/sources.gni b/browser/sources.gni index 8b408d6e931..53bb32a4b99 100644 --- a/browser/sources.gni +++ b/browser/sources.gni @@ -373,26 +373,6 @@ if (is_mac) { brave_chrome_framework_bundle_deps = [ "//brave:framework_bundle_data" ] brave_chrome_framework_contents = [ "Frameworks" ] brave_chrome_framework_ldflags = [] - - # this needs to match the guards on //chrome:verify_chrome_framework_order - if (!is_component_build && chrome_pgo_phase != 1) { - brave_chrome_framework_public_deps += [ - # TODO(bridiver) - this doesn't have to be a public dep - "//brave/build/rust:generate_unexport_list", - ] - brave_chrome_framework_ldflags += [ - # prevent export of all rust symbols - "-Wl,-unexported_symbols_list," + - rebase_path(unexport_list_path, root_build_dir), - ] - } - if (!is_component_build && !use_lld) { - brave_chrome_framework_ldflags += [ - # https://bugzilla.mozilla.org/show_bug.cgi?id=1188030#c14 - # Supposedly this bug was fixed, but it's still happening for us - "-Wl,-no_compact_unwind", - ] - } } brave_chrome_browser_sources += brave_browser_autocomplete_sources diff --git a/build/cargo.gni b/build/cargo.gni index 062f707887f..6528e148d78 100644 --- a/build/cargo.gni +++ b/build/cargo.gni @@ -18,9 +18,14 @@ rust_lib_output_path = "$rust_lib_build_path/${cargo_lib_prefix}brave_rust${cargo_lib_suffix}" template("rust_ffi") { - source_set(target_name) { + static_library(target_name) { libs = [ rust_lib_output_path ] + all_dependent_configs = [ + "//brave/build/rust:strip_rust_symbols", + "//brave/build/rust:too_many_personalities_workaround", + ] + if (is_mac) { frameworks = [ "Security.framework" ] @@ -32,6 +37,9 @@ template("rust_ffi") { } deps = [ "//brave/build/rust:rust_lib" ] + if (is_apple) { + deps += [ "//brave/build/rust:generate_unexport_list" ] + } if (defined(invoker.deps)) { deps += invoker.deps } diff --git a/build/rust/BUILD.gn b/build/rust/BUILD.gn index 2b4e37e3ccd..c460e58ca15 100644 --- a/build/rust/BUILD.gn +++ b/build/rust/BUILD.gn @@ -4,6 +4,28 @@ if (is_mac) { import("//build/config/mac/mac_sdk.gni") } +if (is_apple) { + unexport_list_path = "$root_build_dir/brave_rust/rust_lib.unexports" +} + +# Too many personalities workaround. Will be fixed in llvm see +# https://reviews.llvm.org/D135728 +config("too_many_personalities_workaround") { + if (is_apple && !is_component_build && !use_lld) { + ldflags = [ "-Wl,-no_compact_unwind" ] + } +} + +config("strip_rust_symbols") { + if (is_apple) { + ldflags = [ + # prevent export of all rust symbols + "-Wl,-unexported_symbols_list," + + rebase_path(unexport_list_path, root_build_dir), + ] + } +} + cargo_build("rust_lib") { visibility = [ ":*" ] inputs = [ diff --git a/build/rust/config.gni b/build/rust/config.gni index 7f28f7f6b54..999bd1ac039 100644 --- a/build/rust/config.gni +++ b/build/rust/config.gni @@ -15,15 +15,13 @@ declare_args() { } if (cargo_profile == "") { - if (is_official_build) { - cargo_profile = "release" - } else { + if (is_debug) { cargo_profile = "dev" + } else { + cargo_profile = "release" } } -unexport_list_path = "$root_build_dir/brave_rust/rust_lib.unexports" - rustc_target = "" rustc_toolchain = "" cargo_lib_prefix = "" @@ -55,6 +53,12 @@ enable_rust_lto = too_many_personality_profiles_workaround if (enable_rust_lto) { default_rustflags += [ "-Cembed-bitcode=yes" ] default_rustflags += [ "-Clto" ] +} else { + default_rustflags += [ "-Cembed-bitcode=no" ] +} + +if (is_official_build) { + default_rustflags += [ "-Ccodegen-units=1" ] } if (is_debug) { @@ -62,7 +66,7 @@ if (is_debug) { # must always be optimized for too_many_personality_profiles_workaround to work default_rustflags += [ "-Copt-level=1" ] } else { - default_rustflags += [ "-Copt-level=0" ] + default_rustflags += [ "-Copt-level=0" ] } } else if (optimize_for_size) { default_rustflags += [ "-Copt-level=s" ] diff --git a/ios/BUILD.gn b/ios/BUILD.gn index 81125ddcdca..d44efcdc867 100644 --- a/ios/BUILD.gn +++ b/ios/BUILD.gn @@ -3,7 +3,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -import("//brave/build/rust/config.gni") import("//brave/ios/browser/api/ads/headers.gni") import("//brave/ios/browser/api/brave_shields/headers.gni") import("//brave/ios/browser/api/brave_stats/headers.gni") @@ -28,14 +27,6 @@ config("internal_config") { visibility = [ ":*" ] ldflags = [ "-Wl,-rpath,/usr/lib/swift,-rpath,@executable_path/../Frameworks" ] - if (!use_lld) { - ldflags += [ "-Wl,-no_compact_unwind" ] - } - ldflags += [ - # prevent export of all rust symbols - "-Wl,-unexported_symbols_list," + - rebase_path(unexport_list_path, root_build_dir), - ] } group("brave_ios") { @@ -107,7 +98,6 @@ ios_framework_bundle("brave_core_ios_framework") { deps = [ ":brave_core_umbrella_header", - "//brave/build/rust:generate_unexport_list", "//brave/ios/app", ] diff --git a/script/cargo.py b/script/cargo.py index fef49d7ff7c..bf4e53a035e 100755 --- a/script/cargo.py +++ b/script/cargo.py @@ -32,7 +32,7 @@ def run_cargo(command, args): if args.toolchain: toolchains_path = os.path.abspath( - os.path.join(rustup_path, 'toolchains', args.toolchain, "bin")) + os.path.join(rustup_home, 'toolchains', args.toolchain, "bin")) env['PATH'] = toolchains_path + os.pathsep + env['PATH'] if args.clang_bin_path is not None and not sys.platform.startswith('win'): diff --git a/script/deps_config.py b/script/deps_config.py index 999ce5f74c9..91fcc8f2aa0 100755 --- a/script/deps_config.py +++ b/script/deps_config.py @@ -8,7 +8,7 @@ import os # Version number and URL for pre-configured rust dependency package # e.g. rust_deps_mac_0.1.0.gz DEPS_PACKAGES_URL = "https://brave-build-deps-public.s3.brave.com" -RUST_DEPS_PACKAGE_VERSION = "1.0.0" +RUST_DEPS_PACKAGE_VERSION = "1.1.0" MAC_TOOLCHAIN_ROOT = os.path.join(os.path.dirname(os.path.dirname( os.path.dirname(__file__))), 'build', 'mac_files')