Skip to content

Commit 6c87855

Browse files
committed
[libc++][C++03] Use __cxx03/ headers in C++03 mode
1 parent 323bedd commit 6c87855

File tree

246 files changed

+1882
-1463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+1882
-1463
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
fail-fast: false
4444
matrix:
4545
config: [
46+
'frozen-cxx03-headers',
4647
'generic-cxx03',
4748
'generic-cxx26',
4849
'generic-modules'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set(LIBCXX_TEST_PARAMS "std=c++03;test_frozen_cxx03_headers=True" CACHE STRING "")
2+
set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")

libcxx/include/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,12 +1047,15 @@ set(files
10471047
wctype.h
10481048
)
10491049

1050+
add_subdirectory(__cxx03)
1051+
10501052
configure_file("__config_site.in" "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site" @ONLY)
10511053
configure_file("${LIBCXX_ASSERTION_HANDLER_FILE}" "${LIBCXX_GENERATED_INCLUDE_DIR}/__assertion_handler" COPYONLY)
10521054

10531055
set(_all_includes "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site"
10541056
"${LIBCXX_GENERATED_INCLUDE_DIR}/__assertion_handler")
1055-
foreach(f ${files})
1057+
message(STATUS "C++03 headers: ${LIBCXX_FROZEN_CXX03_HEADERS}")
1058+
foreach(f ${files} ${LIBCXX_FROZEN_CXX03_HEADERS})
10561059
set(src "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
10571060
set(dst "${LIBCXX_GENERATED_INCLUDE_DIR}/${f}")
10581061
add_custom_command(OUTPUT ${dst}
@@ -1082,7 +1085,7 @@ target_include_directories(cxx-headers INTERFACE ${LIBCXX_GENERATED_INCLUDE_TARG
10821085
${LIBCXX_GENERATED_INCLUDE_DIR})
10831086

10841087
if (LIBCXX_INSTALL_HEADERS)
1085-
foreach(file ${files})
1088+
foreach(file ${files} ${LIBCXX_FROZEN_CXX03_HEADERS})
10861089
get_filename_component(dir ${file} DIRECTORY)
10871090
install(FILES ${file}
10881091
DESTINATION "${LIBCXX_INSTALL_INCLUDE_DIR}/${dir}"

libcxx/include/__cxx03/CMakeLists.txt

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ set(files
318318
__configuration/abi.h
319319
__configuration/availability.h
320320
__configuration/compiler.h
321+
__configuration/config_site_shim.h
321322
__configuration/language.h
322323
__configuration/platform.h
323324
__coroutine/coroutine_handle.h
@@ -1018,75 +1019,34 @@ set(files
10181019
wctype.h
10191020
)
10201021

1021-
configure_file("__config_site.in" "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site" @ONLY)
1022-
configure_file("${LIBCXX_ASSERTION_HANDLER_FILE}" "${LIBCXX_GENERATED_INCLUDE_DIR}/__assertion_handler" COPYONLY)
1023-
1024-
set(_all_includes "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site"
1025-
"${LIBCXX_GENERATED_INCLUDE_DIR}/__assertion_handler")
1022+
set(_all_includes "")
10261023
foreach(f ${files})
10271024
set(src "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
1028-
set(dst "${LIBCXX_GENERATED_INCLUDE_DIR}/${f}")
1025+
set(dst "${LIBCXX_GENERATED_INCLUDE_DIR}/__cxx03/${f}")
10291026
add_custom_command(OUTPUT ${dst}
10301027
DEPENDS ${src}
10311028
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
10321029
COMMENT "Copying CXX header ${f}")
10331030
list(APPEND _all_includes "${dst}")
10341031
endforeach()
10351032

1036-
# Generate the IWYU mapping. This depends on all header files but it's also considered as an
1037-
# "include" for dependency tracking.
1038-
add_custom_command(OUTPUT "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp"
1039-
COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_iwyu_mapping.py" "-o" "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp"
1040-
DEPENDS "${LIBCXX_SOURCE_DIR}/utils/libcxx/header_information.py"
1041-
COMMENT "Generate the mapping file for include-what-you-use"
1042-
)
1043-
list(APPEND _all_includes "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp")
1044-
1045-
add_custom_target(generate-cxx-headers ALL DEPENDS ${_all_includes})
1046-
1047-
add_library(cxx-headers INTERFACE)
1048-
target_link_libraries(cxx-headers INTERFACE libcxx-libc-headers libcxx-abi-headers)
1049-
add_dependencies(cxx-headers generate-cxx-headers)
1050-
# It's important that the arch directory be included first so that its header files
1051-
# which interpose on the default include dir be included instead of the default ones.
1052-
target_include_directories(cxx-headers INTERFACE ${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}
1053-
${LIBCXX_GENERATED_INCLUDE_DIR})
1033+
add_custom_target(generate-frozen-cxx03-headers ALL DEPENDS ${_all_includes})
10541034

10551035
if (LIBCXX_INSTALL_HEADERS)
10561036
foreach(file ${files})
10571037
get_filename_component(dir ${file} DIRECTORY)
1058-
install(FILES ${file}
1059-
DESTINATION "${LIBCXX_INSTALL_INCLUDE_DIR}/${dir}"
1038+
install(FILES "${file}"
1039+
DESTINATION "${LIBCXX_INSTALL_INCLUDE_DIR}/__cxx03/${dir}"
10601040
COMPONENT cxx-headers
10611041
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
10621042
)
10631043
endforeach()
10641044

1065-
# Install the generated __config_site file to the per-target include dir.
1066-
install(FILES "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site"
1067-
DESTINATION "${LIBCXX_INSTALL_INCLUDE_TARGET_DIR}"
1068-
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
1069-
COMPONENT cxx-headers)
1070-
1071-
# Install the generated __assertion_handler file to the generic include dir.
1072-
install(FILES "${LIBCXX_GENERATED_INCLUDE_DIR}/__assertion_handler"
1073-
DESTINATION "${LIBCXX_INSTALL_INCLUDE_DIR}"
1074-
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
1075-
COMPONENT cxx-headers)
1076-
1077-
# Install the generated IWYU file to the generic include dir.
1078-
install(FILES "${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp"
1079-
DESTINATION "${LIBCXX_INSTALL_INCLUDE_DIR}"
1080-
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
1081-
COMPONENT cxx-headers)
1082-
10831045
if (NOT CMAKE_CONFIGURATION_TYPES)
1084-
add_custom_target(install-cxx-headers
1046+
add_custom_target(install-frozen-cxx03-headers
10851047
DEPENDS cxx-headers
10861048
COMMAND "${CMAKE_COMMAND}"
10871049
-DCMAKE_INSTALL_COMPONENT=cxx-headers
10881050
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
1089-
# Stripping is a no-op for headers
1090-
add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers)
10911051
endif()
10921052
endif()

libcxx/include/__cxx03/__config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#ifndef _LIBCPP___CXX03___CONFIG
1111
#define _LIBCPP___CXX03___CONFIG
1212

13-
#include <__config_site>
13+
#include <__cxx03/__configuration/config_site_shim.h>
1414
#include <__cxx03/__configuration/abi.h>
1515
#include <__cxx03/__configuration/availability.h>
1616
#include <__cxx03/__configuration/compiler.h>

libcxx/include/__cxx03/__configuration/abi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#ifndef _LIBCPP___CXX03___CONFIGURATION_ABI_H
1111
#define _LIBCPP___CXX03___CONFIGURATION_ABI_H
1212

13-
#include <__config_site>
1413
#include <__cxx03/__configuration/compiler.h>
14+
#include <__cxx03/__configuration/config_site_shim.h>
1515
#include <__cxx03/__configuration/platform.h>
1616

1717
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER

libcxx/include/__cxx03/__configuration/compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#ifndef _LIBCPP___CXX03___CONFIGURATION_COMPILER_H
1111
#define _LIBCPP___CXX03___CONFIGURATION_COMPILER_H
1212

13-
#include <__config_site>
13+
#include <__cxx03/__configuration/config_site_shim.h>
1414

1515
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
1616
# pragma GCC system_header
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___CXX03___CONFIGURATION_CONFIG_SITE_WRAPPER_H
10+
#define _LIBCPP___CXX03___CONFIGURATION_CONFIG_SITE_WRAPPER_H
11+
12+
#include <__config_site>
13+
14+
#if !_LIBCPP_ABI_FORCE_ITANIUM
15+
# undef _LIBCPP_ABI_FORCE_ITANIUM
16+
#endif
17+
18+
#if !_LIBCPP_ABI_FORCE_MICROSOFT
19+
# undef _LIBCPP_ABI_FORCE_MICROSOFT
20+
#endif
21+
22+
#if !_LIBCPP_HAS_THREADS
23+
# define _LIBCPP_HAS_NO_THREADS
24+
#endif
25+
26+
#if !_LIBCPP_HAS_MONOTONIC_CLOCK
27+
# define _LIBCPP_HAS_NO_MONOTONIC_CLOCK
28+
#endif
29+
30+
#if !_LIBCPP_HAS_MUSL_LIBC
31+
# undef _LIBCPP_HAS_MUSL_LIBC
32+
#endif
33+
34+
#if !_LIBCPP_HAS_THREAD_API_PTHREAD
35+
# undef _LIBCPP_HAS_THREAD_API_PTHREAD
36+
#endif
37+
38+
#if !_LIBCPP_HAS_THREAD_API_EXTERNAL
39+
# undef _LIBCPP_HAS_THREAD_API_EXTERNAL
40+
#endif
41+
42+
#if !_LIBCPP_HAS_THREAD_API_WIN32
43+
# undef _LIBCPP_HAS_THREAD_API_WIN32
44+
#endif
45+
46+
#undef _LIBCPP_HAS_THREAD_API_C11
47+
48+
#if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
49+
# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
50+
#endif
51+
52+
#if !_LIBCPP_HAS_FILESYSTEM
53+
# define _LIBCPP_HAS_NO_FILESYSTEM
54+
#endif
55+
56+
#if !_LIBCPP_HAS_RANDOM_DEVICE
57+
# define _LIBCPP_HAS_NO_RANDOM_DEVICE
58+
#endif
59+
60+
#if !_LIBCPP_HAS_LOCALIZATION
61+
# define _LIBCPP_HAS_NO_LOCALIZATION
62+
#endif
63+
64+
#if !_LIBCPP_HAS_UNICODE
65+
# define _LIBCPP_HAS_NO_UNICODE
66+
#endif
67+
68+
#if !_LIBCPP_HAS_WIDE_CHARACTERS
69+
# define _LIBCPP_HAS_NO_WIDE_CHARACTERS
70+
#endif
71+
72+
#if !_LIBCPP_HAS_TIME_ZONE_DATABASE
73+
# define _LIBCPP_HAS_NO_TIME_ZONE_DATABASE
74+
#endif
75+
76+
#if !_LIBCPP_INSTRUMENTED_WITH_ASAN
77+
# undef _LIBCPP_INSTRUMENTED_WITH_ASAN
78+
#endif
79+
80+
#endif // _LIBCPP___CXX03___CONFIGURATION_CONFIG_SITE_WRAPPER_H

libcxx/include/__cxx03/__configuration/language.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#ifndef _LIBCPP___CXX03___CONFIGURATION_LANGUAGE_H
1111
#define _LIBCPP___CXX03___CONFIGURATION_LANGUAGE_H
1212

13-
#include <__config_site>
13+
#include <__cxx03/__configuration/config_site_shim.h>
1414

1515
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
1616
# pragma GCC system_header

libcxx/include/__cxx03/__configuration/platform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#ifndef _LIBCPP___CXX03___CONFIGURATION_PLATFORM_H
1111
#define _LIBCPP___CXX03___CONFIGURATION_PLATFORM_H
1212

13-
#include <__config_site>
13+
#include <__cxx03/__configuration/config_site_shim.h>
1414

1515
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
1616
# pragma GCC system_header

libcxx/include/__cxx03/__locale_dir/locale_base_api/bsd_locale_fallbacks.h

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

1616
#include <__cxx03/__locale_dir/locale_base_api/locale_guard.h>
1717
#include <__cxx03/cstdio>
18-
#include <__cxx03/stdarg.h>
18+
#include <stdarg.h>
1919
#include <__cxx03/stdlib.h>
2020

2121
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS

libcxx/include/__cxx03/__thread/support/pthread.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include <__cxx03/__config>
1616
#include <__cxx03/ctime>
1717
#include <__cxx03/errno.h>
18-
#include <__cxx03/pthread.h>
19-
#include <__cxx03/sched.h>
18+
#include <pthread.h>
19+
#include <sched.h>
2020

2121
#ifdef __MVS__
2222
# include <__cxx03/__support/ibm/nanosleep.h>

libcxx/include/__cxx03/climits

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Macros:
3939

4040
#include <__cxx03/__config>
4141

42-
#include <__cxx03/limits.h>
42+
#include <limits.h>
4343

4444
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4545
# pragma GCC system_header

libcxx/include/__cxx03/locale

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ template <class charT> class messages_byname;
222222
// Most unix variants have catopen. These are the specific ones that don't.
223223
# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
224224
# define _LIBCPP_HAS_CATOPEN 1
225-
# include <__cxx03/nl_types.h>
225+
# include <nl_types.h>
226226
# endif
227227
# endif
228228

0 commit comments

Comments
 (0)