[llvm-branch-commits] [compiler-rt] 385a6f3 - Prevent generation of dependency on _cxa_guard for static initialization

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jun 21 21:43:52 PDT 2021


Author: serge-sans-paille
Date: 2021-06-22T00:43:08-04:00
New Revision: 385a6f37fefbeb1397f1c3733f328bb2b0403e2b

URL: https://github.com/llvm/llvm-project/commit/385a6f37fefbeb1397f1c3733f328bb2b0403e2b
DIFF: https://github.com/llvm/llvm-project/commit/385a6f37fefbeb1397f1c3733f328bb2b0403e2b.diff

LOG: Prevent generation of dependency on _cxa_guard for static initialization

This fixes an issue introduced by https://reviews.llvm.org/D70662

Function-scope static initialization are guarded in C++, so we should probably
not use it because it introduces a dependency on __cxa_guard* symbols.
In the context of clang, libasan is linked statically, and it currently needs to
the odd situation where compiling C code with clang and asan requires -lstdc++

Differential Revision: https://reviews.llvm.org/D102475

(cherry picked from commit 414482751452e54710f16bae58458c66298aaf69)

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
index 2b10bdd37293a..12603da1750d1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
@@ -166,9 +166,10 @@ bool SupportsColoredOutput(fd_t fd) {
 #if !SANITIZER_GO
 // TODO(glider): 
diff erent tools may require 
diff erent altstack size.
 static uptr GetAltStackSize() {
-  // SIGSTKSZ is not enough.
-  static const uptr kAltStackSize = SIGSTKSZ * 4;
-  return kAltStackSize;
+  // Note: since GLIBC_2.31, SIGSTKSZ may be a function call, so this may be
+  // more costly that you think. However GetAltStackSize is only call 2-3 times
+  // per thread so don't cache the evaluation.
+  return SIGSTKSZ * 4;
 }
 
 void SetAlternateSignalStack() {


        


More information about the llvm-branch-commits mailing list