From e376fd5fa64d34803e821e02c0d5199ca7244944 Mon Sep 17 00:00:00 2001 From: Roger Zanoni Date: Sun, 12 Nov 2023 19:41:07 -0300 Subject: [PATCH 31/33] [M118-fix] Add a way to set different lib paths host and target meta-clang on AGL defines a simplified path structure for clang's runtime libraries and a different lib naming convention. Upstream-Status: Inappropriate Signed-off-by: Roger Zanoni --- build/config/clang/BUILD.gn | 79 +++++++++++------------------------- build/config/clang/clang.gni | 3 ++ 2 files changed, 26 insertions(+), 56 deletions(-) diff --git a/build/config/clang/BUILD.gn b/build/config/clang/BUILD.gn index fe044e29e428b..81ec24d92da72 100644 --- a/build/config/clang/BUILD.gn +++ b/build/config/clang/BUILD.gn @@ -3,6 +3,7 @@ # found in the LICENSE file. import("//build/config/rust.gni") +import("//v8/gni/snapshot_toolchain.gni") import("clang.gni") if (is_ios) { @@ -95,66 +96,32 @@ template("clang_lib") { } } else { config(target_name) { - _dir = "" + if (is_a_target_toolchain) { + _base_path = "$clang_base_path_target" + _cpu = target_cpu + } else { + _base_path = "$clang_base_path" + _cpu = host_cpu + } + + if (_cpu == "x64") { + _suffix = "-x86_64" + } else if (_cpu == "x86") { + _suffix = "-i386" + } else if (_cpu == "arm64") { + _suffix = "-aarch64" + } else if (_cpu == "arm") { + _suffix = "-arm" + } else { + assert(false) # Unhandled cpu type + } + + _dir = "linux" _libname = invoker.libname _prefix = "lib" - _suffix = "" _ext = "a" - if (is_win) { - _dir = "windows" - _prefix = "" - _ext = "lib" - if (current_cpu == "x64") { - _suffix = "-x86_64" - } else if (current_cpu == "x86") { - _suffix = "-i386" - } else if (current_cpu == "arm64") { - _suffix = "-aarch64" - } else { - assert(false) # Unhandled cpu type - } - } else if (is_apple) { - _dir = "darwin" - } else if (is_linux || is_chromeos) { - if (current_cpu == "x64") { - _dir = "x86_64-unknown-linux-gnu" - } else if (current_cpu == "x86") { - _dir = "i386-unknown-linux-gnu" - } else if (current_cpu == "arm") { - _dir = "armv7-unknown-linux-gnueabihf" - } else if (current_cpu == "arm64") { - _dir = "aarch64-unknown-linux-gnu" - } else { - assert(false) # Unhandled cpu type - } - } else if (is_fuchsia) { - if (current_cpu == "x64") { - _dir = "x86_64-unknown-fuchsia" - } else if (current_cpu == "arm64") { - _dir = "aarch64-unknown-fuchsia" - } else { - assert(false) # Unhandled cpu type - } - } else if (is_android) { - _dir = "linux" - if (current_cpu == "x64") { - _suffix = "-x86_64-android" - } else if (current_cpu == "x86") { - _suffix = "-i686-android" - } else if (current_cpu == "arm") { - _suffix = "-arm-android" - } else if (current_cpu == "arm64") { - _suffix = "-aarch64-android" - } else if (current_cpu == "riscv64") { - _suffix = "-riscv64-android" - } else { - assert(false) # Unhandled cpu type - } - } else { - assert(false) # Unhandled target platform - } - _clang_lib_dir = "$clang_base_path/lib/clang/$clang_version/lib" + _clang_lib_dir = "$_base_path/lib/clang/$clang_version/lib" _lib_file = "${_prefix}clang_rt.${_libname}${_suffix}.${_ext}" libs = [ "$_clang_lib_dir/$_dir/$_lib_file" ] } diff --git a/build/config/clang/clang.gni b/build/config/clang/clang.gni index 1a065b5e348b0..46fb56693b494 100644 --- a/build/config/clang/clang.gni +++ b/build/config/clang/clang.gni @@ -26,6 +26,9 @@ declare_args() { build_with_chromium && !is_official_build && is_linux && !is_castos clang_base_path = default_clang_base_path + + # used only for linking + clang_base_path_target = default_clang_base_path # Specifies whether or not bitcode should be embedded during compilation. # This is used for creating a MLGO corpus from Chromium in the non-ThinLTO case. -- 2.42.1