hc
2023-11-06 15ade055295d13f95d49e3d99b09f3bbfb4a43e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From b39c31589f64b82c5ec3b9cb4ace94289835a94a Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Fri, 22 Jan 2021 00:02:25 +0800
Subject: [PATCH] avoid link latomic failure on CentOS 8 host
 
When host (such as CentOS 8) did not install libatomic, there was a
link failure on native. In fact, only target requires to link atomic,
the native does not. So link atomic for target only
 
Upstream-Status: Inappropriate [oe specific]
 
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 base/BUILD.gn               | 2 ++
 build/config/linux/BUILD.gn | 2 ++
 2 files changed, 4 insertions(+)
 
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 336ce46f03ad2..9754bb7a6e35e 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -1380,8 +1380,10 @@ component("base") {
   # Needed for <atomic> 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.
+  # Only target requires <atomic>
   if (!use_sysroot &&
       (is_android || ((is_linux || is_chromeos) && !is_chromecast)) &&
+      (current_toolchain != host_toolchain) &&
       host_toolchain != "//build/toolchain/cros:host") {
     libs += [ "atomic" ]
   }
diff --git a/build/config/linux/BUILD.gn b/build/config/linux/BUILD.gn
index 8e42cf9f2f992..0bf9164d51a48 100644
--- a/build/config/linux/BUILD.gn
+++ b/build/config/linux/BUILD.gn
@@ -37,8 +37,10 @@ config("runtime_library") {
     defines = [ "OS_CHROMEOS" ]
   }
 
+  # Only target requires <atomic>
   if ((!(is_chromeos_ash || is_chromeos_lacros) ||
        default_toolchain != "//build/toolchain/cros:target") &&
+      (current_toolchain != host_toolchain) &&
       (!use_custom_libcxx || current_cpu == "mipsel")) {
     libs = [ "atomic" ]
   }