[libc-commits] [libc] 3d0a367 - [libc] Make errno asserts noop on gpu targets (#166606)
via libc-commits
libc-commits at lists.llvm.org
Wed Nov 5 11:17:18 PST 2025
Author: Marcell Leleszi
Date: 2025-11-05T11:17:13-08:00
New Revision: 3d0a3674d9ae52ed685ce467a48653cc27a2e5eb
URL: https://github.com/llvm/llvm-project/commit/3d0a3674d9ae52ed685ce467a48653cc27a2e5eb
DIFF: https://github.com/llvm/llvm-project/commit/3d0a3674d9ae52ed685ce467a48653cc27a2e5eb.diff
LOG: [libc] Make errno asserts noop on gpu targets (#166606)
This patch defines errno unit and integration test asserts as noop on
GPU targets. Checking for errnos is tests has caused build breakages in
previous patches.
Added:
Modified:
libc/test/IntegrationTest/CMakeLists.txt
libc/test/IntegrationTest/test.h
libc/test/UnitTest/CMakeLists.txt
libc/test/UnitTest/ErrnoCheckingTest.h
Removed:
################################################################################
diff --git a/libc/test/IntegrationTest/CMakeLists.txt b/libc/test/IntegrationTest/CMakeLists.txt
index 235e9fe2f55ee..d0752ea178429 100644
--- a/libc/test/IntegrationTest/CMakeLists.txt
+++ b/libc/test/IntegrationTest/CMakeLists.txt
@@ -14,5 +14,6 @@ add_object_library(
libc.hdr.stdint_proxy
libc.src.__support.OSUtil.osutil
libc.src.__support.CPP.atomic
+ libc.src.__support.macros.properties.architectures
${arch_specific_deps}
)
diff --git a/libc/test/IntegrationTest/test.h b/libc/test/IntegrationTest/test.h
index 4a03f7aa6318b..9f5a3dfb3583c 100644
--- a/libc/test/IntegrationTest/test.h
+++ b/libc/test/IntegrationTest/test.h
@@ -11,6 +11,7 @@
#include "src/__support/OSUtil/exit.h"
#include "src/__support/OSUtil/io.h"
+#include "src/__support/macros/properties/architectures.h"
#define __AS_STRING(val) #val
#define __CHECK_TRUE(file, line, val, should_exit) \
@@ -68,9 +69,15 @@
////////////////////////////////////////////////////////////////////////////////
// Errno checks.
+#ifdef LIBC_TARGET_ARCH_IS_GPU
+#define ASSERT_ERRNO_EQ(VAL)
+#define ASSERT_ERRNO_SUCCESS()
+#define ASSERT_ERRNO_FAILURE()
+#else
#define ASSERT_ERRNO_EQ(VAL) ASSERT_EQ(VAL, static_cast<int>(errno))
#define ASSERT_ERRNO_SUCCESS() ASSERT_EQ(0, static_cast<int>(errno))
#define ASSERT_ERRNO_FAILURE() ASSERT_NE(0, static_cast<int>(errno))
+#endif
// Integration tests are compiled with -ffreestanding which stops treating
// the main function as a non-overloadable special function. Hence, we use a
diff --git a/libc/test/UnitTest/CMakeLists.txt b/libc/test/UnitTest/CMakeLists.txt
index 31d1e9dce8204..3197b3d7fd01b 100644
--- a/libc/test/UnitTest/CMakeLists.txt
+++ b/libc/test/UnitTest/CMakeLists.txt
@@ -204,5 +204,6 @@ add_header_library(
ErrnoCheckingTest.h
DEPENDS
libc.src.__support.common
+ libc.src.__support.macros.properties.architectures
libc.src.errno.errno
)
diff --git a/libc/test/UnitTest/ErrnoCheckingTest.h b/libc/test/UnitTest/ErrnoCheckingTest.h
index 5b1bc9441d830..111d812c58612 100644
--- a/libc/test/UnitTest/ErrnoCheckingTest.h
+++ b/libc/test/UnitTest/ErrnoCheckingTest.h
@@ -11,11 +11,17 @@
#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/architectures.h"
#include "test/UnitTest/Test.h"
// Define macro to validate the value stored in the errno and restore it
// to zero.
+#ifdef LIBC_TARGET_ARCH_IS_GPU
+#define ASSERT_ERRNO_EQ(VAL)
+#define ASSERT_ERRNO_SUCCESS()
+#define ASSERT_ERRNO_FAILURE()
+#else
#define ASSERT_ERRNO_EQ(VAL) \
do { \
ASSERT_EQ(VAL, static_cast<int>(libc_errno)); \
@@ -27,6 +33,7 @@
ASSERT_NE(0, static_cast<int>(libc_errno)); \
libc_errno = 0; \
} while (0)
+#endif
namespace LIBC_NAMESPACE_DECL {
namespace testing {
More information about the libc-commits
mailing list