diff --git a/packages/swift/build.sh b/packages/swift/build.sh index 6872122c4..90fc1578b 100644 --- a/packages/swift/build.sh +++ b/packages/swift/build.sh @@ -3,7 +3,7 @@ TERMUX_PKG_DESCRIPTION="Swift is a high-performance system programming language" TERMUX_PKG_LICENSE="Apache-2.0, NCSA" TERMUX_PKG_MAINTAINER="@buttaface" TERMUX_PKG_VERSION=5.5.1 -TERMUX_PKG_REVISION=1 +TERMUX_PKG_REVISION=2 SWIFT_RELEASE="RELEASE" TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz TERMUX_PKG_SHA256=b4092b2584919f718a55ad0ed460fbc48e84ec979a9397ce0adce307aba41ac9 diff --git a/packages/swift/swift-llvm-ar.patch b/packages/swift/swift-llvm-ar.patch new file mode 100644 index 000000000..51694e2ea --- /dev/null +++ b/packages/swift/swift-llvm-ar.patch @@ -0,0 +1,50 @@ +diff --git a/llbuild/lib/BuildSystem/BuildSystem.cpp b/llbuild/lib/BuildSystem/BuildSystem.cpp +index 297dee34..40df58ca 100644 +--- a/llbuild/lib/BuildSystem/BuildSystem.cpp ++++ b/llbuild/lib/BuildSystem/BuildSystem.cpp +@@ -3269,7 +3269,7 @@ class ArchiveShellCommand : public ExternalCommand { + if (const char *ar = std::getenv("AR")) + args.push_back(std::string(ar)); + else +- args.push_back("ar"); ++ args.push_back("llvm-ar"); + args.push_back("cr"); + args.push_back(archiveName); + args.insert(args.end(), archiveInputs.begin(), archiveInputs.end()); +diff --git a/swift/lib/Driver/UnixToolChains.cpp b/swift/lib/Driver/UnixToolChains.cpp +index 1dc32acfd83..d01445c2ef5 100644 +--- a/swift/lib/Driver/UnixToolChains.cpp ++++ b/swift/lib/Driver/UnixToolChains.cpp +@@ -384,9 +386,12 @@ toolchains::GenericUnix::constructInvocation(const StaticLinkJobAction &job, + + ArgStringList Arguments; + ++ const char *AR; + // Configure the toolchain. +- const char *AR = +- context.OI.LTOVariant != OutputInfo::LTOKind::None ? "llvm-ar" : "ar"; ++ if (getTriple().isAndroid()) ++ AR = "llvm-ar"; ++ else ++ AR = context.OI.LTOVariant != OutputInfo::LTOKind::None ? "llvm-ar" : "ar"; + Arguments.push_back("crs"); + + Arguments.push_back( +diff --git a/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift b/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift +index a08e3fa1..11d87b85 100644 +--- a/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift ++++ b/swift-driver/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift +@@ -291,7 +291,12 @@ extension GenericUnixToolchain { + + commandLine.append(contentsOf: inputs.filter { $0.type == .object } + .map { .path($0.file) }) +- return try getToolPath(.staticLinker(lto)) ++ if targetTriple.environment == .android { ++ // Always use the LTO archiver llvm-ar for Android ++ return try getToolPath(.staticLinker(.llvmFull)) ++ } else { ++ return try getToolPath(.staticLinker(lto)) ++ } + } + + }