[libc-commits] [libc] b5440e4 - [libc] Fix cyclical dependency on errno matcher for NVPTX architectures

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Sat Sep 23 06:59:43 PDT 2023


Author: Joseph Huber
Date: 2023-09-23T08:59:34-05:00
New Revision: b5440e443a87e5519d6323bd942a272d328ae255

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

LOG: [libc] Fix cyclical dependency on errno matcher for NVPTX architectures

Summary:
The NVPTX backend cannot handle cyclical dependencies on global variable
initializers. That is, a global variable cannot be used to initialize or
reference another global variable inside of it. This situation was
encountered with the new errno tests. This patch simply replaces the
offending function with a constant version to break the dependency and
alllow the tests to run again.

Added: 
    

Modified: 
    libc/test/UnitTest/ErrnoSetterMatcher.h

Removed: 
    


################################################################################
diff  --git a/libc/test/UnitTest/ErrnoSetterMatcher.h b/libc/test/UnitTest/ErrnoSetterMatcher.h
index e0d22f04431fe43..e55beb52d79ae33 100644
--- a/libc/test/UnitTest/ErrnoSetterMatcher.h
+++ b/libc/test/UnitTest/ErrnoSetterMatcher.h
@@ -49,7 +49,13 @@ template <typename T> struct Comparator {
     __builtin_unreachable();
   }
 
+  // The NVPTX backend cannot handle circular dependencies on global variables.
+  // We provide a constant dummy implementation to prevent this from occurring.
+#ifdef LIBC_TARGET_ARCH_IS_NVPTX
+  constexpr const char *str() { return ""; }
+#else
   const char *str() { return CompareMessage[static_cast<int>(cmp)]; }
+#endif
 };
 
 template <typename T> class ErrnoSetterMatcher : public Matcher<T> {


        


More information about the libc-commits mailing list