|
1 | | -set(libstdcxx_modulemap_target_list) |
2 | | -foreach(sdk ${SWIFT_SDKS}) |
3 | | - if(NOT ${sdk} IN_LIST SWIFT_LIBSTDCXX_PLATFORMS) |
4 | | - continue() |
5 | | - endif() |
6 | | - |
7 | | - foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES}) |
8 | | - set(arch_suffix "${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}") |
9 | | - set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}") |
10 | | - |
11 | | - set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}") |
12 | | - set(module_dir_static "${SWIFTSTATICLIB_DIR}/${arch_subdir}") |
13 | | - |
14 | | - set(libstdcxx_header "libstdcxx.h") |
15 | | - set(libstdcxx_header_out "${module_dir}/libstdcxx.h") |
16 | | - set(libstdcxx_header_out_static "${module_dir_static}/libstdcxx.h") |
17 | | - set(libstdcxx_modulemap "libstdcxx.modulemap") |
18 | | - set(libstdcxx_modulemap_out "${module_dir}/libstdcxx.modulemap") |
19 | | - set(libstdcxx_modulemap_out_static "${module_dir_static}/libstdcxx.modulemap") |
20 | | - |
21 | | - add_custom_command_target( |
22 | | - copy_libstdcxx_modulemap |
23 | | - COMMAND |
24 | | - "${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir} |
25 | | - COMMAND |
26 | | - "${CMAKE_COMMAND}" "-E" "copy_if_different" "${CMAKE_CURRENT_SOURCE_DIR}/${libstdcxx_modulemap}" "${libstdcxx_modulemap_out}" |
27 | | - OUTPUT ${libstdcxx_modulemap_out} |
28 | | - DEPENDS ${libstdcxx_modulemap} |
29 | | - COMMENT "Copying libstdcxx modulemap to resources") |
30 | | - list(APPEND libstdcxx_modulemap_target_list ${copy_libstdcxx_modulemap}) |
31 | | - add_dependencies(swift-stdlib-${arch_suffix} ${copy_libstdcxx_modulemap}) |
32 | | - |
33 | | - add_custom_command_target( |
34 | | - copy_libstdcxx_header |
35 | | - COMMAND |
36 | | - "${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir} |
37 | | - COMMAND |
38 | | - "${CMAKE_COMMAND}" "-E" "copy_if_different" "${CMAKE_CURRENT_SOURCE_DIR}/${libstdcxx_header}" "${libstdcxx_header_out}" |
39 | | - OUTPUT ${libstdcxx_header_out} |
40 | | - DEPENDS ${libstdcxx_header} |
41 | | - COMMENT "Copying libstdcxx header to resources") |
42 | | - list(APPEND libstdcxx_modulemap_target_list ${copy_libstdcxx_header}) |
43 | | - add_dependencies(swift-stdlib-${arch_suffix} ${copy_libstdcxx_header}) |
44 | | - |
45 | | - if(SWIFT_BUILD_STATIC_STDLIB) |
46 | | - add_custom_command_target( |
47 | | - copy_libstdcxx_modulemap_static |
48 | | - COMMAND |
49 | | - "${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir_static} |
50 | | - COMMAND |
51 | | - "${CMAKE_COMMAND}" "-E" "copy_if_different" |
52 | | - "${libstdcxx_modulemap_out}" "${libstdcxx_modulemap_out_static}" |
53 | | - OUTPUT ${libstdcxx_modulemap_out_static} |
54 | | - DEPENDS ${copy_libstdcxx_modulemap} |
55 | | - COMMENT "Copying libstdcxx modulemap to static resources") |
56 | | - list(APPEND libstdcxx_modulemap_target_list ${copy_libstdcxx_modulemap_static}) |
57 | | - add_dependencies(swift-stdlib-${arch_suffix} ${copy_libstdcxx_modulemap_static}) |
58 | | - |
59 | | - add_custom_command_target( |
60 | | - copy_libstdcxx_header_static |
61 | | - COMMAND |
62 | | - "${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir_static} |
63 | | - COMMAND |
64 | | - "${CMAKE_COMMAND}" "-E" "copy_if_different" |
65 | | - "${libstdcxx_header_out}" "${libstdcxx_header_out_static}" |
66 | | - OUTPUT ${libstdcxx_header_out_static} |
67 | | - DEPENDS ${copy_libstdcxx_header} |
68 | | - COMMENT "Copying libstdcxx header to static resources") |
69 | | - list(APPEND libstdcxx_modulemap_target_list ${copy_libstdcxx_header_static}) |
70 | | - add_dependencies(swift-stdlib-${arch_suffix} ${copy_libstdcxx_header_static}) |
71 | | - endif() |
72 | | - |
73 | | - swift_install_in_component(FILES "${libstdcxx_modulemap_out}" |
74 | | - DESTINATION "lib/swift/${arch_subdir}" |
75 | | - COMPONENT sdk-overlay) |
76 | | - swift_install_in_component(FILES "${libstdcxx_header_out}" |
77 | | - DESTINATION "lib/swift/${arch_subdir}" |
78 | | - COMPONENT sdk-overlay) |
79 | | - |
80 | | - if(SWIFT_BUILD_STATIC_STDLIB) |
81 | | - swift_install_in_component(FILES "${libstdcxx_modulemap_out_static}" |
82 | | - DESTINATION "lib/swift_static/${arch_subdir}" |
83 | | - COMPONENT sdk-overlay) |
84 | | - swift_install_in_component(FILES "${libstdcxx_header_out_static}" |
85 | | - DESTINATION "lib/swift_static/${arch_subdir}" |
86 | | - COMPONENT sdk-overlay) |
87 | | - endif() |
88 | | - |
89 | | - if(${BOOTSTRAPPING_MODE} MATCHES "BOOTSTRAPPING.*") |
90 | | - foreach(bootstrapping "0" "1") |
91 | | - get_bootstrapping_path(bootstrapping_dir ${module_dir} ${bootstrapping}) |
92 | | - set(libstdcxx_modulemap_out_bootstrapping "${bootstrapping_dir}/libstdcxx.modulemap") |
93 | | - set(libstdcxx_header_out_bootstrapping "${bootstrapping_dir}/libstdcxx.h") |
94 | | - |
95 | | - add_custom_command_target(unused_var |
96 | | - COMMAND |
97 | | - "${CMAKE_COMMAND}" "-E" "make_directory" "${bootstrapping_dir}" |
98 | | - COMMAND |
99 | | - "${CMAKE_COMMAND}" "-E" "copy_if_different" |
100 | | - "${CMAKE_CURRENT_SOURCE_DIR}/${libstdcxx_modulemap}" "${libstdcxx_modulemap_out_bootstrapping}" |
101 | | - |
102 | | - CUSTOM_TARGET_NAME "copy-libstdcxx-modulemap-bootstrapping${bootstrapping}" |
103 | | - OUTPUT "${libstdcxx_modulemap_out_bootstrapping}" |
104 | | - DEPENDS ${libstdcxx_modulemap} |
105 | | - COMMENT "Copying libstdcxx modulemap to resources for bootstrapping${bootstrapping}") |
106 | | - |
107 | | - add_custom_command_target(unused_var |
108 | | - COMMAND |
109 | | - "${CMAKE_COMMAND}" "-E" "make_directory" "${bootstrapping_dir}" |
110 | | - COMMAND |
111 | | - "${CMAKE_COMMAND}" "-E" "copy_if_different" |
112 | | - "${CMAKE_CURRENT_SOURCE_DIR}/${libstdcxx_header}" "${libstdcxx_header_out_bootstrapping}" |
113 | | - |
114 | | - CUSTOM_TARGET_NAME "copy-libstdcxx-header-bootstrapping${bootstrapping}" |
115 | | - OUTPUT "${libstdcxx_header_out_bootstrapping}" |
116 | | - DEPENDS ${libstdcxx_header} |
117 | | - COMMENT "Copying libstdcxx header to resources for bootstrapping${bootstrapping}") |
118 | | - endforeach() |
119 | | - endif() |
120 | | - endforeach() |
121 | | -endforeach() |
122 | | -add_custom_target(libstdcxx-modulemap DEPENDS ${libstdcxx_modulemap_target_list}) |
123 | | -set_property(TARGET libstdcxx-modulemap PROPERTY FOLDER "Miscellaneous") |
124 | | -add_dependencies(sdk-overlay libstdcxx-modulemap) |
125 | | - |
126 | | - |
127 | | -# |
128 | | -# C++ Standard Library Overlay. |
129 | | -# |
130 | | -add_swift_target_library(swiftstd ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY |
131 | | - std.swift |
| 1 | +add_swift_target_library(swiftCxx ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_SDK_OVERLAY |
132 | 2 | CxxSequence.swift |
133 | | - String.swift |
134 | | - |
135 | | - SWIFT_MODULE_DEPENDS_OSX Darwin |
136 | | - SWIFT_MODULE_DEPENDS_IOS Darwin |
137 | | - SWIFT_MODULE_DEPENDS_TVOS Darwin |
138 | | - SWIFT_MODULE_DEPENDS_WATCHOS Darwin |
139 | | - SWIFT_MODULE_DEPENDS_LINUX Glibc |
140 | 3 |
|
141 | 4 | SWIFT_COMPILE_FLAGS ${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS} ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} |
142 | 5 | -Xfrontend -enable-experimental-cxx-interop |
143 | | - -Xfrontend -module-interface-preserve-types-as-written |
144 | | - |
145 | | - SWIFT_COMPILE_FLAGS_LINUX |
146 | | - # GCC on Linux is usually located under `/usr`. |
147 | | - # However, Ubuntu 20.04 ships with another GCC installation under `/`, which does not include libstdc++. |
148 | | - # Swift build scripts pass `--sysroot=/` to Clang. By default, Clang tries to find GCC installation under sysroot, |
149 | | - # and if it doesn't exist, under `{sysroot}/usr`. On Ubuntu 20.04 and newer, it attempts to use the GCC without the |
150 | | - # C++ stdlib, which causes a build failure. To fix that, we tell Clang explicitly to use GCC from `/usr`. |
151 | | - -Xcc --gcc-toolchain=/usr |
| 6 | + # This module should not pull in the C++ standard library, so we disable it explicitly. |
| 7 | + # For functionality that depends on the C++ stdlib, use C++ stdlib overlay (`swiftstd` module). |
| 8 | + -Xcc -nostdinc++ |
152 | 9 |
|
153 | 10 | LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" |
154 | | - TARGET_SDKS ALL_APPLE_PLATFORMS LINUX |
155 | | - INSTALL_IN_COMPONENT sdk-overlay |
156 | | - DEPENDS libstdcxx-modulemap) |
| 11 | + INSTALL_IN_COMPONENT sdk-overlay) |
| 12 | + |
| 13 | +add_subdirectory(std) |
0 commit comments