[libcxx-commits] [libcxx] [llvm] [libcxx] Add `LIBCXX_HAS_TERMINAL_AVAILABLE` CMake option to disable `print` terminal checks (PR #99259)
Joseph Huber via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Aug 14 10:08:21 PDT 2024
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/99259
>From 670192d5d36a58fad96872759abc74324f770269 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Tue, 16 Jul 2024 18:49:38 -0500
Subject: [PATCH 1/3] [libcxx] Make terminal check always false for `print` on
GPU
Summary:
This check must be handled in order to compile. The GPU cannot easily
determine if a given `FILE *` is a terminal because the `stdio`
interface is actually a wrapper over the system's `FILE *`, so we can't
really detect it easily. An RPC call could be made to `isatty` if we
really need to support this in the future.
---
libcxx/CMakeLists.txt | 2 ++
libcxx/include/__config_site.in | 1 +
libcxx/include/print | 2 +-
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 6168c76bff6d99..3699eca640772f 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -297,6 +297,7 @@ option(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32
option(LIBCXX_HAS_EXTERNAL_THREAD_API
"Build libc++ with an externalized threading API.
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
+option(LIBCXX_HAS_TERMINAL_AVAILABLE "Build libc++ with terminal checking support" ON)
if (LIBCXX_ENABLE_THREADS)
set(LIBCXX_PSTL_BACKEND "std_thread" CACHE STRING "Which PSTL backend to use")
@@ -744,6 +745,7 @@ config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM)
config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT)
config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS)
config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
+config_define_if_not(LIBCXX_HAS_TERMINAL_AVAILABLE _LIBCPP_HAS_NO_TERMINAL)
if (NOT LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION STREQUAL "default")
config_define("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION)
endif()
diff --git a/libcxx/include/__config_site.in b/libcxx/include/__config_site.in
index 67022146c9082b..bf2d31d8eeb1b9 100644
--- a/libcxx/include/__config_site.in
+++ b/libcxx/include/__config_site.in
@@ -15,6 +15,7 @@
#cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
#cmakedefine _LIBCPP_HAS_NO_THREADS
#cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
+#cmakedefine _LIBCPP_HAS_NO_TERMINAL
#cmakedefine _LIBCPP_HAS_MUSL_LIBC
#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
diff --git a/libcxx/include/print b/libcxx/include/print
index 1a579daff270f7..2798a6bda26262 100644
--- a/libcxx/include/print
+++ b/libcxx/include/print
@@ -199,7 +199,7 @@ _LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream)
// the behavior in the test. This is not part of the public API.
# ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL
return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream);
-# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0
+# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 || defined(_LIBCPP_HAS_NO_TERMINAL)
return false;
# elif defined(_LIBCPP_WIN32API)
return std::__is_windows_terminal(__stream);
>From edb96eeb8a079543ca4d40031a117c23e7836ff1 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 5 Aug 2024 15:35:10 -0500
Subject: [PATCH 2/3] Address comments
---
libcxx/CMakeLists.txt | 2 +-
libcxx/utils/libcxx/test/features.py | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 3699eca640772f..434ca34321bdb2 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -97,6 +97,7 @@ option(LIBCXX_ENABLE_UNICODE
"Whether to include support for Unicode in the library. Disabling Unicode can
be useful when porting to platforms that don't support UTF-8 encoding (e.g.
embedded)." ON)
+option(LIBCXX_HAS_TERMINAL_AVAILABLE "Build libc++ with terminal checking support" ON)
option(LIBCXX_ENABLE_WIDE_CHARACTERS
"Whether to include support for wide characters in the library. Disabling
wide character support can be useful when porting to platforms that don't
@@ -297,7 +298,6 @@ option(LIBCXX_HAS_WIN32_THREAD_API "Ignore auto-detection and force use of win32
option(LIBCXX_HAS_EXTERNAL_THREAD_API
"Build libc++ with an externalized threading API.
This option may only be set to ON when LIBCXX_ENABLE_THREADS=ON." OFF)
-option(LIBCXX_HAS_TERMINAL_AVAILABLE "Build libc++ with terminal checking support" ON)
if (LIBCXX_ENABLE_THREADS)
set(LIBCXX_PSTL_BACKEND "std_thread" CACHE STRING "Which PSTL backend to use")
diff --git a/libcxx/utils/libcxx/test/features.py b/libcxx/utils/libcxx/test/features.py
index 97cdb0349885d6..6857a28eb32995 100644
--- a/libcxx/utils/libcxx/test/features.py
+++ b/libcxx/utils/libcxx/test/features.py
@@ -378,6 +378,7 @@ def _mingwSupportsModules(cfg):
"_LIBCPP_HAS_NO_FILESYSTEM": "no-filesystem",
"_LIBCPP_HAS_NO_RANDOM_DEVICE": "no-random-device",
"_LIBCPP_HAS_NO_LOCALIZATION": "no-localization",
+ "_LIBCPP_HAS_NO_TERMINAL": "no-terminal",
"_LIBCPP_HAS_NO_WIDE_CHARACTERS": "no-wide-characters",
"_LIBCPP_HAS_NO_TIME_ZONE_DATABASE": "no-tzdb",
"_LIBCPP_HAS_NO_UNICODE": "libcpp-has-no-unicode",
>From 95ff1b97312a0fda3ebd5c24ea41f59ca4cf8a44 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 14 Aug 2024 12:08:08 -0500
Subject: [PATCH 3/3] address comments
---
.github/workflows/libcxx-build-and-test.yaml | 1 +
libcxx/CMakeLists.txt | 3 ++-
libcxx/cmake/caches/Generic-no-terminal.cmake | 5 +++++
libcxx/utils/ci/run-buildbot | 5 +++++
4 files changed, 13 insertions(+), 1 deletion(-)
create mode 100644 libcxx/cmake/caches/Generic-no-terminal.cmake
diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml
index 1456f245cf7c0c..8c6d7c6c3c4dec 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -146,6 +146,7 @@ jobs:
'generic-no-experimental',
'generic-no-filesystem',
'generic-no-localization',
+ 'generic-no-terminal',
'generic-no-random_device',
'generic-no-threads',
'generic-no-tzdb',
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 434ca34321bdb2..273b2238f34851 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -97,7 +97,8 @@ option(LIBCXX_ENABLE_UNICODE
"Whether to include support for Unicode in the library. Disabling Unicode can
be useful when porting to platforms that don't support UTF-8 encoding (e.g.
embedded)." ON)
-option(LIBCXX_HAS_TERMINAL_AVAILABLE "Build libc++ with terminal checking support" ON)
+option(LIBCXX_HAS_TERMINAL_AVAILABLE
+ "Build libc++ with support for checking whether a stream is a terminal." ON)
option(LIBCXX_ENABLE_WIDE_CHARACTERS
"Whether to include support for wide characters in the library. Disabling
wide character support can be useful when porting to platforms that don't
diff --git a/libcxx/cmake/caches/Generic-no-terminal.cmake b/libcxx/cmake/caches/Generic-no-terminal.cmake
new file mode 100644
index 00000000000000..9f712ebce02dbf
--- /dev/null
+++ b/libcxx/cmake/caches/Generic-no-terminal.cmake
@@ -0,0 +1,5 @@
+set(LIBCXX_HAS_TERMINAL_AVAILABLE OFF CACHE BOOL "")
+
+# Speed up the CI
+set(LIBCXX_TEST_PARAMS "enable_modules=clang" CACHE STRING "")
+set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
diff --git a/libcxx/utils/ci/run-buildbot b/libcxx/utils/ci/run-buildbot
index f1c20b9d721904..6353c87c3d865d 100755
--- a/libcxx/utils/ci/run-buildbot
+++ b/libcxx/utils/ci/run-buildbot
@@ -469,6 +469,11 @@ generic-no-localization)
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake"
check-runtimes
;;
+generic-no-terminal)
+ clean
+ generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-terminal.cmake"
+ check-runtimes
+;;
generic-no-unicode)
clean
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-unicode.cmake"
More information about the libcxx-commits
mailing list