Skip to content

Commit ad6f530

Browse files
Merge pull request #4929 from swiftwasm/main
[pull] swiftwasm from main
2 parents caf1ce1 + 6424835 commit ad6f530

27 files changed

+165
-249
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,6 @@ set(SWIFT_ANDROID_API_LEVEL "" CACHE STRING
404404

405405
set(SWIFT_ANDROID_NDK_PATH "" CACHE STRING
406406
"Path to the directory that contains the Android NDK tools that are executable on the build machine")
407-
set(SWIFT_ANDROID_NDK_CLANG_VERSION "12.0.9" CACHE STRING
408-
"The Clang version to use when building for Android.")
409407
set(SWIFT_ANDROID_DEPLOY_DEVICE_PATH "" CACHE STRING
410408
"Path on an Android device where build products will be pushed. These are used when running the test suite against the device")
411409

cmake/caches/Runtime-Android-aarch64.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,3 @@ set(SWIFT_SDK_ANDROID_ARCHITECTURES aarch64 CACHE STRING "")
2323

2424
# NOTE(compnerd) this is lollipop, which seems to still have decent usage.
2525
set(SWIFT_ANDROID_API_LEVEL 21 CACHE STRING "")
26-
# NOTE(compnerd) this matches the value from the NDK r24.
27-
set(SWIFT_ANDROID_NDK_CLANG_VERSION 14.0.1 CACHE STRING "" FORCE)

cmake/caches/Runtime-Android-armv7.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,3 @@ set(SWIFT_SDK_ANDROID_ARCHITECTURES armv7 CACHE STRING "")
2323

2424
# NOTE(compnerd) this is lollipop, which seems to still have decent usage.
2525
set(SWIFT_ANDROID_API_LEVEL 21 CACHE STRING "")
26-
# NOTE(compnerd) this matches the value from the NDK r24.
27-
set(SWIFT_ANDROID_NDK_CLANG_VERSION 14.0.1 CACHE STRING "" FORCE)
28-

docs/Android.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To follow along with this guide, you'll need:
3636
instructions in the Swift project README.
3737
2. The latest build of the Swift compiler for your Linux distro, available at
3838
https://www.swift.org/download/ or sometimes your distro package manager.
39-
3. The latest version of the Android LTS NDK (r23c at the time of this writing),
39+
3. The latest version of the Android LTS NDK (r25b at the time of this writing),
4040
available to download here:
4141
https://developer.android.com/ndk/downloads
4242
4. An Android device with remote debugging enabled or the emulator. We require
@@ -54,7 +54,7 @@ and the prebuilt Swift toolchain (add --skip-early-swift-driver if you already
5454
have a Swift toolchain in your path):
5555

5656
```
57-
$ NDK_PATH=path/to/android-ndk-r23c
57+
$ NDK_PATH=path/to/android-ndk-r25b
5858
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2022-05-31-a-ubuntu20.04/usr/bin
5959
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2022-05-31-a
6060
$ utils/build-script \
@@ -83,7 +83,7 @@ Then use the standalone Swift stdlib from the previous step to compile a Swift
8383
source file, targeting Android:
8484

8585
```
86-
$ NDK_PATH="path/to/android-ndk-r23c"
86+
$ NDK_PATH="path/to/android-ndk-r25b"
8787
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2022-05-31-a-ubuntu20.04/usr/bin
8888
$ $SWIFT_PATH/swiftc \ # The prebuilt Swift compiler you downloaded
8989
# The location of the tools used to build Android binaries
@@ -133,7 +133,7 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libBlo
133133
In addition, you'll also need to copy the Android NDK's libc++:
134134

135135
```
136-
$ adb push /path/to/android-ndk-r23c/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so /data/local/tmp
136+
$ adb push /path/to/android-ndk-r25b/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so /data/local/tmp
137137
```
138138

139139
Finally, you'll need to copy the `hello` executable you built in the
@@ -176,7 +176,7 @@ $ utils/build-script \
176176
-R \ # Build in ReleaseAssert mode.
177177
-T \ # Run all tests, including on the Android device (add --host-test to only run Android tests on the Linux host).
178178
--android \ # Build for Android.
179-
--android-ndk ~/android-ndk-r23c \ # Path to an Android NDK.
179+
--android-ndk ~/android-ndk-r25b \ # Path to an Android NDK.
180180
--android-arch aarch64 \ # Optionally specify Android architecture, alternately armv7
181181
--android-api-level 21
182182
```

lib/IRGen/GenStruct.cpp

Lines changed: 24 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -354,37 +354,6 @@ namespace {
354354
}
355355
}
356356

357-
template <class Fn>
358-
void forEachNonEmptyBaseTypeInfo(Fn fn) const {
359-
forEachNonEmptyBase([&](clang::QualType, clang::CharUnits,
360-
clang::CharUnits size) {
361-
auto &typeInfo = IGM.getOpaqueStorageTypeInfo(Size(size.getQuantity()),
362-
Alignment(1));
363-
fn(typeInfo);
364-
});
365-
}
366-
367-
template <class Fn>
368-
void forEachNonEmptyBaseTypeInfoAndBaseAddress(IRGenFunction &IGF,
369-
Address addr, Fn fn) const {
370-
forEachNonEmptyBase([&](clang::QualType,
371-
clang::CharUnits offset, clang::CharUnits size) {
372-
auto &typeInfo = IGM.getOpaqueStorageTypeInfo(Size(size.getQuantity()),
373-
Alignment(1));
374-
375-
Address baseAddr = addr;
376-
if (offset.getQuantity() != 0) {
377-
auto baseAddrVal =
378-
IGF.Builder.CreateBitCast(addr.getAddress(), IGF.IGM.Int8PtrTy);
379-
baseAddrVal = IGF.Builder.CreateConstGEP1_64(
380-
IGF.IGM.Int8Ty, baseAddrVal, offset.getQuantity());
381-
baseAddr = Address(baseAddrVal, Alignment(1));
382-
}
383-
384-
fn(typeInfo, baseAddr);
385-
});
386-
}
387-
388357
public:
389358
LoadableClangRecordTypeInfo(ArrayRef<ClangFieldInfo> fields,
390359
unsigned explosionSize, IRGenModule &IGM,
@@ -437,106 +406,6 @@ namespace {
437406
lowering.addTypedData(ClangDecl, offset.asCharUnits());
438407
}
439408

440-
void getSchema(ExplosionSchema &schema) const override {
441-
forEachNonEmptyBaseTypeInfo([&](const LoadableTypeInfo &typeInfo) {
442-
typeInfo.getSchema(schema);
443-
});
444-
445-
for (auto &field : getFields()) {
446-
field.getTypeInfo().getSchema(schema);
447-
}
448-
}
449-
450-
void projectFieldFromExplosion(IRGenFunction &IGF, Explosion &in,
451-
VarDecl *field,
452-
Explosion &out) const override {
453-
auto &fieldInfo = getFieldInfo(field);
454-
455-
// If the field requires no storage, there's nothing to do.
456-
if (fieldInfo.isEmpty())
457-
return;
458-
459-
unsigned baseOffset = 0;
460-
if (auto cxxRecord = dyn_cast<clang::CXXRecordDecl>(ClangDecl)) {
461-
baseOffset = llvm::count_if(cxxRecord->bases(), [](auto base) {
462-
auto baseType = base.getType().getCanonicalType();
463-
464-
auto baseRecord = cast<clang::RecordType>(baseType)->getDecl();
465-
auto baseCxxRecord = cast<clang::CXXRecordDecl>(baseRecord);
466-
467-
return !baseCxxRecord->isEmpty();
468-
});
469-
}
470-
471-
// Otherwise, project from the base.
472-
auto fieldRange = fieldInfo.getProjectionRange();
473-
auto elements = in.getRange(fieldRange.first + baseOffset,
474-
fieldRange.second + baseOffset);
475-
out.add(elements);
476-
}
477-
478-
void reexplode(IRGenFunction &IGF, Explosion &src,
479-
Explosion &dest) const override {
480-
forEachNonEmptyBaseTypeInfo([&](const LoadableTypeInfo &typeInfo) {
481-
typeInfo.reexplode(IGF, src, dest);
482-
});
483-
484-
for (auto &field : getFields()) {
485-
cast<LoadableTypeInfo>(field.getTypeInfo()).reexplode(IGF, src, dest);
486-
}
487-
}
488-
489-
void initialize(IRGenFunction &IGF, Explosion &e, Address addr,
490-
bool isOutlined) const override {
491-
forEachNonEmptyBaseTypeInfoAndBaseAddress(
492-
IGF, addr, [&](const LoadableTypeInfo &typeInfo, Address baseAddr) {
493-
typeInfo.initialize(IGF, e, baseAddr, isOutlined);
494-
});
495-
496-
for (auto &field : getFields()) {
497-
if (field.isEmpty())
498-
continue;
499-
500-
Address fieldAddr = field.projectAddress(IGF, addr, None);
501-
cast<LoadableTypeInfo>(field.getTypeInfo())
502-
.initialize(IGF, e, fieldAddr, isOutlined);
503-
}
504-
}
505-
506-
void loadAsTake(IRGenFunction &IGF, Address addr,
507-
Explosion &e) const override {
508-
forEachNonEmptyBaseTypeInfoAndBaseAddress(
509-
IGF, addr, [&](const LoadableTypeInfo &typeInfo, Address baseAddr) {
510-
typeInfo.loadAsTake(IGF, baseAddr, e);
511-
});
512-
513-
for (auto &field : getFields()) {
514-
if (field.isEmpty())
515-
continue;
516-
517-
Address fieldAddr = field.projectAddress(IGF, addr, None);
518-
cast<LoadableTypeInfo>(field.getTypeInfo())
519-
.loadAsTake(IGF, fieldAddr, e);
520-
}
521-
}
522-
523-
void loadAsCopy(IRGenFunction &IGF, Address addr,
524-
Explosion &e) const override {
525-
forEachNonEmptyBaseTypeInfoAndBaseAddress(
526-
IGF, addr, [&](const LoadableTypeInfo &typeInfo, Address baseAddr) {
527-
typeInfo.loadAsCopy(IGF, baseAddr, e);
528-
});
529-
530-
for (auto &field : getFields()) {
531-
if (field.isEmpty())
532-
continue;
533-
534-
Address fieldAddr = field.projectAddress(IGF, addr, None);
535-
cast<LoadableTypeInfo>(field.getTypeInfo())
536-
.loadAsCopy(IGF, fieldAddr, e);
537-
}
538-
}
539-
540409
llvm::NoneType getNonFixedOffsets(IRGenFunction &IGF) const {
541410
return None;
542411
}
@@ -1168,6 +1037,7 @@ class ClangRecordLowering {
11681037
if (ClangDecl->isUnion()) {
11691038
collectUnionFields();
11701039
} else {
1040+
collectBases();
11711041
collectStructFields();
11721042
}
11731043
}
@@ -1195,6 +1065,29 @@ class ClangRecordLowering {
11951065
return (swiftField->getClangNode().castAsDecl() == clangField);
11961066
}
11971067

1068+
void collectBases() {
1069+
auto &layout = ClangDecl->getASTContext().getASTRecordLayout(ClangDecl);
1070+
1071+
if (auto cxxRecord = dyn_cast<clang::CXXRecordDecl>(ClangDecl)) {
1072+
for (auto base : cxxRecord->bases()) {
1073+
if (base.isVirtual())
1074+
continue;
1075+
1076+
auto baseType = base.getType().getCanonicalType();
1077+
1078+
auto baseRecord = cast<clang::RecordType>(baseType)->getDecl();
1079+
auto baseCxxRecord = cast<clang::CXXRecordDecl>(baseRecord);
1080+
1081+
if (baseCxxRecord->isEmpty())
1082+
continue;
1083+
1084+
auto offset = layout.getBaseClassOffset(baseCxxRecord);
1085+
auto size = ClangDecl->getASTContext().getTypeSizeInChars(baseType);
1086+
addOpaqueField(Size(offset.getQuantity()), Size(size.getQuantity()));
1087+
}
1088+
}
1089+
}
1090+
11981091
void collectStructFields() {
11991092
auto cfi = ClangDecl->field_begin(), cfe = ClangDecl->field_end();
12001093
auto swiftProperties = SwiftDecl->getStoredProperties();

lib/PrintAsClang/PrintClangValueType.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,12 @@ void ClangValueTypePrinter::printValueTypeDecl(
263263
"*>(other._getOpaquePointer()), metadata._0);\n";
264264
os << " }\n";
265265

266-
// FIXME: the move constructor should be hidden somehow.
267-
os << " inline ";
266+
// FIXME: implement the move constructor.
267+
os << " [[noreturn]] inline ";
268268
printer.printBaseName(typeDecl);
269269
os << "(";
270270
printer.printBaseName(typeDecl);
271-
os << " &&) = default;\n";
271+
os << " &&) { abort(); }\n";
272272

273273
bodyPrinter();
274274
if (typeDecl->isStdlibDecl())

lib/SIL/IR/SILInstructions.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,11 @@ SILDebugVariable::createFromAllocation(const AllocationInst *AI) {
169169
// TODO: Support AllocBoxInst
170170

171171
if (!VarInfo)
172-
return VarInfo;
172+
return {};
173173

174-
// Copy everything but the DIExpr
175-
VarInfo->DIExpr.clear();
174+
// TODO: Support variables with expressions.
175+
if (VarInfo->DIExpr)
176+
return {};
176177

177178
// Coalesce the debug loc attached on AI into VarInfo
178179
SILType Type = AI->getType();

lib/SILOptimizer/Transforms/SILSROA.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,8 @@ createAllocas(llvm::SmallVector<AllocStackInst *, 4> &NewAllocations) {
213213
Optional<SILDebugVariable> NewDebugVarInfo =
214214
SILDebugVariable::createFromAllocation(AI);
215215
if (NewDebugVarInfo)
216-
// TODO: Handle DIExpr that is already attached
217-
NewDebugVarInfo->DIExpr = SILDebugInfoExpression::createFragment(VD);
218-
216+
NewDebugVarInfo->DIExpr.append(
217+
SILDebugInfoExpression::createFragment(VD));
219218
NewAllocations.push_back(B.createAllocStack(
220219
Loc, Type.getFieldType(VD, M, TypeExpansionContext(B.getFunction())),
221220
NewDebugVarInfo, AI->hasDynamicLifetime(), AI->isLexical()));

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ function(_add_target_variant_link_flags)
464464
# We need to add the math library, which is linked implicitly by libc++
465465
list(APPEND result "-lm")
466466
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
467-
list(APPEND result "-resource-dir=${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/${SWIFT_ANDROID_NDK_CLANG_VERSION}")
467+
file(GLOB RESOURCE_DIR ${SWIFT_SDK_ANDROID_ARCH_${LFLAGS_ARCH}_PATH}/../lib64/clang/*)
468+
list(APPEND result "-resource-dir=${RESOURCE_DIR}")
468469
endif()
469470

470471
# link against the custom C++ library

stdlib/public/Concurrency/CheckedContinuation.swift

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import Swift
1616
@_silgen_name("swift_continuation_logFailedCheck")
1717
internal func logFailedCheck(_ message: UnsafeRawPointer)
1818

19-
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
2019
/// Implementation class that holds the `UnsafeContinuation` instance for
2120
/// a `CheckedContinuation`.
2221
@available(SwiftStdlib 5.1, *)
@@ -83,9 +82,7 @@ internal final class CheckedContinuationCanary: @unchecked Sendable {
8382
}
8483
}
8584
}
86-
#endif
8785

88-
#if !SWIFT_STDLIB_TASK_TO_THREAD_MODEL_CONCURRENCY
8986
/// A mechanism to interface
9087
/// between synchronous and asynchronous code,
9188
/// logging correctness violations.
@@ -299,65 +296,4 @@ public func withCheckedThrowingContinuation<T>(
299296
body(CheckedContinuation(continuation: $0, function: function))
300297
}
301298
}
302-
#else
303-
@available(SwiftStdlib 5.1, *)
304-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
305-
public struct CheckedContinuation<T, E: Error>: Sendable {
306-
@available(SwiftStdlib 5.1, *)
307-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
308-
public init(continuation: UnsafeContinuation<T, E>, function: String = #function) {
309-
fatalError("Unavailable in task-to-thread concurrency model")
310-
}
311-
312-
@available(SwiftStdlib 5.1, *)
313-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
314-
public func resume(returning value: __owned T) {
315-
fatalError("Unavailable in task-to-thread concurrency model")
316-
}
317-
318-
@available(SwiftStdlib 5.1, *)
319-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
320-
public func resume(throwing error: __owned E) {
321-
fatalError("Unavailable in task-to-thread concurrency model")
322-
}
323-
}
324-
@available(SwiftStdlib 5.1, *)
325-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
326-
extension CheckedContinuation {
327-
@available(SwiftStdlib 5.1, *)
328-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
329-
public func resume<Er: Error>(with result: Result<T, Er>) where E == Error {
330-
fatalError("Unavailable in task-to-thread concurrency model")
331-
}
332-
333-
@available(SwiftStdlib 5.1, *)
334-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
335-
public func resume(with result: Result<T, E>) {
336-
fatalError("Unavailable in task-to-thread concurrency model")
337-
}
338299

339-
@available(SwiftStdlib 5.1, *)
340-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
341-
public func resume() where T == Void {
342-
fatalError("Unavailable in task-to-thread concurrency model")
343-
}
344-
}
345-
346-
@available(SwiftStdlib 5.1, *)
347-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
348-
public func withCheckedContinuation<T>(
349-
function: String = #function,
350-
_ body: (CheckedContinuation<T, Never>) -> Void
351-
) async -> T {
352-
fatalError("Unavailable in task-to-thread concurrency model")
353-
}
354-
355-
@available(SwiftStdlib 5.1, *)
356-
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")
357-
public func withCheckedThrowingContinuation<T>(
358-
function: String = #function,
359-
_ body: (CheckedContinuation<T, Error>) -> Void
360-
) async throws -> T {
361-
fatalError("Unavailable in task-to-thread concurrency model")
362-
}
363-
#endif

0 commit comments

Comments
 (0)