Bug 1775537 [wpt PR 34536] - Rename CanvasFilter WPTs to be tentative, a=testonly
[gecko.git] / build / build-clang / find_symbolizer_linux_clang_15.patch
blobc7caee87042326335b264f0c8fba1a2ceba85d25
1 diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
2 index c3e08f58c2ce..b5c5b9e3e74a 100644
3 --- a/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
4 +++ b/compiler-rt/lib/sanitizer_common/sanitizer_file.cpp
5 @@ -21,6 +21,10 @@
6 #include "sanitizer_file.h"
7 # include "sanitizer_interface_internal.h"
9 +#if SANITIZER_LINUX
10 +#include "sanitizer_posix.h"
11 +#endif
13 namespace __sanitizer {
15 void CatastrophicErrorWrite(const char *buffer, uptr length) {
16 @@ -222,6 +226,34 @@ char *FindPathToBinary(const char *name) {
17 if (*end == '\0') break;
18 beg = end + 1;
21 +#if SANITIZER_LINUX
22 + // If we cannot find the requested binary in PATH, we should try to locate
23 + // it next to the binary, in case it is shipped with the build itself
24 + // (e.g. llvm-symbolizer shipped with sanitizer build to symbolize on client.
25 + if (internal_readlink("/proc/self/exe", buffer.data(), kMaxPathLength) < 0)
26 + return nullptr;
28 + uptr buf_len = internal_strlen(buffer.data());
30 + /* Avoid using dirname() here */
31 + while (buf_len > 0) {
32 + if (buffer[buf_len - 1] == '/')
33 + break;
34 + buf_len--;
35 + }
37 + if (!buf_len)
38 + return nullptr;
40 + if (buf_len + name_len + 1 <= kMaxPathLength) {
41 + internal_memcpy(&buffer[buf_len], name, name_len);
42 + buffer[buf_len + name_len] = '\0';
43 + if (FileExists(buffer.data()))
44 + return internal_strdup(buffer.data());
45 + }
46 +#endif
48 return nullptr;