[Lldb-commits] [llvm] [clang] [clang-tools-extra] [compiler-rt] [lldb] [mlir] Fix Multiple Build Errors on different platforms (PR #77216)

2024-01-07 Thread via lldb-commits

https://github.com/trcrsired updated 
https://github.com/llvm/llvm-project/pull/77216

>From a1156a564c798192cb7608e28ce9b9ed846a8b1c Mon Sep 17 00:00:00 2001
From: trcrsired 
Date: Sat, 6 Jan 2024 20:21:06 -0500
Subject: [PATCH 1/2] Fix Multiple Build Errors on different platforms

Particularly for canadian compilation
---
 .../pseudo/include/CMakeLists.txt |  12 +-
 clang/lib/Tooling/CMakeLists.txt  |  10 +-
 compiler-rt/lib/builtins/fp_compare_impl.inc  |   3 +
 lldb/source/Host/android/HostInfoAndroid.cpp  |   4 +
 lldb/source/Host/android/LibcGlue.cpp |   2 +
 llvm/include/llvm/TargetParser/Triple.h   | 287 +++---
 llvm/lib/Support/Unix/Unix.h  |  17 +-
 mlir/lib/ExecutionEngine/CRunnerUtils.cpp |   4 +-
 8 files changed, 147 insertions(+), 192 deletions(-)

diff --git a/clang-tools-extra/pseudo/include/CMakeLists.txt 
b/clang-tools-extra/pseudo/include/CMakeLists.txt
index 2334cfa12e3376..605f17dd4591a0 100644
--- a/clang-tools-extra/pseudo/include/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -3,10 +3,18 @@ set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx/cxx.bnf)
 
 setup_host_tool(clang-pseudo-gen CLANG_PSEUDO_GEN pseudo_gen pseudo_gen_target)
 
