Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] Deprecate and remove meaningless <cxxx> headers #111615

Merged
merged 26 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cd7e179
[libc++] Deprecate and remove meaningless `<cxxx>` headers
frederick-vs-ja Oct 9, 2024
a7fdda0
[libc++] Add missed `<cstdalign>` and `<stdalign.h>` headers
frederick-vs-ja Oct 9, 2024
fdf253d
[libc++] Deprecate and remove `<cstdalign>`
frederick-vs-ja Oct 9, 2024
81ea61b
Try to fix undeprecation/deprecation verification
frederick-vs-ja Oct 9, 2024
887574c
Try to fix generating scripts
frederick-vs-ja Oct 9, 2024
18c7e9d
More formatting
frederick-vs-ja Oct 9, 2024
b68ee90
Reorganize inclusion per P0063R3 to reduce deprecation warnings
frederick-vs-ja Oct 9, 2024
70d91b7
Delete unneeded `<stdalign.h>`
frederick-vs-ja Oct 10, 2024
8360774
Escape hatch for `<ciso646>`
frederick-vs-ja Oct 10, 2024
9c4337c
Fix some errors for `<ctgmath>` and `<tgmath.h>`
frederick-vs-ja Oct 10, 2024
1299c89
Revert "Delete unneeded `<stdalign.h>`"
frederick-vs-ja Oct 10, 2024
ca47422
Adjust transitive_includes files
frederick-vs-ja Oct 14, 2024
27abb5f
Merge branch 'main' into cxx20-removed-headers
frederick-vs-ja Oct 14, 2024
7d05faa
Try to fix deprecation suppressing/verification
frederick-vs-ja Oct 14, 2024
53da492
Try to fix deprecation suppressing/verification, take 2
frederick-vs-ja Oct 14, 2024
42d680e
Skip modules-build
frederick-vs-ja Oct 14, 2024
2699c51
Remove libc++'s wrapping `<stdalign.h>`
frederick-vs-ja Oct 14, 2024
6372fce
Adjust warning messages
frederick-vs-ja Oct 14, 2024
72180f7
Revert some changes in documentations
frederick-vs-ja Oct 14, 2024
8588d52
Address review comments and try to fix CI failures
frederick-vs-ja Oct 22, 2024
6c4b524
Merge branch 'main' into cxx20-removed-headers
frederick-vs-ja Oct 22, 2024
cb71036
Fix merge and format errors
frederick-vs-ja Oct 22, 2024
cf9e2e2
Add missing cstdalign to c header files
ldionne Oct 22, 2024
aa83d21
Restore to attribute-based method
frederick-vs-ja Oct 23, 2024
2f7ab3b
Reform deprecation messages and add more comments
frederick-vs-ja Oct 27, 2024
42214df
Fix `#else if`
frederick-vs-ja Oct 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libcxx/docs/ReleaseNotes/20.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ What's New in Libc++ 20.0.0?
Implemented Papers
------------------

- P0619R4: Reviewing Deprecated Facilities of C++17 for C++20 (`Github <https://github.com/llvm/llvm-project/issues/99985>`__)
- P2747R2: ``constexpr`` placement new (`Github <https://github.com/llvm/llvm-project/issues/105427>`__)
frederick-vs-ja marked this conversation as resolved.
Show resolved Hide resolved
- P2609R3: Relaxing Ranges Just A Smidge (`Github <https://github.com/llvm/llvm-project/issues/105253>`__)
- P2985R0: A type trait for detecting virtual base classes (`Github <https://github.com/llvm/llvm-project/issues/105432>`__)
Expand Down Expand Up @@ -85,6 +86,11 @@ Deprecations and Removals
- The function ``__libcpp_verbose_abort()`` is now ``noexcept``, to match ``std::terminate()``. (The combination of
``noexcept`` and ``[[noreturn]]`` has special significance for function effects analysis.)

- ``<ccomplex>``, ``<cstdalign>`` (previously missing), ``<cstdbool>``, and ``<ctgmath>`` are deprecated since C++17 as
specified by the standard. They, together with ``<ciso646>``, are removed in C++20, but libc++ still provides these
headers as an extension and only deprecates them. The ``_LIBCPP_DISABLE_DEPRECATION_WARNINGS`` macro can be defined to
suppress deprecation for these headers.

