From 5ce116728b1afcbd722fed74f8313fcad4ae3a4f Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Wed, 5 Oct 2022 09:50:39 +0200 Subject: [PATCH 01/11] Fix Rust-related error building for Arm64 Linux --- build/rust/config.gni | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build/rust/config.gni b/build/rust/config.gni index ce8b5ab02aad..d9c0ae743be6 100644 --- a/build/rust/config.gni +++ b/build/rust/config.gni @@ -95,10 +95,12 @@ if (is_win) { } else if (is_linux) { if (current_cpu == "x64") { rustc_target = "x86_64-unknown-linux-gnu" - if (use_sysroot) { - default_rustflags += [ "-C link-arg=--sysroot=$target_sysroot" ] - default_rustflags += [ "-C link-arg=-Wl,-rpath=\$ORIGIN" ] - } + } else if (current_cpu == "arm64") { + rustc_target = "aarch64-unknown-linux-gnu" + } + if (use_sysroot) { + default_rustflags += [ "-C link-arg=--sysroot=$target_sysroot" ] + default_rustflags += [ "-C link-arg=-Wl,-rpath=\$ORIGIN" ] } } else if (is_android) { if (current_cpu == "arm") { From 0e7776dca85aeb93b048742ad28eec973747ed47 Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Wed, 5 Oct 2022 12:31:54 +0200 Subject: [PATCH 02/11] Fix error building for Arm64 Linux --- .../ui/views/permissions/permission_prompt_bubble_view.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chromium_src/chrome/browser/ui/views/permissions/permission_prompt_bubble_view.cc b/chromium_src/chrome/browser/ui/views/permissions/permission_prompt_bubble_view.cc index a74e609a329c..4c972fb1913e 100644 --- a/chromium_src/chrome/browser/ui/views/permissions/permission_prompt_bubble_view.cc +++ b/chromium_src/chrome/browser/ui/views/permissions/permission_prompt_bubble_view.cc @@ -12,6 +12,7 @@ #include "brave/components/permissions/permission_lifetime_utils.h" #include "brave/grit/brave_generated_resources.h" #include "chrome/browser/ui/browser_tabstrip.h" +#include "chrome/browser/ui/views/chrome_layout_provider.h" #include "chrome/common/webui_url_constants.h" #include "chrome/grit/generated_resources.h" #include "components/grit/brave_components_strings.h" @@ -30,7 +31,6 @@ #if BUILDFLAG(ENABLE_WIDEVINE) #include "brave/browser/widevine/widevine_permission_request.h" #include "brave/components/constants/webui_url_constants.h" -#include "chrome/browser/ui/views/chrome_layout_provider.h" #include "components/permissions/request_type.h" #include "ui/gfx/text_constants.h" #include "ui/views/controls/button/checkbox.h" From ebc3ea675684f07653ddcdfe7bd453bf5ed78b3e Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Wed, 5 Oct 2022 16:45:18 +0200 Subject: [PATCH 03/11] Fix `strip` error when building for Arm64 Linux --- app/linux/BUILD.gn | 28 +++++++++++++++++++++++++++- app/linux/prepend_to_path.py | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 app/linux/prepend_to_path.py diff --git a/app/linux/BUILD.gn b/app/linux/BUILD.gn index b4e41a32a10b..0b07042b6f46 100644 --- a/app/linux/BUILD.gn +++ b/app/linux/BUILD.gn @@ -43,6 +43,15 @@ group("symbol_dist_resources") { group("dist_resources") { } +if (current_cpu == "arm64") { + # Copy the binary for stripping Arm64 binaries as `strip` into a directory + # that we can put on the PATH. + copy("strip_arm64") { + sources = [ "/usr/bin/aarch64-linux-gnu-strip" ] + outputs = [ "$root_out_dir/strip" ] + } +} + action("strip_and_dump_symbols") { script = "//build/linux/dump_app_syms.py" @@ -70,7 +79,24 @@ action("strip_and_dump_symbols") { ] outputs = [ brave_symbol_file ] - args = [ + # If we are on Arm64, rewrite the script and args so we have a `strip` binary + # on the PATH that supports Arm64 binaries: + if (current_cpu == "arm64") { + strip_arm64 = "//brave/app/linux:strip_arm64" + deps += [strip_arm64] + + strip_dir = get_label_info(strip_arm64, "root_out_dir") + strip_path = rebase_path(strip_dir, root_build_dir) + old_script_path = rebase_path(script, root_build_dir) + + script = "//brave/app/linux/prepend_to_path.py" + args = [ strip_path , old_script_path ] + } else { + args = [] + } + + # Here come the usual args for dump_app_syms.py: + args += [ "./" + rebase_path(dump_syms_binary, root_build_dir), "1", # strip_binary = true rebase_path(brave_binary, root_build_dir), diff --git a/app/linux/prepend_to_path.py b/app/linux/prepend_to_path.py new file mode 100644 index 000000000000..5c111f1ab58d --- /dev/null +++ b/app/linux/prepend_to_path.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python +# This Source Code Form is subject to the terms of the Mozilla Public +# 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/. + +# Invoke another Python file after adding a directory to the PATH. + +import os +import subprocess +import sys + +dir_path = sys.argv[1] +args = sys.argv[2:] + +new_env = dict(os.environ) +new_env['PATH'] = dir_path + os.pathsep + new_env['PATH'] + +subprocess.check_call([sys.executable] + args, env=new_env) From c8626d1c8dfc7adc24d7b5a31dbd6ff942d7118a Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Wed, 5 Oct 2022 16:59:54 +0200 Subject: [PATCH 04/11] Fix lint errors --- app/linux/BUILD.gn | 7 +++++-- build/rust/config.gni | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/linux/BUILD.gn b/app/linux/BUILD.gn index 0b07042b6f46..616eb7ecfb0f 100644 --- a/app/linux/BUILD.gn +++ b/app/linux/BUILD.gn @@ -83,14 +83,17 @@ action("strip_and_dump_symbols") { # on the PATH that supports Arm64 binaries: if (current_cpu == "arm64") { strip_arm64 = "//brave/app/linux:strip_arm64" - deps += [strip_arm64] + deps += [ strip_arm64 ] strip_dir = get_label_info(strip_arm64, "root_out_dir") strip_path = rebase_path(strip_dir, root_build_dir) old_script_path = rebase_path(script, root_build_dir) script = "//brave/app/linux/prepend_to_path.py" - args = [ strip_path , old_script_path ] + args = [ + strip_path, + old_script_path, + ] } else { args = [] } diff --git a/build/rust/config.gni b/build/rust/config.gni index d9c0ae743be6..7f28f7f6b546 100644 --- a/build/rust/config.gni +++ b/build/rust/config.gni @@ -47,7 +47,8 @@ if (use_lld) { # https://bugzilla.mozilla.org/show_bug.cgi?id=1188030#c14 # Supposedly this bug was fixed, but it's still happening for us. -too_many_personality_profiles_workaround = is_apple && use_lld && !is_component_build +too_many_personality_profiles_workaround = + is_apple && use_lld && !is_component_build enable_rust_lto = too_many_personality_profiles_workaround From 5a03ba03a9c447e3091cb942f41729e3271a97a2 Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Wed, 5 Oct 2022 17:37:38 +0200 Subject: [PATCH 05/11] Disable Widevine on Arm64 Linux --- build/commands/lib/config.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/build/commands/lib/config.js b/build/commands/lib/config.js index f328635a968b..baac993760e6 100755 --- a/build/commands/lib/config.js +++ b/build/commands/lib/config.js @@ -409,9 +409,14 @@ Config.prototype.buildArgs = function () { args.use_system_xcode = false } - if (this.getTargetOS() === 'linux' && this.targetArch === 'x64') { - // Include vaapi support - args.use_vaapi = true + if (this.getTargetOS() === 'linux') { + if (this.targetArch === 'x64') { + // Include vaapi support + args.use_vaapi = true + } else if (this.targetArch === 'arm64') { + // We don't yet support Widevine on Arm64 Linux. + args.enable_widevine = false + } } // Enable Page Graph only in desktop builds. From 3a08b19437077fccbbaafef963cfe9cdc0169782 Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Thu, 6 Oct 2022 18:23:13 +0200 Subject: [PATCH 06/11] Move includes out of Widevine-specific build flag --- .../permissions/permission_prompt_bubble_view.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/chromium_src/chrome/browser/ui/views/permissions/permission_prompt_bubble_view.cc b/chromium_src/chrome/browser/ui/views/permissions/permission_prompt_bubble_view.cc index 4c972fb1913e..0a54c9d8b18b 100644 --- a/chromium_src/chrome/browser/ui/views/permissions/permission_prompt_bubble_view.cc +++ b/chromium_src/chrome/browser/ui/views/permissions/permission_prompt_bubble_view.cc @@ -8,6 +8,7 @@ #include "base/feature_list.h" #include "base/memory/raw_ptr.h" #include "brave/components/constants/url_constants.h" +#include "brave/components/constants/webui_url_constants.h" #include "brave/components/l10n/common/locale_util.h" #include "brave/components/permissions/permission_lifetime_utils.h" #include "brave/grit/brave_generated_resources.h" @@ -19,23 +20,22 @@ #include "components/permissions/features.h" #include "components/permissions/permission_prompt.h" #include "components/permissions/permission_request.h" +#include "components/permissions/request_type.h" #include "components/strings/grit/components_strings.h" #include "third_party/widevine/cdm/buildflags.h" #include "ui/base/models/combobox_model.h" +#include "ui/gfx/text_constants.h" #include "ui/views/bubble/bubble_dialog_delegate_view.h" +#include "ui/views/controls/button/checkbox.h" #include "ui/views/controls/combobox/combobox.h" +#include "ui/views/controls/label.h" #include "ui/views/controls/styled_label.h" #include "ui/views/layout/box_layout.h" +#include "ui/views/style/typography.h" #include "ui/views/window/dialog_delegate.h" #if BUILDFLAG(ENABLE_WIDEVINE) #include "brave/browser/widevine/widevine_permission_request.h" -#include "brave/components/constants/webui_url_constants.h" -#include "components/permissions/request_type.h" -#include "ui/gfx/text_constants.h" -#include "ui/views/controls/button/checkbox.h" -#include "ui/views/controls/label.h" -#include "ui/views/style/typography.h" #endif namespace { From d87bd5852ab7757a1013c6f4bf0dca149fcf93ff Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Fri, 7 Oct 2022 07:56:33 +0200 Subject: [PATCH 07/11] Simplify Linux build code Previously, `npm run build` produced out/brave with debug info. Then, `npm run create_dist` modified that file to strip symbols. Now, out/brave remains unchanged and we rely on Chromium's existing logic for putting the stripped binary into the .deb and .rpm packages. --- app/linux/BUILD.gn | 66 ++++++------------------------------ app/linux/prepend_to_path.py | 18 ---------- 2 files changed, 10 insertions(+), 74 deletions(-) delete mode 100644 app/linux/prepend_to_path.py diff --git a/app/linux/BUILD.gn b/app/linux/BUILD.gn index 616eb7ecfb0f..a1b96831bc10 100644 --- a/app/linux/BUILD.gn +++ b/app/linux/BUILD.gn @@ -1,4 +1,5 @@ import("//brave/build/config.gni") +import("//build/linux/extract_symbols.gni") if (should_generate_breakpad_symbols) { action("generate_breakpad_symbols") { @@ -36,73 +37,26 @@ if (should_generate_breakpad_symbols) { group("symbol_dist_resources") { public_deps = [ ":generate_breakpad_symbols", - ":strip_and_dump_symbols", + ":brave_symbols", ] } group("dist_resources") { } -if (current_cpu == "arm64") { - # Copy the binary for stripping Arm64 binaries as `strip` into a directory - # that we can put on the PATH. - copy("strip_arm64") { - sources = [ "/usr/bin/aarch64-linux-gnu-strip" ] - outputs = [ "$root_out_dir/strip" ] - } -} - -action("strip_and_dump_symbols") { - script = "//build/linux/dump_app_syms.py" +extract_symbols("brave_symbols") { + binary = "$brave_dist_dir/brave" - dump_syms_label = "//third_party/breakpad:dump_syms($host_toolchain)" - dump_syms_binary = - get_label_info(dump_syms_label, "root_out_dir") + "/" + "dump_syms" - - deps = [ - # TODO(bridiver) - resolve duplicate symbol generation - ":generate_breakpad_symbols", - "//brave:brave_dist_resources", - dump_syms_label, - ] - brave_binary = "$brave_dist_dir/brave" if (current_cpu == "x86") { # Use "ia32" instead of "x86" for GYP compat. - brave_symbol_file = "$root_out_dir/brave.breakpad.ia32" - } else { - brave_symbol_file = "$root_out_dir/brave.breakpad.$current_cpu" - } - - inputs = [ - brave_binary, - dump_syms_binary, - ] - outputs = [ brave_symbol_file ] - - # If we are on Arm64, rewrite the script and args so we have a `strip` binary - # on the PATH that supports Arm64 binaries: - if (current_cpu == "arm64") { - strip_arm64 = "//brave/app/linux:strip_arm64" - deps += [ strip_arm64 ] - - strip_dir = get_label_info(strip_arm64, "root_out_dir") - strip_path = rebase_path(strip_dir, root_build_dir) - old_script_path = rebase_path(script, root_build_dir) - - script = "//brave/app/linux/prepend_to_path.py" - args = [ - strip_path, - old_script_path, - ] + symbol_file = "$root_out_dir/brave.breakpad.ia32" } else { - args = [] + symbol_file = "$root_out_dir/brave.breakpad.$current_cpu" } - # Here come the usual args for dump_app_syms.py: - args += [ - "./" + rebase_path(dump_syms_binary, root_build_dir), - "1", # strip_binary = true - rebase_path(brave_binary, root_build_dir), - rebase_path(brave_symbol_file, root_build_dir), + deps = [ + # TODO(bridiver) - resolve duplicate symbol generation + ":generate_breakpad_symbols", + "//brave:brave_dist_resources", ] } diff --git a/app/linux/prepend_to_path.py b/app/linux/prepend_to_path.py deleted file mode 100644 index 5c111f1ab58d..000000000000 --- a/app/linux/prepend_to_path.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -# This Source Code Form is subject to the terms of the Mozilla Public -# 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/. - -# Invoke another Python file after adding a directory to the PATH. - -import os -import subprocess -import sys - -dir_path = sys.argv[1] -args = sys.argv[2:] - -new_env = dict(os.environ) -new_env['PATH'] = dir_path + os.pathsep + new_env['PATH'] - -subprocess.check_call([sys.executable] + args, env=new_env) From 49df7c0b7c40bd25d1a1f09e7e5b2f502b5e5cfb Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Fri, 7 Oct 2022 08:07:08 +0200 Subject: [PATCH 08/11] Fix lint error --- app/linux/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/linux/BUILD.gn b/app/linux/BUILD.gn index a1b96831bc10..ff32755522ce 100644 --- a/app/linux/BUILD.gn +++ b/app/linux/BUILD.gn @@ -36,8 +36,8 @@ if (should_generate_breakpad_symbols) { group("symbol_dist_resources") { public_deps = [ - ":generate_breakpad_symbols", ":brave_symbols", + ":generate_breakpad_symbols", ] } From 458ab51e80d06a4bb0fe9ad4e150f56efc80dccf Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Tue, 11 Oct 2022 18:49:00 +0200 Subject: [PATCH 09/11] Avoid duplicate symbol generation on Linux --- app/linux/BUILD.gn | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/linux/BUILD.gn b/app/linux/BUILD.gn index ff32755522ce..fc1d353002cc 100644 --- a/app/linux/BUILD.gn +++ b/app/linux/BUILD.gn @@ -54,9 +54,5 @@ extract_symbols("brave_symbols") { symbol_file = "$root_out_dir/brave.breakpad.$current_cpu" } - deps = [ - # TODO(bridiver) - resolve duplicate symbol generation - ":generate_breakpad_symbols", - "//brave:brave_dist_resources", - ] + deps = [ "//brave:brave_dist_resources" ] } From 32ca54f91931f397ff1dce3319a2afc6a68c148b Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Tue, 11 Oct 2022 18:51:58 +0200 Subject: [PATCH 10/11] Enable VA-API on Arm64 Linux --- build/commands/lib/config.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/commands/lib/config.js b/build/commands/lib/config.js index baac993760e6..db2513f87272 100755 --- a/build/commands/lib/config.js +++ b/build/commands/lib/config.js @@ -410,10 +410,11 @@ Config.prototype.buildArgs = function () { } if (this.getTargetOS() === 'linux') { - if (this.targetArch === 'x64') { + if (this.targetArch !== 'x86') { // Include vaapi support args.use_vaapi = true - } else if (this.targetArch === 'arm64') { + } + if (this.targetArch === 'arm64') { // We don't yet support Widevine on Arm64 Linux. args.enable_widevine = false } From 5651fab1f92065d97173d491f323b0b5f8f24e56 Mon Sep 17 00:00:00 2001 From: Michael Herrmann Date: Wed, 12 Oct 2022 08:37:42 +0200 Subject: [PATCH 11/11] Add comment --- build/commands/lib/config.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/commands/lib/config.js b/build/commands/lib/config.js index db2513f87272..61a26b4a3e62 100755 --- a/build/commands/lib/config.js +++ b/build/commands/lib/config.js @@ -412,7 +412,11 @@ Config.prototype.buildArgs = function () { if (this.getTargetOS() === 'linux') { if (this.targetArch !== 'x86') { // Include vaapi support + // TODO: Consider setting use_vaapi_x11 instead of use_vaapi. Also + // consider enabling it for x86 builds. See + // https://github.com/brave/brave-browser/issues/1024#issuecomment-1175397914 args.use_vaapi = true + } if (this.targetArch === 'arm64') { // We don't yet support Widevine on Arm64 Linux.