swift: enable arm build and add upstream patch that fixes linking statically against the corelibs
This commit is contained in:
parent
ae0acaab33
commit
6cef10bdb9
@ -3,13 +3,14 @@ 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.3
|
||||
TERMUX_PKG_REVISION=1
|
||||
SWIFT_RELEASE="RELEASE"
|
||||
TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz
|
||||
TERMUX_PKG_SHA256=f9e5bd81441c4ec13dd9ea290e2d7b8fe9b30ef66ad68947481022ea5179f83a
|
||||
TERMUX_PKG_HOSTBUILD=true
|
||||
TERMUX_PKG_DEPENDS="binutils-gold, clang, libc++, ndk-sysroot, libandroid-glob, libandroid-spawn, libcurl, libicu, libicu-static, libsqlite, libuuid, libxml2, libdispatch, llbuild"
|
||||
TERMUX_PKG_BUILD_DEPENDS="cmake, ninja, perl, pkg-config, python2, rsync"
|
||||
TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686, x86_64"
|
||||
TERMUX_PKG_BLACKLISTED_ARCHES="i686, x86_64"
|
||||
TERMUX_PKG_NO_STATICSPLIT=true
|
||||
|
||||
SWIFT_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;swift-remote-mirror;parser-lib;license;sourcekit-inproc;stdlib;sdk-overlay"
|
||||
@ -20,14 +21,6 @@ SWIFT_BUILD_FLAGS="$SWIFT_TOOLCHAIN_FLAGS $SWIFT_PATH_FLAGS"
|
||||
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
||||
SWIFT_BIN="swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE-ubuntu20.04"
|
||||
SWIFT_BINDIR="$TERMUX_PKG_HOSTBUILD_DIR/$SWIFT_BIN/usr/bin"
|
||||
SWIFT_BUILD_FLAGS="$SWIFT_BUILD_FLAGS --android --android-ndk $TERMUX_STANDALONE_TOOLCHAIN
|
||||
--android-arch $TERMUX_ARCH --android-api-level $TERMUX_PKG_API_LEVEL
|
||||
--android-icu-uc $TERMUX_PREFIX/lib/libicuuc.so --android-icu-uc-include $TERMUX_PREFIX/include/
|
||||
--android-icu-i18n $TERMUX_PREFIX/lib/libicui18n.so --android-icu-i18n-include $TERMUX_PREFIX/include/
|
||||
--android-icu-data $TERMUX_PREFIX/lib/libicudata.so --build-toolchain-only
|
||||
--skip-local-build --skip-local-host-install --build-runtime-with-host-compiler
|
||||
--cross-compile-hosts=android-$TERMUX_ARCH --cross-compile-deps-path=$TERMUX_PREFIX
|
||||
--native-swift-tools-path=$SWIFT_BINDIR --native-clang-tools-path=$TERMUX_STANDALONE_TOOLCHAIN/bin"
|
||||
fi
|
||||
|
||||
termux_step_post_get_source() {
|
||||
@ -89,6 +82,8 @@ termux_step_host_build() {
|
||||
}
|
||||
|
||||
termux_step_pre_configure() {
|
||||
export SWIFT_ARCH=$TERMUX_ARCH
|
||||
test $SWIFT_ARCH == 'arm' && SWIFT_ARCH='armv7'
|
||||
if [ "$TERMUX_PKG_QUICK_REBUILD" = "false" ]; then
|
||||
cd llbuild
|
||||
# A single patch needed from the existing llbuild package
|
||||
@ -103,7 +98,7 @@ termux_step_pre_configure() {
|
||||
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" \
|
||||
$TERMUX_PKG_BUILDER_DIR/swiftpm-Utilities-bootstrap | \
|
||||
sed "s%\@TERMUX_PKG_BUILDDIR\@%${TERMUX_PKG_BUILDDIR}%g" | \
|
||||
sed "s%\@TERMUX_ARCH\@%${TERMUX_ARCH}%g" | patch -p1
|
||||
sed "s%\@SWIFT_ARCH\@%${SWIFT_ARCH}%g" | patch -p1
|
||||
|
||||
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
||||
sed "s%\@TERMUX_STANDALONE_TOOLCHAIN\@%${TERMUX_STANDALONE_TOOLCHAIN}%g" \
|
||||
@ -111,7 +106,7 @@ termux_step_pre_configure() {
|
||||
sed "s%\@CCTERMUX_HOST_PLATFORM\@%${CCTERMUX_HOST_PLATFORM}%g" | \
|
||||
sed "s%\@TERMUX_HOST_PLATFORM\@%${TERMUX_HOST_PLATFORM}%g" | \
|
||||
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" | \
|
||||
sed "s%\@TERMUX_ARCH\@%${TERMUX_ARCH}%g" > $TERMUX_PKG_BUILDDIR/swiftpm-android-flags.json
|
||||
sed "s%\@SWIFT_ARCH\@%${SWIFT_ARCH}%g" > $TERMUX_PKG_BUILDDIR/swiftpm-android-flags.json
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@ -124,8 +119,19 @@ termux_step_make() {
|
||||
-tools-directory $TERMUX_STANDALONE_TOOLCHAIN/$TERMUX_HOST_PLATFORM/bin \
|
||||
-Xlinker -rpath -Xlinker $TERMUX_PREFIX/lib"
|
||||
export TERMUX_SWIFT_FLAGS="$TERMUX_SWIFTPM_FLAGS -resource-dir \
|
||||
$TERMUX_PKG_BUILDDIR/swift-android-$TERMUX_ARCH/lib/swift"
|
||||
$TERMUX_PKG_BUILDDIR/swift-android-$SWIFT_ARCH/lib/swift"
|
||||
export HOST_SWIFTC="$SWIFT_BINDIR/swiftc"
|
||||
SWIFT_BUILD_FLAGS="$SWIFT_BUILD_FLAGS --android --android-ndk $TERMUX_STANDALONE_TOOLCHAIN
|
||||
--android-arch $SWIFT_ARCH --android-api-level $TERMUX_PKG_API_LEVEL
|
||||
--android-icu-uc $TERMUX_PREFIX/lib/libicuuc.so
|
||||
--android-icu-uc-include $TERMUX_PREFIX/include/
|
||||
--android-icu-i18n $TERMUX_PREFIX/lib/libicui18n.so
|
||||
--android-icu-i18n-include $TERMUX_PREFIX/include/
|
||||
--android-icu-data $TERMUX_PREFIX/lib/libicudata.so --build-toolchain-only
|
||||
--skip-local-build --skip-local-host-install --build-runtime-with-host-compiler
|
||||
--cross-compile-hosts=android-$SWIFT_ARCH --cross-compile-deps-path=$TERMUX_PREFIX
|
||||
--native-swift-tools-path=$SWIFT_BINDIR
|
||||
--native-clang-tools-path=$TERMUX_STANDALONE_TOOLCHAIN/bin"
|
||||
fi
|
||||
|
||||
SWIFT_BUILD_ROOT=$TERMUX_PKG_BUILDDIR $TERMUX_PKG_SRCDIR/swift/utils/build-script \
|
||||
@ -141,6 +147,6 @@ termux_step_make_install() {
|
||||
|
||||
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
|
||||
mv $TERMUX_PREFIX/glibc-native.modulemap \
|
||||
$TERMUX_PREFIX/lib/swift/android/$TERMUX_ARCH/glibc.modulemap
|
||||
$TERMUX_PREFIX/lib/swift/android/$SWIFT_ARCH/glibc.modulemap
|
||||
fi
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ index 9379031947d..91cecf46a37 100644
|
||||
endif()
|
||||
|
||||
- set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/${cxx_arch}")
|
||||
+ set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sysroot/usr/lib/aarch64-linux-android")
|
||||
+ set(android_libcxx_path "${SWIFT_ANDROID_NDK_PATH}/sysroot/usr/lib/${SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE}")
|
||||
list(APPEND link_libraries ${android_libcxx_path}/libc++abi.a
|
||||
${android_libcxx_path}/libc++_shared.so)
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
@ -78,7 +78,16 @@ diff --git a/swift/cmake/modules/SwiftConfigureSDK.cmake b/swift/cmake/modules/S
|
||||
index 3a87bfcd80b..89e9827db6c 100644
|
||||
--- a/swift/cmake/modules/SwiftConfigureSDK.cmake
|
||||
+++ b/swift/cmake/modules/SwiftConfigureSDK.cmake
|
||||
@@ -234,7 +234,7 @@ macro(configure_sdk_unix name architectures)
|
||||
@@ -285,7 +285,7 @@ macro(configure_sdk_unix name architectures)
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "arm-linux-androideabi")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "arm")
|
||||
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
- set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/platforms/android-${SWIFT_ANDROID_API_LEVEL}/arch-arm")
|
||||
+ set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NDK_PATH}/sysroot")
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NATIVE_SYSROOT}")
|
||||
else()
|
||||
@@ -298,7 +298,7 @@ macro(configure_sdk_unix name architectures)
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_TRIPLE "aarch64-linux-android")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_ALT_SPELLING "aarch64")
|
||||
if(NOT "${SWIFT_ANDROID_NDK_PATH}" STREQUAL "")
|
||||
@ -87,7 +96,7 @@ index 3a87bfcd80b..89e9827db6c 100644
|
||||
elseif(NOT "${SWIFT_ANDROID_NATIVE_SYSROOT}" STREQUAL "")
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_PATH "${SWIFT_ANDROID_NATIVE_SYSROOT}")
|
||||
else()
|
||||
@@ -275,8 +275,9 @@ macro(configure_sdk_unix name architectures)
|
||||
@@ -339,8 +339,9 @@ macro(configure_sdk_unix name architectures)
|
||||
"${SWIFT_ANDROID_NDK_PATH}/toolchains/x86_64-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/${_swift_android_prebuilt_build}")
|
||||
else()
|
||||
set(SWIFT_SDK_ANDROID_ARCH_${arch}_NDK_PREBUILT_PATH
|
||||
|
13
packages/swift/swift-lib-ClangImporter-ImportType.cpp.patch
Normal file
13
packages/swift/swift-lib-ClangImporter-ImportType.cpp.patch
Normal file
@ -0,0 +1,13 @@
|
||||
diff --git a/swift/lib/ClangImporter/ImportType.cpp b/swift/lib/ClangImporter/ImportType.cpp
|
||||
index 08238b491c2..7bafbbac38b 100644
|
||||
--- a/swift/lib/ClangImporter/ImportType.cpp
|
||||
+++ b/swift/lib/ClangImporter/ImportType.cpp
|
||||
@@ -506,7 +506,7 @@ namespace {
|
||||
if (size > 4096)
|
||||
return Type();
|
||||
|
||||
- SmallVector<TupleTypeElt, 8> elts{size, elementType};
|
||||
+ SmallVector<TupleTypeElt, 8> elts{static_cast<size_t>(size), elementType};
|
||||
return TupleType::get(elts, elementType->getASTContext());
|
||||
}
|
||||
|
678
packages/swift/swift-static-stdlib.patch
Normal file
678
packages/swift/swift-static-stdlib.patch
Normal file
@ -0,0 +1,678 @@
|
||||
commit e8fe2298e393764add98d4490e545f179b7a69e7
|
||||
Author: Dario Rexin <drexin@apple.com>
|
||||
Date: Tue Jul 28 15:17:20 2020 -0700
|
||||
|
||||
Properly compute resource folder when linking statically
|
||||
|
||||
- deduplicate the logic to compute the resource folder
|
||||
- install headers and module files in shared and static resource folders
|
||||
- forward -static flag when calling swiftc with -print-target-info
|
||||
|
||||
diff --git a/swift/include/swift/Frontend/Frontend.h b/swift/include/swift/Frontend/Frontend.h
|
||||
index 7718407233f..b2046d0ff8e 100644
|
||||
--- a/swift/include/swift/Frontend/Frontend.h
|
||||
+++ b/swift/include/swift/Frontend/Frontend.h
|
||||
@@ -128,7 +128,8 @@ public:
|
||||
bool parseArgs(ArrayRef<const char *> Args, DiagnosticEngine &Diags,
|
||||
SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>>
|
||||
*ConfigurationFileBuffers = nullptr,
|
||||
- StringRef workingDirectory = {});
|
||||
+ StringRef workingDirectory = {},
|
||||
+ StringRef mainExecutablePath = {});
|
||||
|
||||
/// Sets specific options based on the given serialized Swift binary data.
|
||||
///
|
||||
@@ -213,8 +214,11 @@ public:
|
||||
/// Computes the runtime resource path relative to the given Swift
|
||||
/// executable.
|
||||
static void computeRuntimeResourcePathFromExecutablePath(
|
||||
- StringRef mainExecutablePath,
|
||||
- llvm::SmallString<128> &runtimeResourcePath);
|
||||
+ StringRef mainExecutablePath, bool shared,
|
||||
+ llvm::SmallVectorImpl<char> &runtimeResourcePath);
|
||||
+
|
||||
+ /// Appends `lib/swift[_static]` to the given path
|
||||
+ static void appendSwiftLibDir(llvm::SmallVectorImpl<char> &path, bool shared);
|
||||
|
||||
void setSDKPath(const std::string &Path);
|
||||
|
||||
diff --git a/swift/include/swift/Frontend/FrontendOptions.h b/swift/include/swift/Frontend/FrontendOptions.h
|
||||
index 81f72772239..51ff57eb20a 100644
|
||||
--- a/swift/include/swift/Frontend/FrontendOptions.h
|
||||
+++ b/swift/include/swift/Frontend/FrontendOptions.h
|
||||
@@ -301,6 +301,11 @@ public:
|
||||
/// Indicates whether the action will immediately run code.
|
||||
static bool isActionImmediate(ActionType);
|
||||
|
||||
+ /// Determines whether the static or shared resource folder is used.
|
||||
+ /// When set to `true`, the default resource folder will be set to
|
||||
+ /// '.../lib/swift', otherwise '.../lib/swift_static'.
|
||||
+ bool UseSharedResourceFolder = true;
|
||||
+
|
||||
/// \return true if action only parses without doing other compilation steps.
|
||||
static bool shouldActionOnlyParse(ActionType);
|
||||
|
||||
diff --git a/swift/include/swift/Option/FrontendOptions.td b/swift/include/swift/Option/FrontendOptions.td
|
||||
index 8190787c330..3ac11f1ecba 100644
|
||||
--- a/swift/include/swift/Option/FrontendOptions.td
|
||||
+++ b/swift/include/swift/Option/FrontendOptions.td
|
||||
@@ -719,4 +719,8 @@ def target_sdk_version : Separate<["-"], "target-sdk-version">,
|
||||
def target_variant_sdk_version : Separate<["-"], "target-variant-sdk-version">,
|
||||
HelpText<"The version of target variant SDK used for compilation">;
|
||||
|
||||
+
|
||||
+def use_static_resource_dir
|
||||
+ : Flag<["-"], "use-static-resource-dir">,
|
||||
+ HelpText<"Use resources in the static resource directory">;
|
||||
} // end let Flags = [FrontendOption, NoDriverOption, HelpHidden]
|
||||
diff --git a/swift/lib/Driver/Driver.cpp b/swift/lib/Driver/Driver.cpp
|
||||
index 00eaeb27bd7..4fedb54f365 100644
|
||||
--- a/swift/lib/Driver/Driver.cpp
|
||||
+++ b/swift/lib/Driver/Driver.cpp
|
||||
@@ -2248,6 +2248,13 @@ bool Driver::handleImmediateArgs(const ArgList &Args, const ToolChain &TC) {
|
||||
commandLine.push_back(resourceDirArg->getValue());
|
||||
}
|
||||
|
||||
+ if (Args.hasFlag(options::OPT_static_executable,
|
||||
+ options::OPT_no_static_executable, false) ||
|
||||
+ Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
|
||||
+ false)) {
|
||||
+ commandLine.push_back("-use-static-resource-dir");
|
||||
+ }
|
||||
+
|
||||
std::string executable = getSwiftProgramPath();
|
||||
|
||||
// FIXME: This bypasses mechanisms like -v and -###. (SR-12119)
|
||||
diff --git a/swift/lib/Driver/ToolChains.cpp b/swift/lib/Driver/ToolChains.cpp
|
||||
index f1c748c78a5..100ed7a7f9c 100644
|
||||
--- a/swift/lib/Driver/ToolChains.cpp
|
||||
+++ b/swift/lib/Driver/ToolChains.cpp
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "swift/Driver/Compilation.h"
|
||||
#include "swift/Driver/Driver.h"
|
||||
#include "swift/Driver/Job.h"
|
||||
+#include "swift/Frontend/Frontend.h"
|
||||
#include "swift/Option/Options.h"
|
||||
#include "clang/Basic/Version.h"
|
||||
#include "clang/Driver/Util.h"
|
||||
@@ -523,6 +524,13 @@ ToolChain::constructInvocation(const CompileJobAction &job,
|
||||
Arguments.push_back("-track-system-dependencies");
|
||||
}
|
||||
|
||||
+ if (context.Args.hasFlag(options::OPT_static_executable,
|
||||
+ options::OPT_no_static_executable, false) ||
|
||||
+ context.Args.hasFlag(options::OPT_static_stdlib,
|
||||
+ options::OPT_no_static_stdlib, false)) {
|
||||
+ Arguments.push_back("-use-static-resource-dir");
|
||||
+ }
|
||||
+
|
||||
context.Args.AddLastArg(
|
||||
Arguments,
|
||||
options::
|
||||
@@ -1256,24 +1264,18 @@ void ToolChain::getClangLibraryPath(const ArgList &Args,
|
||||
void ToolChain::getResourceDirPath(SmallVectorImpl<char> &resourceDirPath,
|
||||
const llvm::opt::ArgList &args,
|
||||
bool shared) const {
|
||||
- // FIXME: Duplicated from CompilerInvocation, but in theory the runtime
|
||||
- // library link path and the standard library module import path don't
|
||||
- // need to be the same.
|
||||
if (const Arg *A = args.getLastArg(options::OPT_resource_dir)) {
|
||||
StringRef value = A->getValue();
|
||||
resourceDirPath.append(value.begin(), value.end());
|
||||
} else if (!getTriple().isOSDarwin() && args.hasArg(options::OPT_sdk)) {
|
||||
StringRef value = args.getLastArg(options::OPT_sdk)->getValue();
|
||||
resourceDirPath.append(value.begin(), value.end());
|
||||
- llvm::sys::path::append(resourceDirPath, "usr", "lib",
|
||||
- shared ? "swift" : "swift_static");
|
||||
+ llvm::sys::path::append(resourceDirPath, "usr");
|
||||
+ CompilerInvocation::appendSwiftLibDir(resourceDirPath, shared);
|
||||
} else {
|
||||
auto programPath = getDriver().getSwiftProgramPath();
|
||||
- resourceDirPath.append(programPath.begin(), programPath.end());
|
||||
- llvm::sys::path::remove_filename(resourceDirPath); // remove /swift
|
||||
- llvm::sys::path::remove_filename(resourceDirPath); // remove /bin
|
||||
- llvm::sys::path::append(resourceDirPath, "lib",
|
||||
- shared ? "swift" : "swift_static");
|
||||
+ CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
|
||||
+ programPath, shared, resourceDirPath);
|
||||
}
|
||||
|
||||
StringRef libSubDir = getPlatformNameForTriple(getTriple());
|
||||
diff --git a/swift/lib/Frontend/ArgsToFrontendOptionsConverter.cpp b/swift/lib/Frontend/ArgsToFrontendOptionsConverter.cpp
|
||||
index 7113e2d4c0c..eabc8a5514b 100644
|
||||
--- a/swift/lib/Frontend/ArgsToFrontendOptionsConverter.cpp
|
||||
+++ b/swift/lib/Frontend/ArgsToFrontendOptionsConverter.cpp
|
||||
@@ -187,6 +187,7 @@ bool ArgsToFrontendOptionsConverter::convert(
|
||||
Opts.EnableSourceImport |= Args.hasArg(OPT_enable_source_import);
|
||||
Opts.ImportUnderlyingModule |= Args.hasArg(OPT_import_underlying_module);
|
||||
Opts.EnableIncrementalDependencyVerifier |= Args.hasArg(OPT_verify_incremental_dependencies);
|
||||
+ Opts.UseSharedResourceFolder = !Args.hasArg(OPT_use_static_resource_dir);
|
||||
|
||||
computeImportObjCHeaderOptions();
|
||||
computeImplicitImportModuleNames();
|
||||
diff --git a/swift/lib/Frontend/CompilerInvocation.cpp b/swift/lib/Frontend/CompilerInvocation.cpp
|
||||
index ba5f25bdec4..ea09add706d 100644
|
||||
--- a/swift/lib/Frontend/CompilerInvocation.cpp
|
||||
+++ b/swift/lib/Frontend/CompilerInvocation.cpp
|
||||
@@ -39,16 +39,25 @@ swift::CompilerInvocation::CompilerInvocation() {
|
||||
}
|
||||
|
||||
void CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
|
||||
- StringRef mainExecutablePath, llvm::SmallString<128> &runtimeResourcePath) {
|
||||
- runtimeResourcePath.assign(mainExecutablePath);
|
||||
+ StringRef mainExecutablePath, bool shared,
|
||||
+ llvm::SmallVectorImpl<char> &runtimeResourcePath) {
|
||||
+ runtimeResourcePath.append(mainExecutablePath.begin(),
|
||||
+ mainExecutablePath.end());
|
||||
+
|
||||
llvm::sys::path::remove_filename(runtimeResourcePath); // Remove /swift
|
||||
llvm::sys::path::remove_filename(runtimeResourcePath); // Remove /bin
|
||||
- llvm::sys::path::append(runtimeResourcePath, "lib", "swift");
|
||||
+ appendSwiftLibDir(runtimeResourcePath, shared);
|
||||
+}
|
||||
+
|
||||
+void CompilerInvocation::appendSwiftLibDir(llvm::SmallVectorImpl<char> &path,
|
||||
+ bool shared) {
|
||||
+ llvm::sys::path::append(path, "lib", shared ? "swift" : "swift_static");
|
||||
}
|
||||
|
||||
void CompilerInvocation::setMainExecutablePath(StringRef Path) {
|
||||
llvm::SmallString<128> LibPath;
|
||||
- computeRuntimeResourcePathFromExecutablePath(Path, LibPath);
|
||||
+ computeRuntimeResourcePathFromExecutablePath(
|
||||
+ Path, FrontendOpts.UseSharedResourceFolder, LibPath);
|
||||
setRuntimeResourcePath(LibPath.str());
|
||||
|
||||
llvm::SmallString<128> DiagnosticDocsPath(Path);
|
||||
@@ -1597,11 +1606,10 @@ static bool ParseMigratorArgs(MigratorOptions &Opts,
|
||||
}
|
||||
|
||||
bool CompilerInvocation::parseArgs(
|
||||
- ArrayRef<const char *> Args,
|
||||
- DiagnosticEngine &Diags,
|
||||
+ ArrayRef<const char *> Args, DiagnosticEngine &Diags,
|
||||
SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>>
|
||||
*ConfigurationFileBuffers,
|
||||
- StringRef workingDirectory) {
|
||||
+ StringRef workingDirectory, StringRef mainExecutablePath) {
|
||||
using namespace options;
|
||||
|
||||
if (Args.empty())
|
||||
@@ -1632,6 +1640,10 @@ bool CompilerInvocation::parseArgs(
|
||||
return true;
|
||||
}
|
||||
|
||||
+ if (!mainExecutablePath.empty()) {
|
||||
+ setMainExecutablePath(mainExecutablePath);
|
||||
+ }
|
||||
+
|
||||
ParseModuleInterfaceArgs(ModuleInterfaceOpts, ParsedArgs);
|
||||
SaveModuleInterfaceArgs(ModuleInterfaceOpts, FrontendOpts, ParsedArgs, Diags);
|
||||
|
||||
diff --git a/swift/lib/FrontendTool/FrontendTool.cpp b/swift/lib/FrontendTool/FrontendTool.cpp
|
||||
index e78174844be..7d8d63656f4 100644
|
||||
--- a/swift/lib/FrontendTool/FrontendTool.cpp
|
||||
+++ b/swift/lib/FrontendTool/FrontendTool.cpp
|
||||
@@ -2078,17 +2078,18 @@ int swift::performFrontend(ArrayRef<const char *> Args,
|
||||
}
|
||||
|
||||
CompilerInvocation Invocation;
|
||||
- std::string MainExecutablePath = llvm::sys::fs::getMainExecutable(Argv0,
|
||||
- MainAddr);
|
||||
- Invocation.setMainExecutablePath(MainExecutablePath);
|
||||
|
||||
SmallString<128> workingDirectory;
|
||||
llvm::sys::fs::current_path(workingDirectory);
|
||||
|
||||
+ std::string MainExecutablePath =
|
||||
+ llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
|
||||
+
|
||||
// Parse arguments.
|
||||
SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4> configurationFileBuffers;
|
||||
if (Invocation.parseArgs(Args, Instance->getDiags(),
|
||||
- &configurationFileBuffers, workingDirectory)) {
|
||||
+ &configurationFileBuffers, workingDirectory,
|
||||
+ MainExecutablePath)) {
|
||||
return finishDiagProcessing(1, /*verifierEnabled*/ false);
|
||||
}
|
||||
|
||||
diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
index a2f682ece68..3ddfa28e3a8 100644
|
||||
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
|
||||
@@ -628,6 +628,9 @@ function(_add_swift_target_library_single target name)
|
||||
"${SWIFTLIB_SINGLE_multiple_parameter_options}"
|
||||
${ARGN})
|
||||
|
||||
+ translate_flag(${SWIFTLIB_SINGLE_STATIC} "STATIC"
|
||||
+ SWIFTLIB_SINGLE_STATIC_keyword)
|
||||
+
|
||||
# Determine macCatalyst build flavor
|
||||
get_maccatalyst_build_flavor(maccatalyst_build_flavor
|
||||
"${SWIFTLIB_SINGLE_SDK}" "${SWIFTLIB_SINGLE_MACCATALYST_BUILD_FLAVOR}")
|
||||
@@ -757,6 +760,7 @@ function(_add_swift_target_library_single target name)
|
||||
${SWIFTLIB_SINGLE_IS_STDLIB_CORE_keyword}
|
||||
${SWIFTLIB_SINGLE_IS_SDK_OVERLAY_keyword}
|
||||
${embed_bitcode_arg}
|
||||
+ ${SWIFTLIB_SINGLE_STATIC_keyword}
|
||||
INSTALL_IN_COMPONENT "${SWIFTLIB_SINGLE_INSTALL_IN_COMPONENT}"
|
||||
MACCATALYST_BUILD_FLAVOR "${SWIFTLIB_SINGLE_MACCATALYST_BUILD_FLAVOR}")
|
||||
add_swift_source_group("${SWIFTLIB_SINGLE_EXTERNAL_SOURCES}")
|
||||
diff --git a/swift/stdlib/cmake/modules/SwiftSource.cmake b/swift/stdlib/cmake/modules/SwiftSource.cmake
|
||||
index 8164f97a164..2feef60f515 100644
|
||||
--- a/swift/stdlib/cmake/modules/SwiftSource.cmake
|
||||
+++ b/swift/stdlib/cmake/modules/SwiftSource.cmake
|
||||
@@ -29,7 +29,7 @@ function(handle_swift_sources
|
||||
dependency_sibgen_target_out_var_name
|
||||
sourcesvar externalvar name)
|
||||
cmake_parse_arguments(SWIFTSOURCES
|
||||
- "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE"
|
||||
+ "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC"
|
||||
"SDK;ARCHITECTURE;INSTALL_IN_COMPONENT;MACCATALYST_BUILD_FLAVOR"
|
||||
"DEPENDS;COMPILE_FLAGS;MODULE_NAME"
|
||||
${ARGN})
|
||||
@@ -41,6 +41,8 @@ function(handle_swift_sources
|
||||
IS_SDK_OVERLAY_arg)
|
||||
translate_flag(${SWIFTSOURCES_EMBED_BITCODE} "EMBED_BITCODE"
|
||||
EMBED_BITCODE_arg)
|
||||
+ translate_flag(${SWIFTSOURCES_STATIC} "STATIC"
|
||||
+ STATIC_arg)
|
||||
|
||||
if(SWIFTSOURCES_IS_MAIN)
|
||||
set(SWIFTSOURCES_INSTALL_IN_COMPONENT never_install)
|
||||
@@ -278,13 +280,15 @@ endfunction()
|
||||
# [MODULE_NAME] # The module name.
|
||||
# [INSTALL_IN_COMPONENT] # Install produced files.
|
||||
# [EMBED_BITCODE] # Embed LLVM bitcode into the .o files
|
||||
+# [STATIC] # Also write .swiftmodule etc. to static
|
||||
+# # resource folder
|
||||
# )
|
||||
function(_compile_swift_files
|
||||
dependency_target_out_var_name dependency_module_target_out_var_name
|
||||
dependency_sib_target_out_var_name dependency_sibopt_target_out_var_name
|
||||
dependency_sibgen_target_out_var_name)
|
||||
cmake_parse_arguments(SWIFTFILE
|
||||
- "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE"
|
||||
+ "IS_MAIN;IS_STDLIB;IS_STDLIB_CORE;IS_SDK_OVERLAY;EMBED_BITCODE;STATIC"
|
||||
"OUTPUT;MODULE_NAME;INSTALL_IN_COMPONENT;MACCATALYST_BUILD_FLAVOR"
|
||||
"SOURCES;FLAGS;DEPENDS;SDK;ARCHITECTURE;OPT_FLAGS;MODULE_DIR"
|
||||
${ARGN})
|
||||
@@ -448,8 +452,11 @@ function(_compile_swift_files
|
||||
endforeach()
|
||||
|
||||
set(module_file)
|
||||
+ set(module_file_static)
|
||||
set(module_doc_file)
|
||||
+ set(module_doc_file_static)
|
||||
set(interface_file)
|
||||
+ set(interface_file_static)
|
||||
|
||||
if(NOT SWIFTFILE_IS_MAIN)
|
||||
# Determine the directory where the module file should be placed.
|
||||
@@ -464,17 +471,28 @@ function(_compile_swift_files
|
||||
list(APPEND swift_flags "-parse-as-library")
|
||||
|
||||
set(module_base "${module_dir}/${SWIFTFILE_MODULE_NAME}")
|
||||
+
|
||||
+ set(module_dir_static "${SWIFTSTATICLIB_DIR}/${library_subdir}")
|
||||
+ set(module_base_static "${module_dir_static}/${SWIFTFILE_MODULE_NAME}")
|
||||
+
|
||||
set(module_triple ${SWIFT_SDK_${library_subdir_sdk}_ARCH_${SWIFTFILE_ARCHITECTURE}_MODULE})
|
||||
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS OR
|
||||
SWIFTFILE_SDK STREQUAL "MACCATALYST")
|
||||
set(specific_module_dir "${module_base}.swiftmodule")
|
||||
set(module_base "${module_base}.swiftmodule/${module_triple}")
|
||||
+
|
||||
+ set(specific_module_dir_static "${module_base_static}.swiftmodule")
|
||||
+ set(module_base_static "${module_base_static}.swiftmodule/${module_triple}")
|
||||
else()
|
||||
set(specific_module_dir)
|
||||
+ set(specific_module_dir_static)
|
||||
endif()
|
||||
set(module_file "${module_base}.swiftmodule")
|
||||
set(module_doc_file "${module_base}.swiftdoc")
|
||||
|
||||
+ set(module_file_static "${module_base_static}.swiftmodule")
|
||||
+ set(module_doc_file_static "${module_base_static}.swiftdoc")
|
||||
+
|
||||
# FIXME: These don't really belong inside the swiftmodule, but there's not
|
||||
# an obvious alternate place to put them.
|
||||
set(sib_file "${module_base}.Onone.sib")
|
||||
@@ -483,6 +501,7 @@ function(_compile_swift_files
|
||||
|
||||
if(SWIFT_ENABLE_MODULE_INTERFACES)
|
||||
set(interface_file "${module_base}.swiftinterface")
|
||||
+ set(interface_file_static "${module_base_static}.swiftinterface")
|
||||
list(APPEND swift_module_flags
|
||||
"-emit-module-interface-path" "${interface_file}")
|
||||
endif()
|
||||
@@ -510,10 +529,20 @@ function(_compile_swift_files
|
||||
swift_install_in_component(DIRECTORY "${specific_module_dir}"
|
||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}"
|
||||
COMPONENT "${SWIFTFILE_INSTALL_IN_COMPONENT}")
|
||||
+ if(SWIFTFILE_STATIC)
|
||||
+ swift_install_in_component(DIRECTORY "${specific_module_dir_static}"
|
||||
+ DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift_static/${library_subdir}"
|
||||
+ COMPONENT "${SWIFTFILE_INSTALL_IN_COMPONENT}")
|
||||
+ endif()
|
||||
else()
|
||||
swift_install_in_component(FILES ${module_outputs}
|
||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}"
|
||||
COMPONENT "${SWIFTFILE_INSTALL_IN_COMPONENT}")
|
||||
+ if(SWIFTFILE_STATIC)
|
||||
+ swift_install_in_component(FILES ${module_outputs}
|
||||
+ DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift_static/${library_subdir}"
|
||||
+ COMPONENT "${SWIFTFILE_INSTALL_IN_COMPONENT}")
|
||||
+ endif()
|
||||
endif()
|
||||
|
||||
# macCatalyst zippered module setup
|
||||
@@ -563,8 +592,10 @@ function(_compile_swift_files
|
||||
endif()
|
||||
|
||||
set(module_outputs "${module_file}" "${module_doc_file}")
|
||||
+ set(module_outputs_static "${module_file_static}" "${module_doc_file_static}")
|
||||
if(interface_file)
|
||||
list(APPEND module_outputs "${interface_file}")
|
||||
+ list(APPEND module_outputs_static "${interface_file_static}")
|
||||
endif()
|
||||
|
||||
if(SWIFTFILE_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
|
||||
@@ -573,10 +604,23 @@ function(_compile_swift_files
|
||||
COMPONENT "${SWIFTFILE_INSTALL_IN_COMPONENT}"
|
||||
OPTIONAL
|
||||
PATTERN "Project" EXCLUDE)
|
||||
+
|
||||
+ if(SWIFTFILE_STATIC)
|
||||
+ swift_install_in_component(DIRECTORY "${specific_module_dir_static}"
|
||||
+ DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift_static/${library_subdir}"
|
||||
+ COMPONENT "${SWIFTFILE_INSTALL_IN_COMPONENT}"
|
||||
+ OPTIONAL
|
||||
+ PATTERN "Project" EXCLUDE)
|
||||
+ endif()
|
||||
else()
|
||||
swift_install_in_component(FILES ${module_outputs}
|
||||
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift/${library_subdir}"
|
||||
COMPONENT "${SWIFTFILE_INSTALL_IN_COMPONENT}")
|
||||
+ if(SWIFTFILE_STATIC)
|
||||
+ swift_install_in_component(FILES ${module_outputs}
|
||||
+ DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift_static/${library_subdir}"
|
||||
+ COMPONENT "${SWIFTFILE_INSTALL_IN_COMPONENT}")
|
||||
+ endif()
|
||||
endif()
|
||||
|
||||
set(line_directive_tool "${SWIFT_SOURCE_DIR}/utils/line-directive")
|
||||
@@ -758,7 +802,27 @@ function(_compile_swift_files
|
||||
${swift_ide_test_dependency}
|
||||
${create_dirs_dependency_target}
|
||||
COMMENT "Generating ${module_file}")
|
||||
- set("${dependency_module_target_out_var_name}" "${module_dependency_target}" PARENT_SCOPE)
|
||||
+
|
||||
+ if(SWIFTFILE_STATIC)
|
||||
+ add_custom_command_target(
|
||||
+ module_dependency_target_static
|
||||
+ COMMAND
|
||||
+ "${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir_static}
|
||||
+ ${specific_module_dir_static}
|
||||
+ COMMAND
|
||||
+ "${CMAKE_COMMAND}" "-E" "copy" ${module_file} ${module_file_static}
|
||||
+ COMMAND
|
||||
+ "${CMAKE_COMMAND}" "-E" "copy" ${module_doc_file} ${module_doc_file_static}
|
||||
+ COMMAND
|
||||
+ "${CMAKE_COMMAND}" "-E" "copy" ${interface_file} ${interface_file_static}
|
||||
+ OUTPUT ${module_outputs_static}
|
||||
+ DEPENDS
|
||||
+ "${module_dependency_target}"
|
||||
+ COMMENT "Generating ${module_file}")
|
||||
+ set("${dependency_module_target_out_var_name}" "${module_dependency_target_static}" PARENT_SCOPE)
|
||||
+ else()
|
||||
+ set("${dependency_module_target_out_var_name}" "${module_dependency_target}" PARENT_SCOPE)
|
||||
+ endif()
|
||||
|
||||
# macCatalyst zippered swiftmodule
|
||||
if(maccatalyst_build_flavor STREQUAL "zippered")
|
||||
diff --git a/swift/stdlib/public/Platform/CMakeLists.txt b/swift/stdlib/public/Platform/CMakeLists.txt
|
||||
index 8ded40c5791..998e454b78c 100644
|
||||
--- a/swift/stdlib/public/Platform/CMakeLists.txt
|
||||
+++ b/swift/stdlib/public/Platform/CMakeLists.txt
|
||||
@@ -78,6 +78,7 @@ foreach(sdk ${SWIFT_SDKS})
|
||||
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
|
||||
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
|
||||
set(module_dir "${SWIFTLIB_DIR}/${arch_subdir}")
|
||||
+ set(module_dir_static "${SWIFTSTATICLIB_DIR}/${arch_subdir}")
|
||||
|
||||
if(${sdk} STREQUAL ANDROID)
|
||||
set(glibc_modulemap_source "bionic.modulemap.gyb")
|
||||
@@ -87,6 +88,7 @@ foreach(sdk ${SWIFT_SDKS})
|
||||
set(glibc_modulemap_source "glibc.modulemap.gyb")
|
||||
endif()
|
||||
set(glibc_modulemap_out "${module_dir}/glibc.modulemap")
|
||||
+ set(glibc_modulemap_out_static "${module_dir_static}/glibc.modulemap")
|
||||
|
||||
# Configure the module map based on the target. Each platform needs to
|
||||
# reference different headers, based on what's available in their glibc.
|
||||
@@ -102,6 +104,21 @@ foreach(sdk ${SWIFT_SDKS})
|
||||
|
||||
list(APPEND glibc_modulemap_target_list ${glibc_modulemap_target})
|
||||
|
||||
+ if(SWIFT_BUILD_STATIC_STDLIB)
|
||||
+ add_custom_command_target(
|
||||
+ copy_glibc_modulemap_static
|
||||
+ COMMAND
|
||||
+ "${CMAKE_COMMAND}" "-E" "make_directory" ${module_dir_static}
|
||||
+ COMMAND
|
||||
+ "${CMAKE_COMMAND}" "-E" "copy" ${glibc_modulemap_out} ${glibc_modulemap_out_static}
|
||||
+ OUTPUT ${glibc_modulemap_out_static}
|
||||
+ DEPENDS
|
||||
+ "${glibc_modulemap_target}"
|
||||
+ COMMENT "Copying Glibc modulemap to static resources")
|
||||
+
|
||||
+ list(APPEND glibc_modulemap_target_list ${copy_glibc_modulemap_static})
|
||||
+ endif()
|
||||
+
|
||||
# If this SDK is a target for a non-native host, except if it's for Android
|
||||
# with its own native sysroot, create a native modulemap without a sysroot
|
||||
# prefix. This is the one we'll install instead.
|
||||
@@ -134,6 +149,11 @@ foreach(sdk ${SWIFT_SDKS})
|
||||
DESTINATION "lib/swift/${arch_subdir}"
|
||||
COMPONENT sdk-overlay)
|
||||
|
||||
+ if(SWIFT_BUILD_STATIC_STDLIB)
|
||||
+ swift_install_in_component(FILES "${glibc_modulemap_out}"
|
||||
+ DESTINATION "lib/swift_static/${arch_subdir}"
|
||||
+ COMPONENT sdk-overlay)
|
||||
+ endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
add_custom_target(glibc_modulemap DEPENDS ${glibc_modulemap_target_list})
|
||||
diff --git a/swift/stdlib/public/SwiftShims/CMakeLists.txt b/swift/stdlib/public/SwiftShims/CMakeLists.txt
|
||||
index b6d3edc4781..23ac72bcda5 100644
|
||||
--- a/swift/stdlib/public/SwiftShims/CMakeLists.txt
|
||||
+++ b/swift/stdlib/public/SwiftShims/CMakeLists.txt
|
||||
@@ -55,10 +55,18 @@ set(sources
|
||||
module.modulemap
|
||||
)
|
||||
set(output_dir "${SWIFTLIB_DIR}/shims")
|
||||
+set(output_dir_static "${SWIFTSTATICLIB_DIR}/shims")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT "${output_dir}"
|
||||
COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir}")
|
||||
+
|
||||
+if(SWIFT_BUILD_STATIC_STDLIB)
|
||||
+ add_custom_command(
|
||||
+ OUTPUT "${output_dir_static}"
|
||||
+ COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${output_dir_static}")
|
||||
+endif()
|
||||
+
|
||||
set(outputs)
|
||||
foreach(input ${sources})
|
||||
add_custom_command(
|
||||
@@ -70,6 +78,18 @@ foreach(input ${sources})
|
||||
"${output_dir}/${input}"
|
||||
COMMENT "Copying ${input} to ${output_dir}")
|
||||
list(APPEND outputs "${output_dir}/${input}")
|
||||
+
|
||||
+ if(SWIFT_BUILD_STATIC_STDLIB)
|
||||
+ add_custom_command(
|
||||
+ OUTPUT "${output_dir_static}/${input}"
|
||||
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
|
||||
+ COMMAND
|
||||
+ "${CMAKE_COMMAND}" "-E" "copy_if_different"
|
||||
+ "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
|
||||
+ "${output_dir_static}/${input}"
|
||||
+ COMMENT "Copying ${input} to ${output_dir_static}")
|
||||
+ list(APPEND outputs "${output_dir_static}/${input}")
|
||||
+ endif()
|
||||
endforeach()
|
||||
# Put the output dir itself last so that it isn't considered the primary output.
|
||||
list(APPEND outputs "${output_dir}")
|
||||
@@ -121,8 +141,25 @@ add_custom_command_target(unused_var
|
||||
CUSTOM_TARGET_NAME "symlink_clang_headers"
|
||||
OUTPUT "${SWIFTLIB_DIR}/clang"
|
||||
COMMENT "Symlinking Clang resource headers into ${SWIFTLIB_DIR}/clang")
|
||||
+
|
||||
add_dependencies(copy_shim_headers symlink_clang_headers)
|
||||
|
||||
+if(SWIFT_BUILD_STATIC_STDLIB)
|
||||
+ add_custom_command_target(unused_var
|
||||
+ COMMAND
|
||||
+ "${CMAKE_COMMAND}" "-E" "make_directory" "${SWIFTSTATICLIB_DIR}"
|
||||
+ COMMAND
|
||||
+ "${CMAKE_COMMAND}" "-E" "${cmake_symlink_option}"
|
||||
+ "${clang_headers_location}"
|
||||
+ "${SWIFTSTATICLIB_DIR}/clang"
|
||||
+
|
||||
+ CUSTOM_TARGET_NAME "symlink_clang_headers_static"
|
||||
+ OUTPUT "${SWIFTSTATICLIB_DIR}/clang"
|
||||
+ COMMENT "Symlinking Clang resource headers into ${SWIFTSTATICLIB_DIR}/clang")
|
||||
+
|
||||
+ add_dependencies(copy_shim_headers symlink_clang_headers_static)
|
||||
+endif()
|
||||
+
|
||||
if(NOT SWIFT_BUILT_STANDALONE)
|
||||
if(TARGET clang-resource-headers) # LLVM > 8
|
||||
set(clang_resource_headers clang-resource-headers)
|
||||
@@ -146,6 +183,12 @@ swift_install_in_component(FILES ${sources}
|
||||
DESTINATION "lib/swift/shims"
|
||||
COMPONENT stdlib)
|
||||
|
||||
+if(SWIFT_BUILD_STATIC_STDLIB)
|
||||
+ swift_install_in_component(FILES ${sources}
|
||||
+ DESTINATION "lib/swift_static/shims"
|
||||
+ COMPONENT stdlib)
|
||||
+endif()
|
||||
+
|
||||
# Install Clang headers under the Swift library so that an installed Swift's
|
||||
# module importer can find the compiler headers corresponding to its Clang.
|
||||
swift_install_in_component(DIRECTORY "${clang_headers_location}/"
|
||||
@@ -153,11 +196,26 @@ swift_install_in_component(DIRECTORY "${clang_headers_location}/"
|
||||
COMPONENT clang-builtin-headers
|
||||
PATTERN "*.h")
|
||||
|
||||
+if(SWIFT_BUILD_STATIC_STDLIB)
|
||||
+ swift_install_in_component(DIRECTORY "${clang_headers_location}/"
|
||||
+ DESTINATION "lib/swift_static/clang"
|
||||
+ COMPONENT clang-builtin-headers
|
||||
+ PATTERN "*.h")
|
||||
+endif()
|
||||
+
|
||||
+
|
||||
swift_install_symlink_component(clang-resource-dir-symlink
|
||||
LINK_NAME clang
|
||||
TARGET ../clang/$ENV{TERMUX_CLANG_VERSION}
|
||||
DESTINATION "lib/swift")
|
||||
|
||||
+if(SWIFT_BUILD_STATIC_STDLIB)
|
||||
+ swift_install_symlink_component(clang-resource-dir-symlink
|
||||
+ LINK_NAME clang
|
||||
+ TARGET ../clang/$ENV{TERMUX_CLANG_VERSION}
|
||||
+ DESTINATION "lib/swift_static")
|
||||
+endif()
|
||||
+
|
||||
# Possibly install Clang headers under Clang's resource directory in case we
|
||||
# need to use a different version of the headers than the installed Clang. This
|
||||
# should be used in conjunction with clang-resource-dir-symlink.
|
||||
diff --git a/swift/test/Driver/print_target_info.swift b/swift/test/Driver/print_target_info.swift
|
||||
index fdb636dcf1f..7009520492d 100644
|
||||
--- a/swift/test/Driver/print_target_info.swift
|
||||
+++ b/swift/test/Driver/print_target_info.swift
|
||||
@@ -4,6 +4,10 @@
|
||||
// RUN: %swift_driver -print-target-info -target x86_64-unknown-linux | %FileCheck -check-prefix CHECK-LINUX %s
|
||||
// RUN: %target-swift-frontend -print-target-info -target x86_64-unknown-linux | %FileCheck -check-prefix CHECK-LINUX %s
|
||||
|
||||
+// RUN: %swift_driver -print-target-info -target x86_64-unknown-linux -static-executable | %FileCheck -check-prefix CHECK-LINUX-STATIC %s
|
||||
+// RUN: %swift_driver -print-target-info -target x86_64-unknown-linux -static-stdlib | %FileCheck -check-prefix CHECK-LINUX-STATIC %s
|
||||
+// RUN: %target-swift-frontend -print-target-info -target x86_64-unknown-linux -use-static-resource-dir | %FileCheck -check-prefix CHECK-LINUX-STATIC %s
|
||||
+
|
||||
// RUN: %swift_driver -print-target-info -target x86_64-apple-macosx10.15 -target-variant x86_64-apple-ios13-macabi | %FileCheck -check-prefix CHECK-ZIPPERED %s
|
||||
// RUN: %target-swift-frontend -print-target-info -target x86_64-apple-macosx10.15 -target-variant x86_64-apple-ios13-macabi | %FileCheck -check-prefix CHECK-ZIPPERED %s
|
||||
|
||||
@@ -34,9 +38,22 @@
|
||||
// CHECK-LINUX: "librariesRequireRPath": false
|
||||
// CHECK-LINUX: }
|
||||
|
||||
+// CHECK-LINUX: "runtimeResourcePath": "{{.*}}lib{{(/|\\\\)}}swift"
|
||||
+
|
||||
// CHECK-LINUX-NOT: "targetVariant":
|
||||
|
||||
|
||||
+// CHECK-LINUX-STATIC: "target": {
|
||||
+// CHECK-LINUX-STATIC: "triple": "x86_64-unknown-linux",
|
||||
+// CHECK-LINUX-STATIC: "moduleTriple": "x86_64-unknown-linux",
|
||||
+// CHECK-LINUX-STATIC: "librariesRequireRPath": false
|
||||
+// CHECK-LINUX-STATIC: }
|
||||
+
|
||||
+// CHECK-LINUX-STATIC: "runtimeResourcePath": "{{.*}}lib{{(/|\\\\)}}swift_static"
|
||||
+
|
||||
+// CHECK-LINUX-STATIC-NOT: "targetVariant":
|
||||
+
|
||||
+
|
||||
// CHECK-ZIPPERED: "target": {
|
||||
// CHECK-ZIPPERED: "triple": "x86_64-apple-macosx10.15"
|
||||
// CHECK-ZIPPERED: "unversionedTriple": "x86_64-apple-macosx"
|
||||
diff --git a/swift/tools/driver/modulewrap_main.cpp b/swift/tools/driver/modulewrap_main.cpp
|
||||
index 187893ec723..510cf5d3eda 100644
|
||||
--- a/swift/tools/driver/modulewrap_main.cpp
|
||||
+++ b/swift/tools/driver/modulewrap_main.cpp
|
||||
@@ -44,6 +44,7 @@ private:
|
||||
std::string OutputFilename = "-";
|
||||
llvm::Triple TargetTriple;
|
||||
std::vector<std::string> InputFilenames;
|
||||
+ bool UseSharedResourceFolder = true;
|
||||
|
||||
public:
|
||||
bool hasSingleInput() const { return InputFilenames.size() == 1; }
|
||||
@@ -60,6 +61,8 @@ public:
|
||||
const std::vector<std::string> &getInputFilenames() { return InputFilenames; }
|
||||
llvm::Triple &getTargetTriple() { return TargetTriple; }
|
||||
|
||||
+ bool useSharedResourceFolder() { return UseSharedResourceFolder; }
|
||||
+
|
||||
int parseArgs(llvm::ArrayRef<const char *> Args, DiagnosticEngine &Diags) {
|
||||
using namespace options;
|
||||
|
||||
@@ -111,6 +114,13 @@ public:
|
||||
OutputFilename = A->getValue();
|
||||
}
|
||||
|
||||
+ if (ParsedArgs.hasFlag(OPT_static_executable, OPT_no_static_executable,
|
||||
+ false) ||
|
||||
+ ParsedArgs.hasFlag(OPT_static_stdlib, OPT_no_static_stdlib, false) ||
|
||||
+ ParsedArgs.hasArg(OPT_static)) {
|
||||
+ UseSharedResourceFolder = false;
|
||||
+ }
|
||||
+
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@@ -159,7 +169,8 @@ int modulewrap_main(ArrayRef<const char *> Args, const char *Argv0,
|
||||
SearchPathOptions SearchPathOpts;
|
||||
SmallString<128> RuntimeResourcePath;
|
||||
CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
|
||||
- MainExecutablePath, RuntimeResourcePath);
|
||||
+ MainExecutablePath, Invocation.useSharedResourceFolder(),
|
||||
+ RuntimeResourcePath);
|
||||
SearchPathOpts.RuntimeResourcePath = std::string(RuntimeResourcePath.str());
|
||||
|
||||
SourceManager SrcMgr;
|
@ -0,0 +1,13 @@
|
||||
diff --git a/swift/stdlib/public/runtime/Float16Support.cpp b/swift/stdlib/public/runtime/Float16Support.cpp
|
||||
index d7377400ba0..9d8c4940054 100644
|
||||
--- a/swift/stdlib/public/runtime/Float16Support.cpp
|
||||
+++ b/swift/stdlib/public/runtime/Float16Support.cpp
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
// Android NDK <r21 do not provide `__aeabi_d2h` in the compiler runtime,
|
||||
// provide shims in that case.
|
||||
-#if (defined(ANDROID) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
|
||||
+#if (defined(__ANDROID__) && defined(__ARM_ARCH_7A__) && defined(__ARM_EABI__)) || \
|
||||
((defined(__i686__) || defined(__x86_64__)) && !defined(__APPLE__))
|
||||
|
||||
#include "../SwiftShims/Visibility.h"
|
@ -2,6 +2,17 @@ diff --git a/swift/utils/build-script-impl b/swift/utils/build-script-impl
|
||||
index b1d060328bc..218c9215260 100755
|
||||
--- a/swift/utils/build-script-impl
|
||||
+++ b/swift/utils/build-script-impl
|
||||
@@ -472,6 +473,10 @@ function set_build_options_for_host() {
|
||||
SWIFT_HOST_TRIPLE="aarch64-unknown-linux-android"
|
||||
llvm_target_arch="AArch64"
|
||||
;;
|
||||
+ android-armv7)
|
||||
+ SWIFT_HOST_TRIPLE="armv7a-unknown-linux-androideabi"
|
||||
+ llvm_target_arch="ARM"
|
||||
+ ;;
|
||||
linux-armv6)
|
||||
SWIFT_HOST_TRIPLE="armv6-unknown-linux-gnueabihf"
|
||||
llvm_target_arch="ARM"
|
||||
@@ -703,6 +705,7 @@ function set_build_options_for_host() {
|
||||
llvm_cmake_options+=(
|
||||
-DLLVM_TOOL_COMPILER_RT_BUILD:BOOL="$(false_true ${SKIP_BUILD_COMPILER_RT})"
|
||||
@ -36,7 +47,7 @@ index b1d060328bc..218c9215260 100755
|
||||
fi
|
||||
else
|
||||
local host_install_destdir="${INSTALL_DESTDIR}"
|
||||
@@ -1422,6 +1426,36 @@ function swift_c_flags() {
|
||||
@@ -1422,6 +1426,38 @@ function swift_c_flags() {
|
||||
fi
|
||||
}
|
||||
|
||||
@ -60,10 +71,12 @@ index b1d060328bc..218c9215260 100755
|
||||
+ local -n options=$2
|
||||
+ case $host in
|
||||
+ android-a*)
|
||||
+ local NDK_ARCH=$ANDROID_ARCH
|
||||
+ test $NDK_ARCH == 'armv7' && NDK_ARCH='armv7-a'
|
||||
+ options+=(
|
||||
+ -DCMAKE_SYSTEM_NAME=Android
|
||||
+ -DCMAKE_SYSTEM_VERSION=${ANDROID_API_LEVEL}
|
||||
+ -DCMAKE_SYSTEM_PROCESSOR=${ANDROID_ARCH}
|
||||
+ -DCMAKE_SYSTEM_PROCESSOR=${NDK_ARCH}
|
||||
+ -DCMAKE_ANDROID_STANDALONE_TOOLCHAIN:PATH=${ANDROID_NDK}
|
||||
+ )
|
||||
+ ;;
|
||||
@ -132,11 +145,14 @@ index b1d060328bc..218c9215260 100755
|
||||
)
|
||||
fi
|
||||
|
||||
@@ -2239,6 +2243,11 @@ for host in "${ALL_HOSTS[@]}"; do
|
||||
@@ -2239,6 +2243,14 @@ for host in "${ALL_HOSTS[@]}"; do
|
||||
)
|
||||
if [[ $(is_cross_tools_host ${host}) ]] ; then
|
||||
add_cross_cmake_options ${host} cmake_options
|
||||
+ cmake_options+=(
|
||||
+ -DCMAKE_FIND_ROOT_PATH:PATH="${CROSS_COMPILE_DEPS_PATH}"
|
||||
+ -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER
|
||||
+ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY
|
||||
+ -DCMAKE_C_FLAGS="$CFLAGS --target=$CCTERMUX_HOST_PLATFORM $CPPFLAGS"
|
||||
+ -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS --target=$CCTERMUX_HOST_PLATFORM"
|
||||
+ -DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS --target=$CCTERMUX_HOST_PLATFORM"
|
||||
|
@ -16,7 +16,7 @@ index f7439427..5f284c48 100755
|
||||
"""Returns the target-triple of the current machine."""
|
||||
try:
|
||||
- target_info_json = subprocess.check_output([args.swiftc_path, '-print-target-info'], stderr=subprocess.PIPE, universal_newlines=True).strip()
|
||||
+ target_info_json = subprocess.check_output([args.swiftc_path, '-print-target-info', '-target', '@TERMUX_ARCH@-unknown-linux-android'], stderr=subprocess.PIPE, universal_newlines=True).strip()
|
||||
+ target_info_json = subprocess.check_output([args.swiftc_path, '-print-target-info', '-target', '@SWIFT_ARCH@-unknown-linux-android'], stderr=subprocess.PIPE, universal_newlines=True).strip()
|
||||
args.target_info = json.loads(target_info_json)
|
||||
return args.target_info["target"]["unversionedTriple"]
|
||||
except Exception as e:
|
||||
@ -135,7 +135,7 @@ index f7439427..5f284c48 100755
|
||||
cross_compile_hosts = args.cross_compile_hosts
|
||||
if build_target == 'x86_64-apple-macosx' and "macosx-arm64" in cross_compile_hosts:
|
||||
build_flags += ["--arch", "x86_64", "--arch", "arm64"]
|
||||
+ elif args.cross_compiling and "android-@TERMUX_ARCH@" in cross_compile_hosts:
|
||||
+ elif args.cross_compiling and "android-@SWIFT_ARCH@" in cross_compile_hosts:
|
||||
+ build_flags.extend([
|
||||
+ "--destination", "@TERMUX_PKG_BUILDDIR@/swiftpm-android-flags.json",
|
||||
+ "-Xlinker", "-rpath", "-Xlinker", "@TERMUX_PREFIX@/lib",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 1,
|
||||
"target": "@TERMUX_ARCH@-unknown-linux-android",
|
||||
"target": "@SWIFT_ARCH@-unknown-linux-android",
|
||||
"toolchain-bin-dir": "@TERMUX_STANDALONE_TOOLCHAIN@/bin",
|
||||
"sdk": "@TERMUX_STANDALONE_TOOLCHAIN@/sysroot",
|
||||
"extra-cc-flags": [
|
||||
|
@ -32,6 +32,18 @@ index b6d925e1..3e546554 100644
|
||||
OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION}
|
||||
OUTPUT_NAME PackageDescription
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/${PACKAGE_DESCRIPTION_VERSION}
|
||||
diff --git a/swiftpm/Sources/SPMBuildCore/Triple.swift b/swiftpm/Sources/SPMBuildCore/Triple.swift
|
||||
index 361dc283..e9091607 100644
|
||||
--- a/swiftpm/Sources/SPMBuildCore/Triple.swift
|
||||
+++ b/swiftpm/Sources/SPMBuildCore/Triple.swift
|
||||
@@ -40,6 +40,7 @@ public struct Triple: Encodable, Equatable {
|
||||
case s390x
|
||||
case aarch64
|
||||
case armv7
|
||||
+ case armv7a
|
||||
case arm
|
||||
case arm64
|
||||
case arm64e
|
||||
diff --git a/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt b/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
|
||||
index bbc43d98..bc5ee576 100644
|
||||
--- a/swiftpm/swift-tools-support-core/Sources/TSCBasic/CMakeLists.txt
|
||||
@ -45,3 +57,19 @@ index bbc43d98..bc5ee576 100644
|
||||
endif()
|
||||
# NOTE(compnerd) workaround for CMake not setting up include flags yet
|
||||
set_target_properties(TSCBasic PROPERTIES
|
||||
diff --git a/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift b/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
|
||||
index 0658e55b..9221950b 100644
|
||||
--- a/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
|
||||
+++ b/swiftpm/swift-tools-support-core/Sources/TSCUtility/FSWatch.swift
|
||||
@@ -429,7 +429,11 @@ public final class Inotify {
|
||||
|
||||
private func FD_ZERO(_ set: inout fd_set) {
|
||||
#if os(Android)
|
||||
+ #if arch(arm)
|
||||
+ set.fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
+ #else
|
||||
set.fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
+ #endif
|
||||
#else
|
||||
set.__fds_bits = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user