• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp
2index 39b7bdb7e..96be82f01 100644
3--- a/llvm/lib/Support/Host.cpp
4+++ b/llvm/lib/Support/Host.cpp
5@@ -518,7 +518,7 @@ static bool isCpuIdSupported() {
6 static bool getX86CpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
7                                unsigned *rECX, unsigned *rEDX) {
8 #if defined(__GNUC__) || defined(__clang__)
9-#if defined(__x86_64__)
10+#if defined(__x86_64__) && !defined(IS_WASM)
11   // gcc doesn't know cpuid would clobber ebx/rbx. Preserve it manually.
12   // FIXME: should we save this for Clang?
13   __asm__("movq\t%%rbx, %%rsi\n\t"
14@@ -594,7 +594,7 @@ static bool getX86CpuIDAndInfoEx(unsigned value, unsigned subleaf,
15                                  unsigned *rEAX, unsigned *rEBX, unsigned *rECX,
16                                  unsigned *rEDX) {
17 #if defined(__GNUC__) || defined(__clang__)
18-#if defined(__x86_64__)
19+#if defined(__x86_64__) && !defined(IS_WASM)
20   // gcc doesn't know cpuid would clobber ebx/rbx. Preserve it manually.
21   // FIXME: should we save this for Clang?
22   __asm__("movq\t%%rbx, %%rsi\n\t"
23@@ -628,7 +628,7 @@ static bool getX86CpuIDAndInfoEx(unsigned value, unsigned subleaf,
24
25 // Read control register 0 (XCR0). Used to detect features such as AVX.
26 static bool getX86XCR0(unsigned *rEAX, unsigned *rEDX) {
27-#if defined(__GNUC__) || defined(__clang__)
28+#if (defined(__GNUC__) || defined(__clang__)) && !defined(IS_WASM)
29   // Check xgetbv; this uses a .byte sequence instead of the instruction
30   // directly because older assemblers do not include support for xgetbv and
31   // there is no easy way to conditionally compile based on the assembler used.
32diff --git a/llvm/utils/gn/build/buildflags.gni b/llvm/utils/gn/build/buildflags.gni
33index ca43a2499..bea51ce38 100644
34--- a/llvm/utils/gn/build/buildflags.gni
35+++ b/llvm/utils/gn/build/buildflags.gni
36@@ -1,6 +1,8 @@
37 declare_args() {
38   # Build for debugging. Equivalent to is_optimized=false symbol_level=2.
39-  is_debug = false
40+  if (!build_llvm_with_ts) {
41+    is_debug = false
42+  }
43
44   # Whether to build with tsan.
45   use_tsan = false
46diff --git a/llvm/utils/gn/build/compiled_action.gni b/llvm/utils/gn/build/compiled_action.gni
47index 697fe3de2..ad3d177ed 100644
48--- a/llvm/utils/gn/build/compiled_action.gni
49+++ b/llvm/utils/gn/build/compiled_action.gni
50@@ -64,8 +64,13 @@ template("compiled_action") {
51                              "visibility",
52                            ])
53     host_tool = invoker.tool + "($host_toolchain)"
54-    host_executable = get_label_info(host_tool, "root_out_dir") +
55-                      "/bin/" + get_label_info(host_tool, "name")
56+    if (build_llvm_with_ts) {
57+      host_executable = get_label_info(host_tool, "root_out_dir") +
58+              "/" + get_label_info(host_tool, "name")
59+    } else {
60+      host_executable = get_label_info(host_tool, "root_out_dir") +
61+              "/bin/" + get_label_info(host_tool, "name")
62+    }
63     deps = [ host_tool ]
64     script = "//llvm/utils/gn/build/run_built_binary.py"
65     args = [ rebase_path(host_executable, root_build_dir) ] + invoker.args
66diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
67index 897364f00..b540838dd 100644
68--- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
69+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
70@@ -50,7 +50,11 @@ declare_args() {
71
72   # glibc is at least 2.33 which has mallinfo2.
73   # TODO: remove this once nobody using the gn build is building against an old glibc.
74-  llvm_have_mallinfo2 = current_os == "linux"
75+  if (build_llvm_with_ts) {
76+    llvm_have_mallinfo2 = false
77+  } else {
78+    llvm_have_mallinfo2 = current_os == "linux"
79+  }
80 }
81
82 write_cmake_config("abi-breaking") {
83@@ -169,7 +173,8 @@ write_cmake_config("config") {
84     values += [
85       "HAVE_CRASHREPORTER_INFO=",
86       "HAVE_DECL_ARC4RANDOM=",
87-      "HAVE_DLADDR=",
88+      # set HAVE_DLADDR to avoid compile error on wasm build
89+      "HAVE_DLADDR=1",
90       "HAVE_MACH_MACH_H=",
91       "HAVE_MALLOC_MALLOC_H=",
92       "HAVE_MALLOC_ZONE_STATISTICS=",
93@@ -180,8 +185,16 @@ write_cmake_config("config") {
94   }
95
96   if (current_os == "linux" || current_os == "mac") {
97+    if (build_llvm_with_ts) {
98+      values += [
99+        "HAVE_BACKTRACE=",
100+      ]
101+    } else {
102+      values += [
103+        "HAVE_BACKTRACE=1",
104+      ]
105+    }
106     values += [
107-      "HAVE_BACKTRACE=1",
108       "HAVE_POSIX_SPAWN=1",
109       "HAVE_PTHREAD_GETNAME_NP=1",
110     ]
111@@ -259,7 +272,17 @@ write_cmake_config("config") {
112       "HAVE_SBRK=1",
113       "HAVE_SETENV=1",
114       "HAVE_SETRLIMIT=1",
115-      "HAVE_SIGALTSTACK=1",
116+    ]
117+    if (build_llvm_with_ts) {
118+      values += [
119+        "HAVE_SIGALTSTACK=",
120+      ]
121+    } else {
122+      values += [
123+        "HAVE_SIGALTSTACK=1",
124+      ]
125+    }
126+    values += [
127       "HAVE_STRERROR_R=1",
128       "HAVE_SYSCONF=1",
129       "HAVE_SYS_IOCTL_H=1",
130diff --git a/llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
131index 7a864464a..83b0d6d31 100644
132--- a/llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
133+++ b/llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
134@@ -5,14 +5,16 @@ static_library("IR") {
135   public_deps = [
136     # Must be public_dep because IR's public headers include llvm-config.h.
137     "//llvm/include/llvm/Config:llvm-config",
138-    "//llvm/include/llvm/IR:public_tablegen",
139   ]
140   deps = [
141-    "//llvm/include/llvm/IR:IntrinsicImpl",
142     "//llvm/lib/BinaryFormat",
143     "//llvm/lib/Remarks",
144     "//llvm/lib/Support",
145   ]
146+  if (!is_ohos) {
147+    public_deps += [ "//llvm/include/llvm/IR:public_tablegen" ]
148+    deps += [ "//llvm/include/llvm/IR:IntrinsicImpl" ]
149+  }
150   sources = [
151     "AbstractCallSite.cpp",
152     "AsmWriter.cpp",
153diff --git a/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
154index 56d5b2ce7..7737612f0 100644
155--- a/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
156+++ b/llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
157@@ -1,13 +1,21 @@
158 static_library("Support") {
159   output_name = "LLVMSupport"
160-  deps = [
161-    "BLAKE3",
162-    "//llvm/include/llvm/Config:config",
163-    "//llvm/lib/Demangle",
164-    "//llvm/utils/gn/build/libs/pthread",
165-    "//llvm/utils/gn/build/libs/terminfo",
166-    "//llvm/utils/gn/build/libs/zlib",
167-  ]
168+  if (build_llvm_with_ts) {
169+    deps = [
170+      "//llvm/include/llvm/Config:config",
171+      "//llvm/lib/Demangle",
172+      "//src/parser/hiperf_parser:libz",
173+    ]
174+  } else {
175+    deps = [
176+      "BLAKE3",
177+      "//llvm/include/llvm/Config:config",
178+      "//llvm/lib/Demangle",
179+      "//llvm/utils/gn/build/libs/pthread",
180+      "//llvm/utils/gn/build/libs/terminfo",
181+      "//llvm/utils/gn/build/libs/zlib",
182+    ]
183+  }
184
185   # public_deps are used for depending on targets that generate headers
186   # which are included in public headers of this target. public_deps means
187@@ -193,7 +201,10 @@ static_library("Support") {
188     libs += [ "dl" ]
189   } else if (current_os == "win") {
190     # Delay load shell32.dll if possible to speed up process startup.
191-    libs += [ "delayimp.lib" ]
192+    # avoid link error if build with smartperf
193+    if (!build_llvm_with_ts) {
194+      libs += [ "delayimp.lib" ]
195+    }
196     ldflags = [
197       "-delayload:ole32.dll",
198       "-delayload:shell32.dll",
199