Skip to content

Commit 868d1e5

Browse files
authored
Merge pull request #26315 from Rostepher/toolchain-compat-libs-5.1
[Build System: CMake] Move the Compatibility libraries into stdlib/toolchain (5.1 branch).
2 parents 8faa962 + 92d4e76 commit 868d1e5

File tree

10 files changed

+107
-29
lines changed

10 files changed

+107
-29
lines changed

stdlib/public/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ if(SWIFT_BUILD_STDLIB)
6161
add_subdirectory(stubs)
6262
add_subdirectory(core)
6363
add_subdirectory(SwiftOnoneSupport)
64-
add_subdirectory(Compatibility50)
65-
add_subdirectory(CompatibilityDynamicReplacements)
6664
endif()
6765

6866
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR)

stdlib/public/Compatibility50/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
This file was deleted.

stdlib/public/CompatibilityDynamicReplacements/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

stdlib/toolchain/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,47 @@
1+
# Toolchain-only build products
2+
3+
set(CXX_COMPILE_FLAGS)
4+
set(CXX_LINK_FLAGS)
5+
6+
7+
set(compile_flags
8+
# Build the runtime with -Wall to catch, e.g., uninitialized variables
9+
# warnings.
10+
"-Wall"
11+
12+
# C++ code in the runtime and standard library should generally avoid
13+
# introducing static constructors or destructors.
14+
"-Wglobal-constructors"
15+
"-Wexit-time-destructors"
16+
17+
# We don't want runtime C++ code to export symbols we didn't explicitly
18+
# choose to.
19+
"-fvisibility=hidden")
20+
21+
22+
# Build the runtime with -Wall to catch, e.g., uninitialized variables
23+
# warnings.
24+
if(SWIFT_COMPILER_IS_MSVC_LIKE)
25+
list(APPEND compile_flags "/W3")
26+
else()
27+
list(APPEND compile_flags "-Wall")
28+
endif()
29+
30+
31+
foreach(flag ${compile_flags})
32+
check_cxx_compiler_flag("${flag}" is_supported)
33+
if(is_supported)
34+
list(APPEND CXX_COMPILE_FLAGS "${flag}")
35+
endif()
36+
endforeach()
37+
unset(compile_flags)
38+
39+
40+
if("Thread" IN_LIST SWIFT_RUNTIME_USE_SANITIZERS)
41+
list(APPEND CXX_LINK_FLAGS "-fsanitize=thread")
42+
endif()
43+
44+
145
add_subdirectory(legacy_layouts)
46+
add_subdirectory(Compatibility50)
47+
add_subdirectory(CompatibilityDynamicReplacements)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
set(library_name "swiftCompatibility50")
2+
3+
add_swift_target_library("${library_name}" STATIC TARGET_LIBRARY
4+
ProtocolConformance.cpp
5+
Overrides.cpp
6+
7+
TARGET_SDKS ${SWIFT_APPLE_PLATFORMS}
8+
9+
C_COMPILE_FLAGS ${CXX_COMPILE_FLAGS}
10+
LINK_FLAGS ${CXX_LINK_FLAGS}
11+
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
12+
13+
INSTALL_IN_COMPONENT compiler
14+
INSTALL_WITH_SHARED)
15+
16+
17+
# FIXME: We need a more flexible mechanism to add lipo targets generated by
18+
# add_swift_target_library to the ALL target. Until then this hack is necessary
19+
# to ensure these libraries build.
20+
foreach(sdk ${SWIFT_SDKS})
21+
set(target_name "${library_name}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
22+
if(NOT TARGET "${target_name}")
23+
continue()
24+
endif()
25+
26+
set_target_properties("${target_name}"
27+
PROPERTIES
28+
EXCLUDE_FROM_ALL FALSE)
29+
endforeach()

stdlib/public/Compatibility50/Overrides.cpp renamed to stdlib/toolchain/Compatibility50/Overrides.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#include "Overrides.h"
18-
#include "../runtime/CompatibilityOverride.h"
18+
#include "../../public/runtime/CompatibilityOverride.h"
1919

2020
using namespace swift;
2121

2222
struct OverrideSection {
2323
uintptr_t version;
2424
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
2525
Override_ ## name name;
26-
#include "../runtime/CompatibilityOverride.def"
26+
#include "../../public/runtime/CompatibilityOverride.def"
2727
};
2828

2929
OverrideSection Overrides

stdlib/public/Compatibility50/ProtocolConformance.cpp renamed to stdlib/toolchain/Compatibility50/ProtocolConformance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//===----------------------------------------------------------------------===//
1919

2020
#include "Overrides.h"
21-
#include "../runtime/Private.h"
21+
#include "../../public/runtime/Private.h"
2222
#include "swift/Basic/Lazy.h"
2323
#include <objc/runtime.h>
2424

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
set(library_name "swiftCompatibilityDynamicReplacements")
2+
3+
add_swift_target_library("${library_name}" STATIC TARGET_LIBRARY
4+
DynamicReplaceable.cpp
5+
6+
TARGET_SDKS ${SWIFT_APPLE_PLATFORMS}
7+
8+
C_COMPILE_FLAGS ${CXX_COMPILE_FLAGS}
9+
LINK_FLAGS ${CXX_LINK_FLAGS}
10+
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
11+
12+
INSTALL_IN_COMPONENT compiler
13+
INSTALL_WITH_SHARED)
14+
15+
16+
# FIXME: We need a more flexible mechanism to add lipo targets generated by
17+
# add_swift_target_library to the ALL target. Until then this hack is necessary
18+
# to ensure these libraries build.
19+
foreach(sdk ${SWIFT_SDKS})
20+
set(target_name "${library_name}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
21+
if(NOT TARGET "${target_name}")
22+
continue()
23+
endif()
24+
25+
set_target_properties("${target_name}"
26+
PROPERTIES
27+
EXCLUDE_FROM_ALL FALSE)
28+
endforeach()

stdlib/public/CompatibilityDynamicReplacements/DynamicReplaceable.cpp renamed to stdlib/toolchain/CompatibilityDynamicReplacements/DynamicReplaceable.cpp

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

2020
#include "swift/Runtime/Once.h"
2121
#include "swift/Runtime/Exclusivity.h"
22-
#include "../runtime/ThreadLocalStorage.h"
22+
#include "../../public/runtime/ThreadLocalStorage.h"
2323

2424
using namespace swift;
2525

0 commit comments

Comments
 (0)