[cef] Fix cef build for renesas
[AGL/meta-agl-demo.git] / recipes-wam / cef / files / chromium / 0031-M118-fix-Add-a-way-to-set-different-lib-paths-host-a.patch
1 From e376fd5fa64d34803e821e02c0d5199ca7244944 Mon Sep 17 00:00:00 2001
2 From: Roger Zanoni <rzanoni@igalia.com>
3 Date: Sun, 12 Nov 2023 19:41:07 -0300
4 Subject: [PATCH 31/33] [M118-fix] Add a way to set different lib paths host
5  and target
6
7 meta-clang on AGL defines a simplified path structure for clang's
8 runtime libraries and a different lib naming convention.
9
10 Upstream-Status: Inappropriate
11 Signed-off-by: Roger Zanoni <rzanoni@igalia.com>
12 ---
13  build/config/clang/BUILD.gn  | 79 +++++++++++-------------------------
14  build/config/clang/clang.gni |  3 ++
15  2 files changed, 26 insertions(+), 56 deletions(-)
16
17 diff --git a/build/config/clang/BUILD.gn b/build/config/clang/BUILD.gn
18 index fe044e29e428b..81ec24d92da72 100644
19 --- a/build/config/clang/BUILD.gn
20 +++ b/build/config/clang/BUILD.gn
21 @@ -3,6 +3,7 @@
22  # found in the LICENSE file.
23  
24  import("//build/config/rust.gni")
25 +import("//v8/gni/snapshot_toolchain.gni")
26  import("clang.gni")
27  
28  if (is_ios) {
29 @@ -95,66 +96,32 @@ template("clang_lib") {
30      }
31    } else {
32      config(target_name) {
33 -      _dir = ""
34 +      if (is_a_target_toolchain) {
35 +        _base_path = "$clang_base_path_target"
36 +        _cpu = target_cpu
37 +      } else {
38 +        _base_path = "$clang_base_path"
39 +        _cpu = host_cpu
40 +      }
41 +
42 +      if (_cpu == "x64") {
43 +        _suffix = "-x86_64"
44 +      } else if (_cpu == "x86") {
45 +        _suffix = "-i386"
46 +      } else if (_cpu == "arm64") {
47 +        _suffix = "-aarch64"
48 +      } else if (_cpu == "arm") {
49 +        _suffix = "-arm"
50 +      } else {
51 +        assert(false)  # Unhandled cpu type
52 +      }
53 +
54 +      _dir = "linux"
55        _libname = invoker.libname
56        _prefix = "lib"
57 -      _suffix = ""
58        _ext = "a"
59 -      if (is_win) {
60 -        _dir = "windows"
61 -        _prefix = ""
62 -        _ext = "lib"
63 -        if (current_cpu == "x64") {
64 -          _suffix = "-x86_64"
65 -        } else if (current_cpu == "x86") {
66 -          _suffix = "-i386"
67 -        } else if (current_cpu == "arm64") {
68 -          _suffix = "-aarch64"
69 -        } else {
70 -          assert(false)  # Unhandled cpu type
71 -        }
72 -      } else if (is_apple) {
73 -        _dir = "darwin"
74 -      } else if (is_linux || is_chromeos) {
75 -        if (current_cpu == "x64") {
76 -          _dir = "x86_64-unknown-linux-gnu"
77 -        } else if (current_cpu == "x86") {
78 -          _dir = "i386-unknown-linux-gnu"
79 -        } else if (current_cpu == "arm") {
80 -          _dir = "armv7-unknown-linux-gnueabihf"
81 -        } else if (current_cpu == "arm64") {
82 -          _dir = "aarch64-unknown-linux-gnu"
83 -        } else {
84 -          assert(false)  # Unhandled cpu type
85 -        }
86 -      } else if (is_fuchsia) {
87 -        if (current_cpu == "x64") {
88 -          _dir = "x86_64-unknown-fuchsia"
89 -        } else if (current_cpu == "arm64") {
90 -          _dir = "aarch64-unknown-fuchsia"
91 -        } else {
92 -          assert(false)  # Unhandled cpu type
93 -        }
94 -      } else if (is_android) {
95 -        _dir = "linux"
96 -        if (current_cpu == "x64") {
97 -          _suffix = "-x86_64-android"
98 -        } else if (current_cpu == "x86") {
99 -          _suffix = "-i686-android"
100 -        } else if (current_cpu == "arm") {
101 -          _suffix = "-arm-android"
102 -        } else if (current_cpu == "arm64") {
103 -          _suffix = "-aarch64-android"
104 -        } else if (current_cpu == "riscv64") {
105 -          _suffix = "-riscv64-android"
106 -        } else {
107 -          assert(false)  # Unhandled cpu type
108 -        }
109 -      } else {
110 -        assert(false)  # Unhandled target platform
111 -      }
112  
113 -      _clang_lib_dir = "$clang_base_path/lib/clang/$clang_version/lib"
114 +      _clang_lib_dir = "$_base_path/lib/clang/$clang_version/lib"
115        _lib_file = "${_prefix}clang_rt.${_libname}${_suffix}.${_ext}"
116        libs = [ "$_clang_lib_dir/$_dir/$_lib_file" ]
117      }
118 diff --git a/build/config/clang/clang.gni b/build/config/clang/clang.gni
119 index 1a065b5e348b0..46fb56693b494 100644
120 --- a/build/config/clang/clang.gni
121 +++ b/build/config/clang/clang.gni
122 @@ -26,6 +26,9 @@ declare_args() {
123        build_with_chromium && !is_official_build && is_linux && !is_castos
124  
125    clang_base_path = default_clang_base_path
126 +  
127 +  # used only for linking
128 +  clang_base_path_target = default_clang_base_path
129  
130    # Specifies whether or not bitcode should be embedded during compilation.
131    # This is used for creating a MLGO corpus from Chromium in the non-ThinLTO case.
132 -- 
133 2.42.1
134