+if(NOT DEFINED CLANG_PSEUDO_GEN)
+   if(DEFINED LLVM_NATIVE_TOOL_DIR AND NOT LLVM_NATIVE_TOOL_DIR STREQUAL "")
+  set(CLANG_PSEUDO_GEN "${LLVM_NATIVE_TOOL_DIR}/clang_pseudo_gen")
+   else()
+  set(CLANG_PSEUDO_GEN "${pseudo_gen}")
+   endif()
+endif()
+
 # Generate inc files.
 set(cxx_symbols_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXSymbols.inc)
 add_custom_command(OUTPUT ${cxx_symbols_inc}
-   COMMAND "${pseudo_gen}"
+   COMMAND "${CLANG_PSEUDO_GEN}"
  --grammar ${cxx_bnf}
  --emit-symbol-list
  -o ${cxx_symbols_inc}
@@ -16,7 +24,7 @@ add_custom_command(OUTPUT ${cxx_symbols_inc}
 
 set(cxx_bnf_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXBNF.inc)
 add_custom_command(OUTPUT ${cxx_bnf_inc}
-   COMMAND "${pseudo_gen}"
+   COMMAND "${CLANG_PSEUDO_GEN}"
  --grammar ${cxx_bnf}
  --emit-grammar-content
  -o ${cxx_bnf_inc}
diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index aff39e4de13c0b..1510f5fb8a0810 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -53,6 +53,14 @@ else()
 list(APPEND implicitDirs -I ${implicitDir})
   endforeach()
 
+  if(NOT DEFINED CLANG_AST_DUMP)
+if(DEFINED LLVM_NATIVE_TOOL_DIR AND NOT LLVM_NATIVE_TOOL_DIR STREQUAL "")
+  set(CLANG_AST_DUMP ${LLVM_NATIVE_TOOL_DIR}/clang-ast-dump)
+else()
+  set(CLANG_AST_DUMP $)
+endif()
+  endif()
+
   include(GetClangResourceDir)
   get_clang_resource_dir(resource_dir PREFIX ${LLVM_BINARY_DIR})
   add_custom_command(
@@ -60,7 +68,7 @@ else()
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
   DEPENDS clang-ast-dump clang-resource-headers
   COMMAND
-  $
+  ${CLANG_AST_DUMP}
 # Skip this in debug mode because parsing AST.h is too slow
 --skip-processing=${skip_expensive_processing}
 -I ${resource_dir}/include
diff --git a/compiler-rt/lib/builtins/fp_compare_impl.inc 
b/compiler-rt/lib/builtins/fp_compare_impl.inc
index a9a4f6fbf5dfe4..b2ebd0737df033 100644
--- a/compiler-rt/lib/builtins/fp_compare_impl.inc
+++ b/compiler-rt/lib/builtins/fp_compare_impl.inc
@@ -18,6 +18,9 @@ typedef int CMP_RESULT;
 #elif __SIZEOF_POINTER__ == 8 && __SIZEOF_LONG__ == 4
 // LLP64 ABIs use long long instead of long.
 typedef long long CMP_RESULT;
+#elif defined(__wasm64__)
+// GCC uses int as CMP_RESULT
+typedef int CMP_RESULT;
 #elif __AVR__
 // AVR uses a single byte for the return value.
 typedef char CMP_RESULT;
diff --git a/lldb/source/Host/android/HostInfoAndroid.cpp 
b/lldb/source/Host/android/HostInfoAndroid.cpp
index 68440e016afe4b..5ba2f0e24a8d24 100644
--- a/lldb/source/Host/android/HostInfoAndroid.cpp
+++ b/lldb/source/Host/android/HostInfoAndroid.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#ifdef __ANDROID__
+
 #include "lldb/Host/android/HostInfoAndroid.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/linux/HostInfoLinux.h"
@@ -92,3 +94,5 @@ bool HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec 
&file_spec) {
 
   return FileSystem::Instance().Exists(file_spec);
 }
+
+#endif
diff --git a/lldb/source/Host/android/LibcGlue.cpp 
b/lldb/source/Host/android/LibcGlue.cpp
index 877d735823feee..82b257719c2c8a 100644
--- a/lldb/source/Host/android/LibcGlue.cpp
+++ b/lldb/source/Host/android/LibcGlue.cpp
@@ -8,6 +8,7 @@
 
 // This files adds functions missing from libc on earlier versions of Android
 
+#ifdef __ANDROID__
 #include 
 
 #include 
@@ -26,3 +27,4 @@ time_t timegm(struct tm *t) { return (time_t)timegm64(t); }
 int posix_openpt(int flags) { return open("/dev/ptmx", flags); }
 
 #endif
+#endif
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetP

[Lldb-commits] [clang] [lldb] [mlir] [llvm] [libc] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

2024-01-07 Thread Bill Wendling via lldb-commits

bwendling wrote:

> Hi @bwendling, your change to MemoryBuiltins.h is hitting an error in the 
> version of Visual Studio 2019 that we use internally to build:
> 
> ```
> C:\j\w\779ddbee\p\llvm\include\llvm/Analysis/MemoryBuiltins.h(217): error 
> C2990: 'llvm::SizeOffsetType': non-class template has already been declared 
> as a class template
> C:\j\w\779ddbee\p\llvm\include\llvm/Analysis/MemoryBuiltins.h(193): note: see 
> declaration of 'llvm::SizeOffsetType'
> C:\j\w\779ddbee\p\llvm\include\llvm/Analysis/MemoryBuiltins.h(279): error 
> C2990: 'llvm::SizeOffsetType': non-class template has already been declared 
> as a class template
> C:\j\w\779ddbee\p\llvm\include\llvm/Analysis/MemoryBuiltins.h(193): note: see 
> declaration of 'llvm::SizeOffsetType'
> C:\j\w\779ddbee\p\llvm\include\llvm/Analysis/MemoryBuiltins.h(292): error 
> C2990: 'llvm::SizeOffsetType': non-class template has already been declared 
> as a class template
> C:\j\w\779ddbee\p\llvm\include\llvm/Analysis/MemoryBuiltins.h(193): note: see 
> declaration of 'llvm::SizeOffsetType'
> ```
> 
> From the Visual Studio documentation for the error, it appears that we should 
> be able to work around this error by modifying the friend declaration like 
> this:
> 
> ```c++
> -  friend class SizeOffsetType;
> +  template  friend class SizeOffsetType;
> ```
> 
> When I made this change to the 3 locations that caused the error (lines 
> 217/279/292), I was able to build successfully with Visual Studio. Could we 
> update the friend declaration so that it also works with the version of 
> Visual Studio that we are using internally to build?

Sorry about that. I pushed a fix here:

To https://github.com/llvm/llvm-project.git
   3eb9fd8ac8bb..0903d992cc96  main -> main


https://github.com/llvm/llvm-project/pull/76882
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libc] [llvm] [mlir] [clang] [lldb] [NFC][ObjectSizeOffset] Use classes instead of std::pair (PR #76882)

2024-01-07 Thread Bill Wendling via lldb-commits

bwendling wrote:

Actually, that fix was making all of the other builds fail:

```
/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/include/llvm/Analysis/MemoryBuiltins.h:279:47:
 error: specialization of ‘llvm::SizeOffsetType’ after instantiation
  279 |   template  friend class SizeOffsetType;
  |   ^~
/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/include/llvm/Analysis/MemoryBuiltins.h:292:47:
 error: specialization of ‘llvm::SizeOffsetType’ after instantiation
  292 |   template  friend class SizeOffsetType;
  |   ^~
32.474 [1989/19/1551] Building CXX object 
lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/AttributorAttributes.cpp.o
FAILED: lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/AttributorAttributes.cpp.o 
ccache /usr/bin/c++ -DCPUINFO_SUPPORTED_PLATFORM=1 -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/b/ml-opt-dev-x86-64-b1/build/lib/Transforms/IPO 
-I/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/lib/Transforms/IPO 
-I/b/ml-opt-dev-x86-64-b1/build/include 
-I/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/include -isystem 
/tmp/tflitebuild/tensorflow/include -isystem 
/tmp/tflitebuild/eigen/include/eigen3 -isystem 
/tmp/tflitebuild/abseil-cpp/include -isystem 
/tmp/tflitebuild/flatbuffers/include -isystem 
/tmp/tflitebuild/gemmlowp/include/gemmlowp -isystem 
/tmp/tflitebuild/ml_dtypes/src/ml_dtypes -isystem 
/tmp/tflitebuild/ml_dtypes/src/ml_dtypes/ml_dtypes -isystem 
/tmp/tflitebuild/ruy/include -isystem /tmp/tflitebuild/cpuinfo/include -isystem 
/tmp/tflitebuild/ARM_NEON_2_x86_SSE/include -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move 
-Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wno-misleading-indentation -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG  -fno-exceptions 
-funwind-tables -fno-rtti -UNDEBUG -DEIGEN_NEON_GEBP_NR=4 
-DTFL_STATIC_LIBRARY_BUILD -std=c++17 -MD -MT 
lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/AttributorAttributes.cpp.o -MF 
lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/AttributorAttributes.cpp.o.d -o 
lib/Transforms/IPO/CMakeFiles/LLVMipo.dir/AttributorAttributes.cpp.o -c 
/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
In file included from 
/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/lib/Transforms/IPO/AttributorAttributes.cpp:35:
/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/include/llvm/Analysis/MemoryBuiltins.h:217:47:
 error: specialization of ‘llvm::SizeOffsetType’ after instantiation
  217 |   template  friend class SizeOffsetType;
  |   ^~
/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/include/llvm/Analysis/MemoryBuiltins.h:279:47:
 error: specialization of ‘llvm::SizeOffsetType’ after instantiation
  279 |   template  friend class SizeOffsetType;
  |   ^~
/b/ml-opt-dev-x86-64-b1/llvm-project/llvm/include/llvm/Analysis/MemoryBuiltins.h:292:47:
 error: specialization of ‘llvm::SizeOffsetType’ after instantiation
  292 |   template  friend class SizeOffsetType;
  |   ^~
33.552 [1989/18/1552] Building AMDGPUGenMCPseudoLowering.inc...
```

So I don't know what can be done here. Is it possible for Visual Studio not to 
use a broken compiler?

https://github.com/llvm/llvm-project/pull/76882
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [clang] [libcxx] [llvm] [clang-tools-extra] [compiler-rt] [mlir] Fix Multiple Build Errors on different platforms (PR #77216)

2024-01-07 Thread via lldb-commits

https://github.com/trcrsired updated 
https://github.com/llvm/llvm-project/pull/77216

>From a1156a564c798192cb7608e28ce9b9ed846a8b1c Mon Sep 17 00:00:00 2001
From: trcrsired 
Date: Sat, 6 Jan 2024 20:21:06 -0500
Subject: [PATCH 1/2] Fix Multiple Build Errors on different platforms

Particularly for canadian compilation
---
 .../pseudo/include/CMakeLists.txt |  12 +-
 clang/lib/Tooling/CMakeLists.txt  |  10 +-
 compiler-rt/lib/builtins/fp_compare_impl.inc  |   3 +
 lldb/source/Host/android/HostInfoAndroid.cpp  |   4 +
 lldb/source/Host/android/LibcGlue.cpp |   2 +
 llvm/include/llvm/TargetParser/Triple.h   | 287 +++---
 llvm/lib/Support/Unix/Unix.h  |  17 +-
 mlir/lib/ExecutionEngine/CRunnerUtils.cpp |   4 +-
 8 files changed, 147 insertions(+), 192 deletions(-)

diff --git a/clang-tools-extra/pseudo/include/CMakeLists.txt 
b/clang-tools-extra/pseudo/include/CMakeLists.txt
index 2334cfa12e3376..605f17dd4591a0 100644
--- a/clang-tools-extra/pseudo/include/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -3,10 +3,18 @@ set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx/cxx.bnf)
 
 setup_host_tool(clang-pseudo-gen CLANG_PSEUDO_GEN pseudo_gen pseudo_gen_target)
 
+if(NOT DEFINED CLANG_PSEUDO_GEN)
+   if(DEFINED LLVM_NATIVE_TOOL_DIR AND NOT LLVM_NATIVE_TOOL_DIR STREQUAL "")
+  set(CLANG_PSEUDO_GEN "${LLVM_NATIVE_TOOL_DIR}/clang_pseudo_gen")
+   else()
+  set(CLANG_PSEUDO_GEN "${pseudo_gen}")
+   endif()
+endif()
+
 # Generate inc files.
 set(cxx_symbols_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXSymbols.inc)
 add_custom_command(OUTPUT ${cxx_symbols_inc}
-   COMMAND "${pseudo_gen}"
+   COMMAND "${CLANG_PSEUDO_GEN}"
  --grammar ${cxx_bnf}
  --emit-symbol-list
  -o ${cxx_symbols_inc}
@@ -16,7 +24,7 @@ add_custom_command(OUTPUT ${cxx_symbols_inc}
 
 set(cxx_bnf_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXBNF.inc)
 add_custom_command(OUTPUT ${cxx_bnf_inc}
-   COMMAND "${pseudo_gen}"
+   COMMAND "${CLANG_PSEUDO_GEN}"
  --grammar ${cxx_bnf}
  --emit-grammar-content
  -o ${cxx_bnf_inc}
diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index aff39e4de13c0b..1510f5fb8a0810 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -53,6 +53,14 @@ else()
 list(APPEND implicitDirs -I ${implicitDir})
   endforeach()
 
+  if(NOT DEFINED CLANG_AST_DUMP)
+if(DEFINED LLVM_NATIVE_TOOL_DIR AND NOT LLVM_NATIVE_TOOL_DIR STREQUAL "")
+  set(CLANG_AST_DUMP ${LLVM_NATIVE_TOOL_DIR}/clang-ast-dump)
+else()
+  set(CLANG_AST_DUMP $)
+endif()
+  endif()
+
   include(GetClangResourceDir)
   get_clang_resource_dir(resource_dir PREFIX ${LLVM_BINARY_DIR})
   add_custom_command(
@@ -60,7 +68,7 @@ else()
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
   DEPENDS clang-ast-dump clang-resource-headers
   COMMAND
-  $
+  ${CLANG_AST_DUMP}
 # Skip this in debug mode because parsing AST.h is too slow
 --skip-processing=${skip_expensive_processing}
 -I ${resource_dir}/include
diff --git a/compiler-rt/lib/builtins/fp_compare_impl.inc 
b/compiler-rt/lib/builtins/fp_compare_impl.inc
index a9a4f6fbf5dfe4..b2ebd0737df033 100644
--- a/compiler-rt/lib/builtins/fp_compare_impl.inc
+++ b/compiler-rt/lib/builtins/fp_compare_impl.inc
@@ -18,6 +18,9 @@ typedef int CMP_RESULT;
 #elif __SIZEOF_POINTER__ == 8 && __SIZEOF_LONG__ == 4
 // LLP64 ABIs use long long instead of long.
 typedef long long CMP_RESULT;
+#elif defined(__wasm64__)
+// GCC uses int as CMP_RESULT
+typedef int CMP_RESULT;
 #elif __AVR__
 // AVR uses a single byte for the return value.
 typedef char CMP_RESULT;
diff --git a/lldb/source/Host/android/HostInfoAndroid.cpp 
b/lldb/source/Host/android/HostInfoAndroid.cpp
index 68440e016afe4b..5ba2f0e24a8d24 100644
--- a/lldb/source/Host/android/HostInfoAndroid.cpp
+++ b/lldb/source/Host/android/HostInfoAndroid.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#ifdef __ANDROID__
+
 #include "lldb/Host/android/HostInfoAndroid.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/linux/HostInfoLinux.h"
@@ -92,3 +94,5 @@ bool HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec 
&file_spec) {
 
   return FileSystem::Instance().Exists(file_spec);
 }
+
+#endif
diff --git a/lldb/source/Host/android/LibcGlue.cpp 
b/lldb/source/Host/android/LibcGlue.cpp
index 877d735823feee..82b257719c2c8a 100644
--- a/lldb/source/Host/android/LibcGlue.cpp
+++ b/lldb/source/Host/android/LibcGlue.cpp
@@ -8,6 +8,7 @@
 
 // This files adds functions missing from libc on earlier versions of Android
 
+#ifdef __ANDROID__
 #include 
 
 #include 
@@ -26,3 +27,4 @@ time_t timegm(struct tm *t) { return (time_t)timegm64(t); }
 int posix_openpt(int flags) { return open("/dev/ptmx", flags); }
 
 #endif
+#endif
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetP

[Lldb-commits] [clang-tools-extra] [lldb] [clang] [libcxx] [compiler-rt] [llvm] [mlir] Fix Multiple Build Errors on different platforms (PR #77216)

2024-01-07 Thread via lldb-commits

https://github.com/trcrsired updated 
https://github.com/llvm/llvm-project/pull/77216

>From a1156a564c798192cb7608e28ce9b9ed846a8b1c Mon Sep 17 00:00:00 2001
From: trcrsired 
Date: Sat, 6 Jan 2024 20:21:06 -0500
Subject: [PATCH 1/2] Fix Multiple Build Errors on different platforms

Particularly for canadian compilation
---
 .../pseudo/include/CMakeLists.txt |  12 +-
 clang/lib/Tooling/CMakeLists.txt  |  10 +-
 compiler-rt/lib/builtins/fp_compare_impl.inc  |   3 +
 lldb/source/Host/android/HostInfoAndroid.cpp  |   4 +
 lldb/source/Host/android/LibcGlue.cpp |   2 +
 llvm/include/llvm/TargetParser/Triple.h   | 287 +++---
 llvm/lib/Support/Unix/Unix.h  |  17 +-
 mlir/lib/ExecutionEngine/CRunnerUtils.cpp |   4 +-
 8 files changed, 147 insertions(+), 192 deletions(-)

diff --git a/clang-tools-extra/pseudo/include/CMakeLists.txt 
b/clang-tools-extra/pseudo/include/CMakeLists.txt
index 2334cfa12e3376..605f17dd4591a0 100644
--- a/clang-tools-extra/pseudo/include/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -3,10 +3,18 @@ set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx/cxx.bnf)
 
 setup_host_tool(clang-pseudo-gen CLANG_PSEUDO_GEN pseudo_gen pseudo_gen_target)
 
+if(NOT DEFINED CLANG_PSEUDO_GEN)
+   if(DEFINED LLVM_NATIVE_TOOL_DIR AND NOT LLVM_NATIVE_TOOL_DIR STREQUAL "")
+  set(CLANG_PSEUDO_GEN "${LLVM_NATIVE_TOOL_DIR}/clang_pseudo_gen")
+   else()
+  set(CLANG_PSEUDO_GEN "${pseudo_gen}")
+   endif()
+endif()
+
 # Generate inc files.
 set(cxx_symbols_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXSymbols.inc)
 add_custom_command(OUTPUT ${cxx_symbols_inc}
-   COMMAND "${pseudo_gen}"
+   COMMAND "${CLANG_PSEUDO_GEN}"
  --grammar ${cxx_bnf}
  --emit-symbol-list
  -o ${cxx_symbols_inc}
@@ -16,7 +24,7 @@ add_custom_command(OUTPUT ${cxx_symbols_inc}
 
 set(cxx_bnf_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXBNF.inc)
 add_custom_command(OUTPUT ${cxx_bnf_inc}
-   COMMAND "${pseudo_gen}"
+   COMMAND "${CLANG_PSEUDO_GEN}"
  --grammar ${cxx_bnf}
  --emit-grammar-content
  -o ${cxx_bnf_inc}
diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index aff39e4de13c0b..1510f5fb8a0810 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -53,6 +53,14 @@ else()
 list(APPEND implicitDirs -I ${implicitDir})
   endforeach()
 
+  if(NOT DEFINED CLANG_AST_DUMP)
+if(DEFINED LLVM_NATIVE_TOOL_DIR AND NOT LLVM_NATIVE_TOOL_DIR STREQUAL "")
+  set(CLANG_AST_DUMP ${LLVM_NATIVE_TOOL_DIR}/clang-ast-dump)
+else()
+  set(CLANG_AST_DUMP $)
+endif()
+  endif()
+
   include(GetClangResourceDir)
   get_clang_resource_dir(resource_dir PREFIX ${LLVM_BINARY_DIR})
   add_custom_command(
@@ -60,7 +68,7 @@ else()
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
   DEPENDS clang-ast-dump clang-resource-headers
   COMMAND
-  $
+  ${CLANG_AST_DUMP}
 # Skip this in debug mode because parsing AST.h is too slow
 --skip-processing=${skip_expensive_processing}
 -I ${resource_dir}/include
diff --git a/compiler-rt/lib/builtins/fp_compare_impl.inc 
b/compiler-rt/lib/builtins/fp_compare_impl.inc
index a9a4f6fbf5dfe4..b2ebd0737df033 100644
--- a/compiler-rt/lib/builtins/fp_compare_impl.inc
+++ b/compiler-rt/lib/builtins/fp_compare_impl.inc
@@ -18,6 +18,9 @@ typedef int CMP_RESULT;
 #elif __SIZEOF_POINTER__ == 8 && __SIZEOF_LONG__ == 4
 // LLP64 ABIs use long long instead of long.
 typedef long long CMP_RESULT;
+#elif defined(__wasm64__)
+// GCC uses int as CMP_RESULT
+typedef int CMP_RESULT;
 #elif __AVR__
 // AVR uses a single byte for the return value.
 typedef char CMP_RESULT;
diff --git a/lldb/source/Host/android/HostInfoAndroid.cpp 
b/lldb/source/Host/android/HostInfoAndroid.cpp
index 68440e016afe4b..5ba2f0e24a8d24 100644
--- a/lldb/source/Host/android/HostInfoAndroid.cpp
+++ b/lldb/source/Host/android/HostInfoAndroid.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#ifdef __ANDROID__
+
 #include "lldb/Host/android/HostInfoAndroid.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/linux/HostInfoLinux.h"
@@ -92,3 +94,5 @@ bool HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec 
&file_spec) {
 
   return FileSystem::Instance().Exists(file_spec);
 }
+
+#endif
diff --git a/lldb/source/Host/android/LibcGlue.cpp 
b/lldb/source/Host/android/LibcGlue.cpp
index 877d735823feee..82b257719c2c8a 100644
--- a/lldb/source/Host/android/LibcGlue.cpp
+++ b/lldb/source/Host/android/LibcGlue.cpp
@@ -8,6 +8,7 @@
 
 // This files adds functions missing from libc on earlier versions of Android
 
+#ifdef __ANDROID__
 #include 
 
 #include 
@@ -26,3 +27,4 @@ time_t timegm(struct tm *t) { return (time_t)timegm64(t); }
 int posix_openpt(int flags) { return open("/dev/ptmx", flags); }
 
 #endif
+#endif
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetP

[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-07 Thread Nicholas Mosier via lldb-commits

https://github.com/nmosier created 
https://github.com/llvm/llvm-project/pull/77252

Fix #77251.

>From c8b55528ce76a5d3ae1736a0f73499d96173d927 Mon Sep 17 00:00:00 2001
From: Nicholas Mosier 
Date: Sun, 7 Jan 2024 20:06:55 +
Subject: [PATCH] [lldb] Fix Intel PT plugin compile errors

Fix #77251.
---
 .../intel-pt/CommandObjectTraceStartIntelPT.cpp  |  4 +---
 lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp |  5 +
 lldb/source/Plugins/Trace/intel-pt/DecodedThread.h   |  4 
 lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp |  4 ++--
 .../Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp|  4 ++--
 .../Trace/intel-pt/TraceIntelPTBundleLoader.cpp  | 12 +---
 6 files changed, 19 insertions(+), 14 deletions(-)

diff --git 
a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
index d4f7dc354e9fed..44224229e625bf 100644
--- a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
@@ -158,7 +158,7 @@ 
CommandObjectProcessTraceStartIntelPT::CommandOptions::GetDefinitions() {
   return llvm::ArrayRef(g_process_trace_start_intel_pt_options);
 }
 
-bool CommandObjectProcessTraceStartIntelPT::DoExecute(
+void CommandObjectProcessTraceStartIntelPT::DoExecute(
 Args &command, CommandReturnObject &result) {
   if (Error err = m_trace.Start(
   m_options.m_ipt_trace_size, m_options.m_process_buffer_size_limit,
@@ -167,8 +167,6 @@ bool CommandObjectProcessTraceStartIntelPT::DoExecute(
 result.SetError(Status(std::move(err)));
   else
 result.SetStatus(eReturnStatusSuccessFinishResult);
-
-  return result.Succeeded();
 }
 
 std::optional
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
index 17f8f51bdf0e0d..145e0386f6a023 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
@@ -85,6 +85,11 @@ double DecodedThread::NanosecondsRange::GetInterpolatedTime(
   return interpolate(next_range->nanos);
 }
 
+DecodedThread::TraceItemStorage::TraceItemStorage(
+const TraceItemStorage &other) {
+  std::memcpy(this, &other, sizeof *this);
+}
+
 uint64_t DecodedThread::GetItemsCount() const { return m_item_kinds.size(); }
 
 lldb::addr_t
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
index 5745cdb67ab68f..88bf748d186a36 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
@@ -276,6 +276,10 @@ class DecodedThread : public 
std::enable_shared_from_this {
 
 /// The string message of this item if it's an error
 std::string error;
+
+TraceItemStorage() {}
+~TraceItemStorage() {}
+TraceItemStorage(const TraceItemStorage &other);
   };
 
   /// Create a new trace item.
diff --git a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp 
b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
index cdf81954eee902..f8241ef6a79329 100644
--- a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
@@ -572,7 +572,7 @@ Error 
lldb_private::trace_intel_pt::DecodeSingleTraceForThread(
 Expected decoder = PSBBlockDecoder::Create(
 trace_intel_pt, block, buffer.slice(block.psb_offset, block.size),
 *decoded_thread.GetThread()->GetProcess(),
-i + 1 < blocks->size() ? blocks->at(i + 1).starting_ip : None,
+i + 1 < blocks->size() ? blocks->at(i + 1).starting_ip : std::nullopt,
 decoded_thread, std::nullopt);
 if (!decoder)
   return decoder.takeError();
@@ -640,7 +640,7 @@ Error 
lldb_private::trace_intel_pt::DecodeSystemWideTraceForThread(
   *decoded_thread.GetThread()->GetProcess(),
   j + 1 < execution.psb_blocks.size()
   ? execution.psb_blocks[j + 1].starting_ip
-  : None,
+  : std::nullopt,
   decoded_thread, execution.thread_execution.GetEndTSC());
   if (!decoder)
 return decoder.takeError();
diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
index 66d342196cf10d..dda6cd74343f0f 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
@@ -35,7 +35,7 @@ void TraceCursorIntelPT::Next() {
 void TraceCursorIntelPT::ClearTimingRangesIfInvalid() {
   if (m_tsc_range_calculated) {
 if (!m_tsc_range || m_pos < 0 || !m_tsc_range->InRange(m_pos)) {
-  m_tsc_range = None;
+  m_tsc_range = std::nullopt;
   m_tsc_range_calculated = false;
 }
   }
@@ -43,7 +43,7 @@ void TraceCursorIntelPT::ClearTimingRangesIfInvalid() {
   if (m_nanoseconds_range_calculated) {
 if (!m_n

[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-07 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Nicholas Mosier (nmosier)


Changes

Fix #77251.

---
Full diff: https://github.com/llvm/llvm-project/pull/77252.diff


6 Files Affected:

- (modified) 
lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp (+1-3) 
- (modified) lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp (+5) 
- (modified) lldb/source/Plugins/Trace/intel-pt/DecodedThread.h (+4) 
- (modified) lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp (+2-2) 
- (modified) lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp (+2-2) 
- (modified) lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp 
(+5-7) 


``diff
diff --git 
a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
index d4f7dc354e9fed..44224229e625bf 100644
--- a/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
@@ -158,7 +158,7 @@ 
CommandObjectProcessTraceStartIntelPT::CommandOptions::GetDefinitions() {
   return llvm::ArrayRef(g_process_trace_start_intel_pt_options);
 }
 
-bool CommandObjectProcessTraceStartIntelPT::DoExecute(
+void CommandObjectProcessTraceStartIntelPT::DoExecute(
 Args &command, CommandReturnObject &result) {
   if (Error err = m_trace.Start(
   m_options.m_ipt_trace_size, m_options.m_process_buffer_size_limit,
@@ -167,8 +167,6 @@ bool CommandObjectProcessTraceStartIntelPT::DoExecute(
 result.SetError(Status(std::move(err)));
   else
 result.SetStatus(eReturnStatusSuccessFinishResult);
-
-  return result.Succeeded();
 }
 
 std::optional
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
index 17f8f51bdf0e0d..145e0386f6a023 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
@@ -85,6 +85,11 @@ double DecodedThread::NanosecondsRange::GetInterpolatedTime(
   return interpolate(next_range->nanos);
 }
 
+DecodedThread::TraceItemStorage::TraceItemStorage(
+const TraceItemStorage &other) {
+  std::memcpy(this, &other, sizeof *this);
+}
+
 uint64_t DecodedThread::GetItemsCount() const { return m_item_kinds.size(); }
 
 lldb::addr_t
diff --git a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h 
b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
index 5745cdb67ab68f..88bf748d186a36 100644
--- a/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
+++ b/lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
@@ -276,6 +276,10 @@ class DecodedThread : public 
std::enable_shared_from_this {
 
 /// The string message of this item if it's an error
 std::string error;
+
+TraceItemStorage() {}
+~TraceItemStorage() {}
+TraceItemStorage(const TraceItemStorage &other);
   };
 
   /// Create a new trace item.
diff --git a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp 
b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
index cdf81954eee902..f8241ef6a79329 100644
--- a/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
@@ -572,7 +572,7 @@ Error 
lldb_private::trace_intel_pt::DecodeSingleTraceForThread(
 Expected decoder = PSBBlockDecoder::Create(
 trace_intel_pt, block, buffer.slice(block.psb_offset, block.size),
 *decoded_thread.GetThread()->GetProcess(),
-i + 1 < blocks->size() ? blocks->at(i + 1).starting_ip : None,
+i + 1 < blocks->size() ? blocks->at(i + 1).starting_ip : std::nullopt,
 decoded_thread, std::nullopt);
 if (!decoder)
   return decoder.takeError();
@@ -640,7 +640,7 @@ Error 
lldb_private::trace_intel_pt::DecodeSystemWideTraceForThread(
   *decoded_thread.GetThread()->GetProcess(),
   j + 1 < execution.psb_blocks.size()
   ? execution.psb_blocks[j + 1].starting_ip
-  : None,
+  : std::nullopt,
   decoded_thread, execution.thread_execution.GetEndTSC());
   if (!decoder)
 return decoder.takeError();
diff --git a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp 
b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
index 66d342196cf10d..dda6cd74343f0f 100644
--- a/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
+++ b/lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
@@ -35,7 +35,7 @@ void TraceCursorIntelPT::Next() {
 void TraceCursorIntelPT::ClearTimingRangesIfInvalid() {
   if (m_tsc_range_calculated) {
 if (!m_tsc_range || m_pos < 0 || !m_tsc_range->InRange(m_pos)) {
-  m_tsc_range = None;
+  m_tsc_range = std::nullopt;
   m_tsc_range_calculated = false;
 }
   }
@@ -43,7 +43,7 @@ void TraceCursorIntelPT::ClearTimingRangesIfInvalid() {
   if (m_nanoseconds_range_calculated) {
 if (!m_nanoseconds_range || m_pos < 0 ||
 !m_nanoseconds_range->InRan

[Lldb-commits] [clang] [llvm] [lld] [clang-tools-extra] [lldb] [mlir] [libc] [compiler-rt] [libcxx] Fix Multiple Build Errors on different platforms (PR #77216)

2024-01-07 Thread via lldb-commits

https://github.com/trcrsired updated 
https://github.com/llvm/llvm-project/pull/77216

>From a1156a564c798192cb7608e28ce9b9ed846a8b1c Mon Sep 17 00:00:00 2001
From: trcrsired 
Date: Sat, 6 Jan 2024 20:21:06 -0500
Subject: [PATCH 1/2] Fix Multiple Build Errors on different platforms

Particularly for canadian compilation
---
 .../pseudo/include/CMakeLists.txt |  12 +-
 clang/lib/Tooling/CMakeLists.txt  |  10 +-
 compiler-rt/lib/builtins/fp_compare_impl.inc  |   3 +
 lldb/source/Host/android/HostInfoAndroid.cpp  |   4 +
 lldb/source/Host/android/LibcGlue.cpp |   2 +
 llvm/include/llvm/TargetParser/Triple.h   | 287 +++---
 llvm/lib/Support/Unix/Unix.h  |  17 +-
 mlir/lib/ExecutionEngine/CRunnerUtils.cpp |   4 +-
 8 files changed, 147 insertions(+), 192 deletions(-)

diff --git a/clang-tools-extra/pseudo/include/CMakeLists.txt 
b/clang-tools-extra/pseudo/include/CMakeLists.txt
index 2334cfa12e3376..605f17dd4591a0 100644
--- a/clang-tools-extra/pseudo/include/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -3,10 +3,18 @@ set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx/cxx.bnf)
 
 setup_host_tool(clang-pseudo-gen CLANG_PSEUDO_GEN pseudo_gen pseudo_gen_target)
 
+if(NOT DEFINED CLANG_PSEUDO_GEN)
+   if(DEFINED LLVM_NATIVE_TOOL_DIR AND NOT LLVM_NATIVE_TOOL_DIR STREQUAL "")
+  set(CLANG_PSEUDO_GEN "${LLVM_NATIVE_TOOL_DIR}/clang_pseudo_gen")
+   else()
+  set(CLANG_PSEUDO_GEN "${pseudo_gen}")
+   endif()
+endif()
+
 # Generate inc files.
 set(cxx_symbols_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXSymbols.inc)
 add_custom_command(OUTPUT ${cxx_symbols_inc}
-   COMMAND "${pseudo_gen}"
+   COMMAND "${CLANG_PSEUDO_GEN}"
  --grammar ${cxx_bnf}
  --emit-symbol-list
  -o ${cxx_symbols_inc}
@@ -16,7 +24,7 @@ add_custom_command(OUTPUT ${cxx_symbols_inc}
 
 set(cxx_bnf_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXBNF.inc)
 add_custom_command(OUTPUT ${cxx_bnf_inc}
-   COMMAND "${pseudo_gen}"
+   COMMAND "${CLANG_PSEUDO_GEN}"
  --grammar ${cxx_bnf}
  --emit-grammar-content
  -o ${cxx_bnf_inc}
diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt
index aff39e4de13c0b..1510f5fb8a0810 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -53,6 +53,14 @@ else()
 list(APPEND implicitDirs -I ${implicitDir})
   endforeach()
 
+  if(NOT DEFINED CLANG_AST_DUMP)
+if(DEFINED LLVM_NATIVE_TOOL_DIR AND NOT LLVM_NATIVE_TOOL_DIR STREQUAL "")
+  set(CLANG_AST_DUMP ${LLVM_NATIVE_TOOL_DIR}/clang-ast-dump)
+else()
+  set(CLANG_AST_DUMP $)
+endif()
+  endif()
+
   include(GetClangResourceDir)
   get_clang_resource_dir(resource_dir PREFIX ${LLVM_BINARY_DIR})
   add_custom_command(
@@ -60,7 +68,7 @@ else()
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
   DEPENDS clang-ast-dump clang-resource-headers
   COMMAND
-  $
+  ${CLANG_AST_DUMP}
 # Skip this in debug mode because parsing AST.h is too slow
 --skip-processing=${skip_expensive_processing}
 -I ${resource_dir}/include
diff --git a/compiler-rt/lib/builtins/fp_compare_impl.inc 
b/compiler-rt/lib/builtins/fp_compare_impl.inc
index a9a4f6fbf5dfe4..b2ebd0737df033 100644
--- a/compiler-rt/lib/builtins/fp_compare_impl.inc
+++ b/compiler-rt/lib/builtins/fp_compare_impl.inc
@@ -18,6 +18,9 @@ typedef int CMP_RESULT;
 #elif __SIZEOF_POINTER__ == 8 && __SIZEOF_LONG__ == 4
 // LLP64 ABIs use long long instead of long.
 typedef long long CMP_RESULT;
+#elif defined(__wasm64__)
+// GCC uses int as CMP_RESULT
+typedef int CMP_RESULT;
 #elif __AVR__
 // AVR uses a single byte for the return value.
 typedef char CMP_RESULT;
diff --git a/lldb/source/Host/android/HostInfoAndroid.cpp 
b/lldb/source/Host/android/HostInfoAndroid.cpp
index 68440e016afe4b..5ba2f0e24a8d24 100644
--- a/lldb/source/Host/android/HostInfoAndroid.cpp
+++ b/lldb/source/Host/android/HostInfoAndroid.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#ifdef __ANDROID__
+
 #include "lldb/Host/android/HostInfoAndroid.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/linux/HostInfoLinux.h"
@@ -92,3 +94,5 @@ bool HostInfoAndroid::ComputeTempFileBaseDirectory(FileSpec 
&file_spec) {
 
   return FileSystem::Instance().Exists(file_spec);
 }
+
+#endif
diff --git a/lldb/source/Host/android/LibcGlue.cpp 
b/lldb/source/Host/android/LibcGlue.cpp
index 877d735823feee..82b257719c2c8a 100644
--- a/lldb/source/Host/android/LibcGlue.cpp
+++ b/lldb/source/Host/android/LibcGlue.cpp
@@ -8,6 +8,7 @@
 
 // This files adds functions missing from libc on earlier versions of Android
 
+#ifdef __ANDROID__
 #include 
 
 #include 
@@ -26,3 +27,4 @@ time_t timegm(struct tm *t) { return (time_t)timegm64(t); }
 int posix_openpt(int flags) { return open("/dev/ptmx", flags); }
 
 #endif
+#endif
diff --git a/llvm/include/llvm/TargetParser/Triple.h 
b/llvm/include/llvm/TargetP

[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-07 Thread Jonas Devlieghere via lldb-commits


@@ -85,6 +85,11 @@ double DecodedThread::NanosecondsRange::GetInterpolatedTime(
   return interpolate(next_range->nanos);
 }
 
+DecodedThread::TraceItemStorage::TraceItemStorage(
+const TraceItemStorage &other) {
+  std::memcpy(this, &other, sizeof *this);

JDevlieghere wrote:

Does the `DecodedThread` know which member of the `TraceItemStorage` is being 
used? If so, you can pass an additional argument and copy the right member 
rather than just copying the bytes. 

https://github.com/llvm/llvm-project/pull/77252
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-07 Thread Jonas Devlieghere via lldb-commits


@@ -103,12 +103,10 @@ TraceIntelPTBundleLoader::CreateEmptyProcess(lldb::pid_t 
pid,
   ParsedProcess parsed_process;
   parsed_process.target_sp = target_sp;
 
-  // This should instead try to directly create an instance of ProcessTrace.
-  // ProcessSP process_sp = target_sp->CreateProcess(
-  ///*listener*/ nullptr, "trace",
-  ///*crash_file*/ nullptr,
-  ///*can_connect*/ false);
-
+  ProcessSP process_sp = target_sp->CreateProcess(
+  /*listener*/ nullptr, "trace",
+  /*crash_file*/ nullptr,
+  /*can_connect*/ false);

JDevlieghere wrote:

Should the original comment be kept as a FIXME? 

https://github.com/llvm/llvm-project/pull/77252
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Fix Intel PT plugin compile errors (PR #77252)

2024-01-07 Thread Jonas Devlieghere via lldb-commits


@@ -276,6 +276,10 @@ class DecodedThread : public 
std::enable_shared_from_this {
 
 /// The string message of this item if it's an error
 std::string error;
+
+TraceItemStorage() {}
+~TraceItemStorage() {}

JDevlieghere wrote:

Can this be `= default`?

https://github.com/llvm/llvm-project/pull/77252
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [libunwind] [flang] [lldb] [libcxx] [clang] [libc] [compiler-rt] [llvm] [clang-tools-extra] [lld] [libc++][test] try to directly create socket file in /tmp when filepath is too long (PR

2024-01-07 Thread Wu Yingcong via lldb-commits

https://github.com/yingcong-wu updated 
https://github.com/llvm/llvm-project/pull/77058

>From 202fb858344d102bd5199cd749bb15195dbce558 Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" 
Date: Fri, 5 Jan 2024 00:48:34 -0800
Subject: [PATCH 1/7] try to directly create file in /tmp when filepath is too
 long

---
 libcxx/test/support/filesystem_test_helper.h | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libcxx/test/support/filesystem_test_helper.h 
b/libcxx/test/support/filesystem_test_helper.h
index a049efe03d844e..271b2bb5cafe23 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include  // for printf
+#include 
 #include 
 #include 
 #include 
@@ -324,10 +325,22 @@ struct scoped_test_env
 
 ::sockaddr_un address;
 address.sun_family = AF_UNIX;
+
+// If file.size() is too big, try to create a file directly inside
+// /tmp to make sure file path is short enough.
+if (file.size() <= sizeof(address.sun_path) && utils::exists("/tmp")) {
+fs::path const tmp = "/tmp";
+std::size_t i  = 
std::hash()(std::to_string(std::time(nullptr)));
+fs::path p = tmp / ("libcxx-socket-" + file + "-" + 
std::to_string(i));
+while (utils::exists(p.string())) {
+  p = tmp / ("libcxx-socket-" + file + "-" + std::to_string(++i));
+}
+file = p.string();
+}
 assert(file.size() <= sizeof(address.sun_path));
 ::strncpy(address.sun_path, file.c_str(), sizeof(address.sun_path));
 int fd = ::socket(AF_UNIX, SOCK_STREAM, 0);
-::bind(fd, reinterpret_cast<::sockaddr*>(&address), sizeof(address));
+assert(::bind(fd, reinterpret_cast<::sockaddr*>(&address), 
sizeof(address)) == 0);
 return file;
 }
 #endif

>From 5d64d75bf7ad8422eb54594fa8cc8dfda7f14e4e Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" 
Date: Fri, 5 Jan 2024 01:13:24 -0800
Subject: [PATCH 2/7] format

---
 libcxx/test/support/filesystem_test_helper.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libcxx/test/support/filesystem_test_helper.h 
b/libcxx/test/support/filesystem_test_helper.h
index 271b2bb5cafe23..d33fcf5497f084 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -329,13 +329,13 @@ struct scoped_test_env
 // If file.size() is too big, try to create a file directly inside
 // /tmp to make sure file path is short enough.
 if (file.size() <= sizeof(address.sun_path) && utils::exists("/tmp")) {
-fs::path const tmp = "/tmp";
-std::size_t i  = 
std::hash()(std::to_string(std::time(nullptr)));
-fs::path p = tmp / ("libcxx-socket-" + file + "-" + 
std::to_string(i));
-while (utils::exists(p.string())) {
-  p = tmp / ("libcxx-socket-" + file + "-" + std::to_string(++i));
-}
-file = p.string();
+  fs::path const tmp = "/tmp";
+  std::size_t i  = 
std::hash()(std::to_string(std::time(nullptr)));
+  fs::path p = tmp / ("libcxx-socket-" + file + "-" + 
std::to_string(i));
+  while (utils::exists(p.string())) {
+p = tmp / ("libcxx-socket-" + file + "-" + std::to_string(++i));
+  }
+  file = p.string();
 }
 assert(file.size() <= sizeof(address.sun_path));
 ::strncpy(address.sun_path, file.c_str(), sizeof(address.sun_path));

>From ec6ff976d4e338fb1cd219409ee47b75b3b6a324 Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" 
Date: Fri, 5 Jan 2024 01:59:22 -0800
Subject: [PATCH 3/7] fix error

---
 libcxx/test/support/filesystem_test_helper.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libcxx/test/support/filesystem_test_helper.h 
b/libcxx/test/support/filesystem_test_helper.h
index d33fcf5497f084..001625d97775f8 100644
--- a/libcxx/test/support/filesystem_test_helper.h
+++ b/libcxx/test/support/filesystem_test_helper.h
@@ -321,27 +321,27 @@ struct scoped_test_env
   // allow tests to call this unguarded.
 #if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(_WIN32)
 std::string create_socket(std::string file) {
-file = sanitize_path(std::move(file));
+std::string socket_file = sanitize_path(file);
 
 ::sockaddr_un address;
 address.sun_family = AF_UNIX;
 
 // If file.size() is too big, try to create a file directly inside
 // /tmp to make sure file path is short enough.
-if (file.size() <= sizeof(address.sun_path) && utils::exists("/tmp")) {
+if (socket_file.size() <= sizeof(address.sun_path) && 
utils::exists("/tmp")) {
   fs::path const tmp = "/tmp";
   std::size_t i  = 
std::hash()(std::to_string(std::time(nullptr)));