Skip to content

Commit d9ba70a

Browse files
committed
runtime: tweak the compilation
Always include all the sources as we cannot include object libraries to be subsumed. This allows us to conditionally build the swift runtime for foreign hosts simultaneously (e.g. cross compile for Linux and Windows simultaneously).
1 parent f52555e commit d9ba70a

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

stdlib/public/runtime/CMakeLists.txt

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,9 @@ if(SWIFT_RUNTIME_ENABLE_LEAK_CHECKER)
1717
set(swift_runtime_leaks_sources Leaks.mm)
1818
endif()
1919

20-
set(swift_runtime_port_sources)
21-
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
22-
set(swift_runtime_port_sources
23-
MutexWin32.cpp
24-
CygwinPort.cpp)
25-
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN")
26-
set(swift_runtime_port_sources
27-
MutexPThread.cpp
28-
CygwinPort.cpp)
29-
else()
30-
set(swift_runtime_port_sources
31-
MutexPThread.cpp)
32-
endif()
33-
3420
list(APPEND swift_runtime_compile_flags
3521
"-D__SWIFT_CURRENT_DYLIB=swiftCore")
36-
22+
3723
set(swift_runtime_objc_sources)
3824
set(swift_runtime_unicode_normalization_sources)
3925
if(SWIFT_HOST_VARIANT MATCHES "${SWIFT_DARWIN_VARIANTS}")
@@ -47,6 +33,7 @@ endif()
4733

4834
set(swift_runtime_sources
4935
Casting.cpp
36+
CygwinPort.cpp
5037
Demangle.cpp
5138
Enum.cpp
5239
ErrorObjectNative.cpp
@@ -56,6 +43,8 @@ set(swift_runtime_sources
5643
KnownMetadata.cpp
5744
Metadata.cpp
5845
MetadataLookup.cpp
46+
MutexPThread.cpp
47+
MutexWin32.cpp
5948
Once.cpp
6049
Portability.cpp
6150
ProtocolConformance.cpp
@@ -78,7 +67,6 @@ add_swift_library(swiftRuntime OBJECT_LIBRARY TARGET_LIBRARY
7867
${swift_runtime_sources}
7968
${swift_runtime_objc_sources}
8069
${swift_runtime_leaks_sources}
81-
${swift_runtime_port_sources}
8270
C_COMPILE_FLAGS ${swift_runtime_compile_flags}
8371
INSTALL_IN_COMPONENT never_install)
8472

stdlib/public/runtime/CygwinPort.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17+
#if defined(_WIN32) || defined(__CYGWIN__)
1718
#include "Private.h"
1819
#include "swift/Runtime/Debug.h"
1920
#include <stdint.h>
@@ -136,6 +137,7 @@ uint8_t *swift::_swift_getSectionDataPE(void *handle, const char *sectionName,
136137

137138
return nullptr;
138139
}
140+
139141
#if !defined(_MSC_VER)
140142
void swift::_swift_once_f(uintptr_t *predicate, void *context,
141143
void (*function)(void *)) {
@@ -152,3 +154,4 @@ void swift::_swift_once_f(uintptr_t *predicate, void *context,
152154
swiftOnceMutex.unlock();
153155
}
154156
#endif
157+
#endif

stdlib/public/runtime/MutexPThread.cpp

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

18+
#if !defined(_WIN32)
1819
#include "swift/Runtime/Mutex.h"
1920

2021
#include "swift/Runtime/Debug.h"
@@ -142,3 +143,4 @@ void ReadWriteLockPlatformHelper::readUnlock(pthread_rwlock_t &rwlock) {
142143
void ReadWriteLockPlatformHelper::writeUnlock(pthread_rwlock_t &rwlock) {
143144
reportError(pthread_rwlock_unlock(&rwlock));
144145
}
146+
#endif

stdlib/public/runtime/MutexWin32.cpp

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

18+
#if defined(_WIN32) || defined(__CYGWIN__)
1819
#include "swift/Runtime/Mutex.h"
1920
#include "swift/Runtime/Debug.h"
2021

@@ -30,3 +31,4 @@ void ConditionPlatformHelper::wait(CONDITION_VARIABLE &condition,
3031
errorcode);
3132
}
3233
}
34+
#endif

0 commit comments

Comments
 (0)