Upcoming Deprecations and Removals
----------------------------------

Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx20Papers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"`P0528R3 <https://wg21.link/P0528R3>`__","The Curious Case of Padding Bits, Featuring Atomic Compare-and-Exchange","2018-06 (Rapperswil)","","",""
"`P0542R5 <https://wg21.link/P0542R5>`__","Support for contract based programming in C++","2018-06 (Rapperswil)","|Nothing To Do|","n/a","Pulled at the 2019-07 meeting in Cologne"
"`P0556R3 <https://wg21.link/P0556R3>`__","Integral power-of-2 operations","2018-06 (Rapperswil)","|Complete|","9.0",""
"`P0619R4 <https://wg21.link/P0619R4>`__","Reviewing Deprecated Facilities of C++17 for C++20","2018-06 (Rapperswil)","|Partial|","","Only sections D.7, D.8, D.9, D.10, D.11, D.12, and D.13 are implemented. Section D.4 remains undone."
"`P0619R4 <https://wg21.link/P0619R4>`__","Reviewing Deprecated Facilities of C++17 for C++20","2018-06 (Rapperswil)","|Complete|","20.0","Removed headers are still provided as an extension, but with deprecation warnings"
"`P0646R1 <https://wg21.link/P0646R1>`__","Improving the Return Value of Erase-Like Algorithms","2018-06 (Rapperswil)","|Complete|","10.0",""
"`P0722R3 <https://wg21.link/P0722R3>`__","Efficient sized delete for variable sized classes","2018-06 (Rapperswil)","|Complete|","9.0",""
"`P0758R1 <https://wg21.link/P0758R1>`__","Implicit conversion traits and utility functions","2018-06 (Rapperswil)","|Complete|","",""
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ set(files
coroutine
csetjmp
csignal
cstdalign
cstdarg
cstdbool
cstddef
Expand Down
12 changes: 12 additions & 0 deletions libcxx/include/ccomplex
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,16 @@
# pragma GCC system_header
#endif

#if _LIBCPP_STD_VER >= 20

using __standard_header_ccomplex _LIBCPP_DEPRECATED_("removed in C++20. Include <complex> instead.") = void;
using __use_standard_header_ccomplex = __standard_header_ccomplex;

#elif _LIBCPP_STD_VER >= 17

using __standard_header_ccomplex _LIBCPP_DEPRECATED_("Include <complex> instead.") = void;
using __use_standard_header_ccomplex = __standard_header_ccomplex;

#endif

#endif // _LIBCPP_CCOMPLEX
7 changes: 7 additions & 0 deletions libcxx/include/ciso646
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@
# pragma GCC system_header
#endif

#if _LIBCPP_STD_VER >= 20

using __standard_header_ciso646 _LIBCPP_DEPRECATED_("removed in C++20. Include <version> instead.") = void;
using __use_standard_header_ciso646 = __standard_header_ciso646;

#endif

#endif // _LIBCPP_CISO646
2 changes: 1 addition & 1 deletion libcxx/include/complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#endif

#ifdef __cplusplus
# include <ccomplex>
# include <complex>
#elif __has_include_next(<complex.h>)
# include_next <complex.h>
#endif
Expand Down
55 changes: 55 additions & 0 deletions libcxx/include/cstdalign
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP_CSTDALIGN
#define _LIBCPP_CSTDALIGN

/*
cstdalign synopsis

Macros:

__alignas_is_defined
__alignof_is_defined

*/

#include <__config>
frederick-vs-ja marked this conversation as resolved.
Show resolved Hide resolved

// <stdalign.h> is not provided by libc++
#if __has_include(<stdalign.h>)
# include <stdalign.h>
# ifdef _LIBCPP_STDALIGN_H
# error "If libc++ starts defining <stdalign.h>, the __has_include check should move to libc++'s <stdalign.h>"
# endif
#endif

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

#undef __alignas_is_defined
#define __alignas_is_defined 1

#undef __alignof_is_defined
#define __alignof_is_defined 1

#if _LIBCPP_STD_VER >= 20

using __standard_header_cstdalign _LIBCPP_DEPRECATED_("removed in C++20.") = void;
using __use_standard_header_cstdalign = __standard_header_cstdalign;

#elif _LIBCPP_STD_VER >= 17

using __standard_header_cstdalign _LIBCPP_DEPRECATED = void;
using __use_standard_header_cstdalign = __standard_header_cstdalign;

#endif

#endif // _LIBCPP_CSTDALIGN
12 changes: 12 additions & 0 deletions libcxx/include/cstdbool
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ Macros:
#undef __bool_true_false_are_defined
#define __bool_true_false_are_defined 1

#if _LIBCPP_STD_VER >= 20

using __standard_header_cstdbool _LIBCPP_DEPRECATED_("removed in C++20.") = void;
using __use_standard_header_cstdbool = __standard_header_cstdbool;

#elif _LIBCPP_STD_VER >= 17

using __standard_header_cstdbool _LIBCPP_DEPRECATED = void;
using __use_standard_header_cstdbool = __standard_header_cstdbool;

#endif

#endif // _LIBCPP_CSTDBOOL
14 changes: 13 additions & 1 deletion libcxx/include/ctgmath
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,23 @@

*/

#include <ccomplex>
#include <cmath>
#include <complex>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

#if _LIBCPP_STD_VER >= 20

using __standard_header_ctgmath _LIBCPP_DEPRECATED_("removed in C++20. Include <cmath> and <complex> instead.") = void;
using __use_standard_header_ctgmath = __standard_header_ctgmath;

#elif _LIBCPP_STD_VER >= 17

using __standard_header_ctgmath _LIBCPP_DEPRECATED_("Include <cmath> and <complex> instead.") = void;
using __use_standard_header_ctgmath = __standard_header_ctgmath;

#endif

#endif // _LIBCPP_CTGMATH
5 changes: 5 additions & 0 deletions libcxx/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,11 @@ module std [system] {
export *
}

module cstdalign {
header "cstdalign"
export *
}

module cstdarg {
header "cstdarg"
export *
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/tgmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#endif

#ifdef __cplusplus
# include <ctgmath>
# include <cmath>
# include <complex>
#else
# if __has_include_next(<tgmath.h>)
# include_next <tgmath.h>
Expand Down
13 changes: 10 additions & 3 deletions libcxx/test/libcxx/clang_modules_include.gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@

import sys
sys.path.append(sys.argv[1])
from libcxx.header_information import lit_header_restrictions, public_headers
from libcxx.header_information import (
lit_header_restrictions,
lit_header_undeprecations,
public_headers,
)

for header in public_headers:
print(f"""\
print(
f"""\
//--- {header}.compile.pass.cpp
// RUN: %{{cxx}} %s %{{flags}} %{{compile_flags}} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only

Expand All @@ -41,9 +46,11 @@
// UNSUPPORTED: LIBCXX-PICOLIBC-FIXME

{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}

#include <{header}>
""")
"""
)

print(
f"""\
Expand Down
13 changes: 10 additions & 3 deletions libcxx/test/libcxx/double_include.gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@

import sys
sys.path.append(sys.argv[1])
from libcxx.header_information import lit_header_restrictions, public_headers
from libcxx.header_information import (
lit_header_restrictions,
lit_header_undeprecations,
public_headers,
)

for header in public_headers:
print(f"""\
print(
f"""\
//--- {header}.sh.cpp
{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}

// RUN: %{{cxx}} -c %s -o %t.first.o %{{flags}} %{{compile_flags}}
// RUN: %{{cxx}} -c %s -o %t.second.o -DWITH_MAIN %{{flags}} %{{compile_flags}}
Expand All @@ -32,4 +38,5 @@
#if defined(WITH_MAIN)
int main(int, char**) {{ return 0; }}
#endif
""")
"""
)
37 changes: 24 additions & 13 deletions libcxx/test/libcxx/header_inclusions.gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,43 @@
# RUN: %{python} %s %{libcxx-dir}/utils

import sys

sys.path.append(sys.argv[1])
from libcxx.header_information import lit_header_restrictions, public_headers, mandatory_inclusions
from libcxx.header_information import (
lit_header_restrictions,
lit_header_undeprecations,
public_headers,
mandatory_inclusions,
)

for header in public_headers:
header_guard = lambda h: f"_LIBCPP_{str(h).upper().replace('.', '_').replace('/', '_')}"
header_guard = (
lambda h: f"_LIBCPP_{str(h).upper().replace('.', '_').replace('/', '_')}"
)

# <cassert> has no header guards
if header == 'cassert':
checks = ''
else:
checks = f'''
# <cassert> has no header guards
if header == "cassert":
checks = ""
else:
checks = f"""
#ifndef {header_guard(header)}
# error <{header}> was expected to define a header guard {header_guard(header)}
#endif
'''
for includee in mandatory_inclusions.get(header, []):
checks += f'''
"""
for includee in mandatory_inclusions.get(header, []):
checks += f"""
#ifndef {header_guard(includee)}
# error <{header}> was expected to include <{includee}>
#endif
'''
"""

print(f"""\
print(
f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}

#include <{header}>
{checks}
""")
"""
)
1 change: 1 addition & 0 deletions libcxx/test/libcxx/include_as_c.sh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#endif
#include <math.h>
#include <setjmp.h>
#include <stdalign.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stddef.h>
Expand Down
13 changes: 10 additions & 3 deletions libcxx/test/libcxx/libcpp_version.gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,23 @@

import sys
sys.path.append(sys.argv[1])
from libcxx.header_information import lit_header_restrictions, public_headers
from libcxx.header_information import (
lit_header_restrictions,
lit_header_undeprecations,
public_headers,
)

for header in public_headers:
print(f"""\
print(
f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}

#include <{header}>

#ifndef _LIBCPP_VERSION
# error <{header}> does not seem to define _LIBCPP_VERSION
#endif
""")
"""
)
18 changes: 13 additions & 5 deletions libcxx/test/libcxx/no_assert_include.gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,28 @@
# RUN: %{python} %s %{libcxx-dir}/utils

import sys

sys.path.append(sys.argv[1])
from libcxx.header_information import lit_header_restrictions, public_headers
from libcxx.header_information import (
lit_header_restrictions,
lit_header_undeprecations,
public_headers,
)

for header in public_headers:
if header == 'cassert':
continue
if header == "cassert":
continue

print(f"""\
print(
f"""\
//--- {header}.compile.pass.cpp
{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}

#include <{header}>

#ifdef assert
# error "Do not include cassert or assert.h in standard header files"
#endif
""")
"""
)
Loading