Skip to content

Commit 7ad7f8f

Browse files
authored
[libcxx] Add LIBCXX_HAS_TERMINAL_AVAILABLE CMake option to disable print terminal checks (llvm#99259)
Adds a new CMake option called `LIBCXX_HAS_TERMINAL_AVAILABLE` that prevents us from checking for `isatty`.
1 parent 281d178 commit 7ad7f8f

File tree

7 files changed

+17
-1
lines changed

7 files changed

+17
-1
lines changed

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ jobs:
146146
'generic-no-experimental',
147147
'generic-no-filesystem',
148148
'generic-no-localization',
149+
'generic-no-terminal',
149150
'generic-no-random_device',
150151
'generic-no-threads',
151152
'generic-no-tzdb',

libcxx/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ option(LIBCXX_ENABLE_UNICODE
9797
"Whether to include support for Unicode in the library. Disabling Unicode can
9898
be useful when porting to platforms that don't support UTF-8 encoding (e.g.
9999
embedded)." ON)
100+
option(LIBCXX_HAS_TERMINAL_AVAILABLE
101+
"Build libc++ with support for checking whether a stream is a terminal." ON)
100102
option(LIBCXX_ENABLE_WIDE_CHARACTERS
101103
"Whether to include support for wide characters in the library. Disabling
102104
wide character support can be useful when porting to platforms that don't
@@ -744,6 +746,7 @@ config_define_if(LIBCXX_ABI_FORCE_ITANIUM _LIBCPP_ABI_FORCE_ITANIUM)
744746
config_define_if(LIBCXX_ABI_FORCE_MICROSOFT _LIBCPP_ABI_FORCE_MICROSOFT)
745747
config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS)
746748
config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK)
749+
config_define_if_not(LIBCXX_HAS_TERMINAL_AVAILABLE _LIBCPP_HAS_NO_TERMINAL)
747750
if (NOT LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION STREQUAL "default")
748751
config_define("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION)
749752
endif()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(LIBCXX_HAS_TERMINAL_AVAILABLE OFF CACHE BOOL "")
2+
3+
# Speed up the CI
4+
set(LIBCXX_TEST_PARAMS "enable_modules=clang" CACHE STRING "")
5+
set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")

libcxx/include/__config_site.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#cmakedefine _LIBCPP_ABI_FORCE_MICROSOFT
1616
#cmakedefine _LIBCPP_HAS_NO_THREADS
1717
#cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK
18+
#cmakedefine _LIBCPP_HAS_NO_TERMINAL
1819
#cmakedefine _LIBCPP_HAS_MUSL_LIBC
1920
#cmakedefine _LIBCPP_HAS_THREAD_API_PTHREAD
2021
#cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL

libcxx/include/print

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ _LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream)
199199
// the behavior in the test. This is not part of the public API.
200200
# ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL
201201
return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream);
202-
# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0
202+
# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 || defined(_LIBCPP_HAS_NO_TERMINAL)
203203
return false;
204204
# elif defined(_LIBCPP_WIN32API)
205205
return std::__is_windows_terminal(__stream);

libcxx/utils/ci/run-buildbot

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,11 @@ generic-no-localization)
469469
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-localization.cmake"
470470
check-runtimes
471471
;;
472+
generic-no-terminal)
473+
clean
474+
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-terminal.cmake"
475+
check-runtimes
476+
;;
472477
generic-no-unicode)
473478
clean
474479
generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/Generic-no-unicode.cmake"

libcxx/utils/libcxx/test/features.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ def _mingwSupportsModules(cfg):
378378
"_LIBCPP_HAS_NO_FILESYSTEM": "no-filesystem",
379379
"_LIBCPP_HAS_NO_RANDOM_DEVICE": "no-random-device",
380380
"_LIBCPP_HAS_NO_LOCALIZATION": "no-localization",
381+
"_LIBCPP_HAS_NO_TERMINAL": "no-terminal",
381382
"_LIBCPP_HAS_NO_WIDE_CHARACTERS": "no-wide-characters",
382383
"_LIBCPP_HAS_NO_TIME_ZONE_DATABASE": "no-tzdb",
383384
"_LIBCPP_HAS_NO_UNICODE": "libcpp-has-no-unicode",

0 commit comments

Comments
 (0)