Skip to content

Commit 5de7c6f

Browse files
committed
Basic: normalise android triples when loading modules
The android API level can be ignored when loading the module. The API level controls the NDK APIs which are available and is equivalent to the SDK version for Darwin. This allows us to keep the API level in the triple which future versions of Android's toolchain does.
1 parent 7691ce3 commit 5de7c6f

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/Basic/Platform.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,16 @@ llvm::Triple swift::getTargetSpecificModuleTriple(const llvm::Triple &triple) {
328328
return llvm::Triple(newArch, newVendor, newOS, *newEnvironment);
329329
}
330330

331+
// android - drop the API level. That is not pertinent to the module; the API
332+
// availability is handled by the clang importer.
333+
if (triple.isAndroid()) {
334+
StringRef environment =
335+
llvm::Triple::getEnvironmentTypeName(triple.getEnvironment());
336+
337+
return llvm::Triple(triple.getArchName(), triple.getVendorName(),
338+
triple.getOSName(), environment);
339+
}
340+
331341
// Other platforms get no normalization.
332342
return triple;
333343
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %swift_driver_plain --driver-mode=swiftc -target aarch64-unknown-linux-android -c %s -parse-stdlib -module-name Swift -emit-module -emit-module-path %t/Swift.swiftmodule
3+
// RUN: %swift_driver_plain --driver-mode=swiftc -O -target aarch64-unknown-linux-android21 -c %s -I %t
4+

0 commit comments

Comments
 (0)