Skip to content

Commit

Permalink
[libcxx] Add LIBCXX_HAS_TERMINAL_AVAILABLE CMake option to disable …
Browse files Browse the repository at this point in the history
…`print` terminal checks (#99259)

Adds a new CMake option called `LIBCXX_HAS_TERMINAL_AVAILABLE` that
prevents us from checking for `isatty`.
  • Loading branch information
jhuber6 authored Aug 21, 2024
1 parent 281d178 commit 7ad7f8f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/libcxx-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions libcxx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +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 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
Expand Down Expand Up @@ -744,6 +746,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()
Expand Down
5 changes: 5 additions & 0 deletions libcxx/cmake/caches/Generic-no-terminal.cmake
Original file line number Diff line number Diff line change
@@ -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 "")
1 change: 1 addition & 0 deletions libcxx/include/__config_site.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/print
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions libcxx/utils/ci/run-buildbot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions libcxx/utils/libcxx/test/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7ad7f8f

Please sign in to comment.