Skip to content

Commit 1afd4d5

Browse files
committed
[libc++][print] Enables it on Apple backdeployment.
As suggested in llvm#73262 this enable the stream printing on Apple backdeployment targets. This omits the check whether the file is a terminal. This is not entirely conforming, but the differences should be minor and are typically not observable. Fixes llvm#75225
1 parent fbcf8a8 commit 1afd4d5

File tree

10 files changed

+14
-21
lines changed

10 files changed

+14
-21
lines changed

libcxx/include/__availability

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@
264264
# define _LIBCPP_AVAILABILITY_HAS_TZDB 0
265265
# define _LIBCPP_AVAILABILITY_TZDB __attribute__((unavailable))
266266

267+
// Warning: This availability macro works differently as the other macros.
268+
// The dylib part of print is not needed on Apple platforms. Therefore when
269+
// the macro is not available the code calling the dylib is commented out.
270+
// The macro _LIBCPP_AVAILABILITY_PRINT is not used.
267271
# define _LIBCPP_AVAILABILITY_HAS_PRINT 0
268272
# define _LIBCPP_AVAILABILITY_PRINT __attribute__((unavailable))
269273

libcxx/include/ostream

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,12 +1084,15 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view _
10841084
// native Unicode API;
10851085
// Whether the returned FILE* is "a terminal capable of displaying Unicode"
10861086
// is determined in the same way as the print(FILE*, ...) overloads.
1087-
_LIBCPP_AVAILABILITY_PRINT _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os);
1087+
_LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os);
10881088

10891089
# ifndef _LIBCPP_HAS_NO_UNICODE
10901090
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
1091-
_LIBCPP_AVAILABILITY_PRINT _LIBCPP_HIDE_FROM_ABI void
1091+
_LIBCPP_HIDE_FROM_ABI void
10921092
__vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) {
1093+
#if _LIBCPP_AVAILABILITY_HAS_PRINT == 0
1094+
return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
1095+
#else
10931096
FILE* __file = std::__get_ostream_file(__os);
10941097
if (!__file || !__print::__is_terminal(__file))
10951098
return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
@@ -1124,17 +1127,18 @@ __vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __wr
11241127
__os.__set_badbit_and_consider_rethrow();
11251128
}
11261129
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
1130+
#endif // _LIBCPP_AVAILABILITY_HAS_PRINT
11271131
}
11281132

11291133
template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
1130-
_LIBCPP_AVAILABILITY_PRINT _LIBCPP_HIDE_FROM_ABI inline void
1134+
_LIBCPP_HIDE_FROM_ABI inline void
11311135
vprint_unicode(ostream& __os, string_view __fmt, format_args __args) {
11321136
std::__vprint_unicode(__os, __fmt, __args, false);
11331137
}
11341138
# endif // _LIBCPP_HAS_NO_UNICODE
11351139

11361140
template <class... _Args>
1137-
_LIBCPP_AVAILABILITY_PRINT _LIBCPP_HIDE_FROM_ABI void
1141+
_LIBCPP_HIDE_FROM_ABI void
11381142
print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
11391143
# ifndef _LIBCPP_HAS_NO_UNICODE
11401144
if constexpr (__print::__use_unicode)
@@ -1147,7 +1151,7 @@ print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
11471151
}
11481152

11491153
template <class... _Args>
1150-
_LIBCPP_AVAILABILITY_PRINT _LIBCPP_HIDE_FROM_ABI void
1154+
_LIBCPP_HIDE_FROM_ABI void
11511155
println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
11521156
# ifndef _LIBCPP_HAS_NO_UNICODE
11531157
// Note the wording in the Standard is inefficient. The output of

libcxx/src/ostream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
_LIBCPP_BEGIN_NAMESPACE_STD
1919

20-
_LIBCPP_AVAILABILITY_PRINT _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) {
20+
_LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) {
2121
// dynamic_cast requires RTTI, this only affects users whose vendor builds
2222
// the dylib with RTTI disabled. It does not affect users who build with RTTI
2323
// disabled but use a dylib where the RTTI is enabled.

libcxx/test/libcxx/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/vprint_unicode.pass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
1111

1212
// XFAIL: availability-fp_to_chars-missing
13-
// XFAIL: availability-print-missing
1413

1514
// Clang modules do not work with the definiton of _LIBCPP_TESTING_PRINT_IS_TERMINAL
1615
// XFAIL: clang-modules-build

libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/locale-specific_form.pass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
// UNSUPPORTED: no-filesystem
1414

1515
// XFAIL: availability-fp_to_chars-missing
16-
// XFAIL: availability-print-missing
1716

1817
// Bionic has minimal locale support, investigate this later.
1918
// XFAIL: LIBCXX-ANDROID-FIXME

libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/print.pass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// UNSUPPORTED: no-filesystem
1313

1414
// XFAIL: availability-fp_to_chars-missing
15-
// XFAIL: availability-print-missing
1615

1716
// <ostream>
1817

libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/println.pass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// UNSUPPORTED: no-filesystem
1313

1414
// XFAIL: availability-fp_to_chars-missing
15-
// XFAIL: availability-print-missing
1615

1716
// <ostream>
1817

libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/vprint_nonunicode.pass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// UNSUPPORTED: no-filesystem
1313

1414
// XFAIL: availability-fp_to_chars-missing
15-
// XFAIL: availability-print-missing
1615

1716
// <ostream>
1817

libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.formatted.print/vprint_unicode.pass.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// UNSUPPORTED: no-filesystem
1313

1414
// XFAIL: availability-fp_to_chars-missing
15-
// XFAIL: availability-print-missing
1615

1716
// <ostream>
1817

libcxx/utils/libcxx/test/features.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,4 @@ def check_gdb(cfg):
586586
cfg.available_features,
587587
),
588588
),
589-
# Tests that require support for <print> and std::print in <ostream> in the built library.
590-
Feature(
591-
name="availability-print-missing",
592-
when=lambda cfg: BooleanExpression.evaluate(
593-
# TODO(ldionne) Please provide the correct value.
594-
"stdlib=apple-libc++ && target={{.+}}-apple-macosx{{(10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0|13.0)(.0)?}}",
595-
cfg.available_features,
596-
),
597-
),
598589
]

0 commit comments

Comments
 (0)