swift: bump revision to use clang 11 headers and remove some unused patches

This commit is contained in:
Butta 2020-12-23 00:17:36 +05:30 committed by buttaface
parent 206246fc9d
commit 131b4ff765
5 changed files with 9 additions and 267 deletions

View File

@ -4,6 +4,7 @@ TERMUX_PKG_LICENSE="Apache-2.0, NCSA"
TERMUX_PKG_MAINTAINER="@buttaface"
TERMUX_PKG_VERSION=5.3.2
SWIFT_RELEASE="RELEASE"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://github.com/apple/swift/archive/swift-$TERMUX_PKG_VERSION-$SWIFT_RELEASE.tar.gz
TERMUX_PKG_SHA256=2087bb002dfef7ea2d7fbfaa097eeafd10d997cae52e2f34bb115fca68dd8039
TERMUX_PKG_HOSTBUILD=true
@ -89,7 +90,8 @@ termux_step_pre_configure() {
patch -p1 < $TERMUX_PKG_BUILDER_DIR/../llbuild/lib-llvm-Support-CmakeLists.txt.patch
cd ../llvm-project
patch -p2 < $TERMUX_PKG_BUILDER_DIR/../libllvm/tools-clang-lib-Driver-ToolChain.cpp.patch
patch -p1 < $TERMUX_PKG_BUILDER_DIR/../libllvm/clang-lib-Driver-ToolChain.cpp.patch
patch -p1 < $TERMUX_PKG_BUILDER_DIR/../libllvm/clang-lib-Driver-ToolChains-Linux.cpp.patch
cd ..
sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" \
@ -117,7 +119,6 @@ termux_step_make() {
-Xlinker -rpath -Xlinker $TERMUX_PREFIX/lib"
export TERMUX_SWIFT_FLAGS="$TERMUX_SWIFTPM_FLAGS -resource-dir \
$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

View File

@ -1,30 +0,0 @@
diff --git a/llvm-project/clang/lib/Driver/ToolChains/Linux.cpp b/llvm-project/clang/lib/Driver/ToolChains/Linux.cpp
index bff1ab1009be..6b127b5c11aa 100644
--- a/llvm-project/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/llvm-project/clang/lib/Driver/ToolChains/Linux.cpp
@@ -403,7 +403,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
if (Triple.getVendor() == llvm::Triple::OpenEmbedded &&
Triple.isArch64Bit())
addPathIfExists(D, SysRoot + "/usr/" + OSLibDir, Paths);
- else
+ else if (!IsAndroid)
addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
if (IsRISCV) {
StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
@@ -451,7 +451,15 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
addPathIfExists(D, D.Dir + "/../lib", Paths);
addPathIfExists(D, SysRoot + "/lib", Paths);
- addPathIfExists(D, SysRoot + "/usr/lib", Paths);
+ bool nativeBuild = Triple == llvm::Triple(llvm::sys::getDefaultTargetTriple());
+ if (nativeBuild || !IsAndroid)
+ addPathIfExists(D, SysRoot + "/usr/lib", Paths);
+
+ if (IsAndroid) {
+ addPathIfExists(D, SysRoot + "/usr/" + MultiarchTriple + "/lib", Paths);
+ addPathIfExists(D, "/system/" + OSLibDir, Paths);
+ ExtraOpts.push_back("-rpath=" + SysRoot + "/usr/lib");
+ }
}
ToolChain::CXXStdlibType Linux::GetDefaultCXXStdlibType() const {

View File

@ -28,18 +28,6 @@ index b40bd4d881e..8c51c6b6857 100644
# We need to add the math library, which is linked implicitly by libc++
list(APPEND result "-lm")
@@ -491,11 +491,6 @@ function(_add_variant_link_flags)
swift_android_cxx_libraries_for_arch(${LFLAGS_ARCH} cxx_link_libraries)
list(APPEND link_libraries ${cxx_link_libraries})
- # link against the ICU libraries
- list(APPEND link_libraries
- ${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_I18N}
- ${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_UC})
-
swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)
list(APPEND library_search_directories ${path})
diff --git a/swift/lib/Driver/CMakeLists.txt b/swift/lib/Driver/CMakeLists.txt
index 448f5044b70..e665dfcfefe 100644
--- a/swift/lib/Driver/CMakeLists.txt
@ -135,59 +123,6 @@ index 9f3cf240d3d..d2ce14d5f47 100644
endif()
function(swift_create_stdlib_targets name variant define_all_alias)
diff --git a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
index a2f682ece68..95e2c6e8a99 100644
--- a/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
+++ b/swift/stdlib/cmake/modules/AddSwiftStdlib.cmake
@@ -359,11 +359,6 @@ function(_add_target_variant_link_flags)
swift_android_cxx_libraries_for_arch(${LFLAGS_ARCH} cxx_link_libraries)
list(APPEND link_libraries ${cxx_link_libraries})
- # link against the ICU libraries
- list(APPEND link_libraries
- ${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_I18N}
- ${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_UC})
-
swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)
list(APPEND library_search_directories ${path})
@@ -1767,6 +1762,14 @@ function(add_swift_target_library name)
list(APPEND swiftlib_link_flags_all "-dynamiclib -Wl,-headerpad_max_install_names")
endif()
+ set(SWIFTLIB_${sdk}_SOURCES ${SWIFTLIB_SOURCES})
+ if(name STREQUAL swiftRuntime)
+ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
+ list(REMOVE_ITEM SWIFTLIB_${sdk}_SOURCES ImageInspectionELF.cpp)
+ swift_runtime_static_libraries(${sdk})
+ endif()
+ endif()
+
set(sdk_supported_archs
${SWIFT_SDK_${sdk}_ARCHITECTURES}
${SWIFT_SDK_${sdk}_MODULE_ARCHITECTURES})
@@ -1804,6 +1807,12 @@ function(add_swift_target_library name)
set(swiftlib_module_dependency_targets)
set(swiftlib_private_link_libraries_targets)
+ if(name STREQUAL swiftCore)
+ # This initializes swiftlib_private_link_libraries_targets for swiftCore,
+ # so don't move it away from the variable declaration just above.
+ swift_core_private_libraries(${sdk} ${arch} swiftlib_private_link_libraries_targets)
+ endif()
+
if(NOT BUILD_STANDALONE)
foreach(mod ${swiftlib_module_depends_flattened})
if(DEFINED maccatalyst_build_flavor)
@@ -1920,7 +1929,7 @@ function(add_swift_target_library name)
${SWIFTLIB_STATIC_keyword}
${SWIFTLIB_OBJECT_LIBRARY_keyword}
${SWIFTLIB_INSTALL_WITH_SHARED_keyword}
- ${SWIFTLIB_SOURCES}
+ ${SWIFTLIB_${sdk}_SOURCES}
TARGET_LIBRARY
MODULE_TARGETS ${module_variant_names}
SDK ${sdk}
diff --git a/swift/stdlib/public/Platform/CMakeLists.txt b/swift/stdlib/public/Platform/CMakeLists.txt
index 8ded40c5791..c811000b1d1 100644
--- a/swift/stdlib/public/Platform/CMakeLists.txt
@ -245,161 +180,6 @@ index 23ac72bcda5..23aecfc9bc5 100644
DESTINATION "lib/swift_static")
endif()
diff --git a/swift/stdlib/public/core/CMakeLists.txt b/swift/stdlib/public/core/CMakeLists.txt
index 7ab092655c7..494d4d62aa3 100644
--- a/swift/stdlib/public/core/CMakeLists.txt
+++ b/swift/stdlib/public/core/CMakeLists.txt
@@ -226,11 +226,9 @@ set(SWIFTLIB_GYB_SOURCES
set(GROUP_INFO_JSON_FILE ${CMAKE_CURRENT_SOURCE_DIR}/GroupInfo.json)
set(swift_core_link_flags "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}")
set(swift_core_framework_depends)
-set(swift_core_private_link_libraries)
set(swift_stdlib_compile_flags "${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS}")
if(SWIFT_PRIMARY_VARIANT_SDK IN_LIST SWIFT_APPLE_PLATFORMS)
list(APPEND swift_core_link_flags "-all_load")
- list(APPEND swift_core_private_link_libraries icucore)
else()
# With the GNU linker the equivalent of -all_load is to tell the linker
# --whole-archive before the archive and --no-whole-archive after (without
@@ -243,35 +241,42 @@ else()
# effort has been completed.
#set(LINK_FLAGS
# -Wl,--whole-archive swiftRuntime -Wl,--no-whole-archive)
- if("${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "")
- list(APPEND swift_core_private_link_libraries
- ${SWIFT_${SWIFT_PRIMARY_VARIANT_SDK}_${SWIFT_PRIMARY_VARIANT_ARCH}_ICU_UC}
- ${SWIFT_${SWIFT_PRIMARY_VARIANT_SDK}_${SWIFT_PRIMARY_VARIANT_ARCH}_ICU_I18N})
+endif()
+
+function(swift_core_private_libraries sdk arch libraries_var_name)
+ set(private_link_libraries)
+ if(${sdk} IN_LIST SWIFT_APPLE_PLATFORMS)
+ list(APPEND private_link_libraries icucore)
else()
- list(APPEND swift_core_private_link_libraries -licui18nswift -licuucswift -licudataswift)
+
+
+ if(${sdk} STREQUAL ${SWIFT_HOST_VARIANT_SDK} AND NOT "${SWIFT_PATH_TO_LIBICU_BUILD}" STREQUAL "")
+ list(APPEND private_link_libraries -licui18nswift -licuucswift -licudataswift)
+ else()
+ list(APPEND private_link_libraries ${SWIFT_${sdk}_${arch}_ICU_UC}
+ ${SWIFT_${sdk}_${arch}_ICU_I18N})
+ endif()
endif()
-endif()
-if(SWIFT_PRIMARY_VARIANT_SDK STREQUAL ANDROID)
- # workaround for libatomic needing to be after object files for swiftCore.so
- list(APPEND swift_core_private_link_libraries atomic)
-elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL CYGWIN)
- # TODO(compnerd) cache this variable to permit re-configuration
- execute_process(COMMAND "cygpath" "-u" "$ENV{SYSTEMROOT}" OUTPUT_VARIABLE ENV_SYSTEMROOT)
- list(APPEND swift_core_private_link_libraries "${ENV_SYSTEMROOT}/system32/psapi.dll")
-elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL FREEBSD)
- find_library(EXECINFO_LIBRARY execinfo)
- list(APPEND swift_core_private_link_libraries ${EXECINFO_LIBRARY})
- # workaround for libatomic needing to be after object files for swiftCore.so
- list(APPEND swift_core_private_link_libraries
- ${SWIFTLIB_DIR}/clang/lib/freebsd/libclang_rt.builtins-${SWIFT_PRIMARY_VARIANT_ARCH}.a)
-elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL LINUX)
- if(SWIFT_BUILD_STATIC_STDLIB)
- list(APPEND swift_core_private_link_libraries swiftImageInspectionShared)
+ if(${sdk} STREQUAL CYGWIN)
+ if(${sdk} STREQUAL ${SWIFT_HOST_VARIANT_SDK})
+ # TODO(compnerd) cache this variable to permit re-configuration
+ execute_process(COMMAND "cygpath" "-u" "$ENV{SYSTEMROOT}" OUTPUT_VARIABLE ENV_SYSTEMROOT)
+ list(APPEND private_link_libraries "${ENV_SYSTEMROOT}/system32/psapi.dll")
+ else()
+ message(FATAL_ERROR "CYGWIN cross-compilation doesn't know where to find psapi.dll.")
+ endif()
+ elseif(${sdk} STREQUAL FREEBSD)
+ find_library(EXECINFO_LIBRARY execinfo)
+ list(APPEND private_link_libraries ${EXECINFO_LIBRARY})
+ elseif(${sdk} STREQUAL LINUX AND SWIFT_BUILD_STATIC_STDLIB)
+ list(APPEND private_link_libraries swiftImageInspectionShared)
+ elseif(${sdk} STREQUAL WINDOWS)
+ list(APPEND private_link_libraries shell32;DbgHelp)
endif()
-elseif(SWIFT_PRIMARY_VARIANT_SDK STREQUAL WINDOWS)
- list(APPEND swift_core_private_link_libraries shell32;DbgHelp)
-endif()
+
+ set(${libraries_var_name} ${private_link_libraries} PARENT_SCOPE)
+endfunction()
option(SWIFT_CHECK_ESSENTIAL_STDLIB
"Check core standard library layering by linking its essential subset"
@@ -312,8 +317,6 @@ add_swift_target_library(swiftCore
${swift_stdlib_compile_flags} -Xcc -DswiftCore_EXPORTS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
LINK_FLAGS
${swift_core_link_flags}
- PRIVATE_LINK_LIBRARIES
- ${swift_core_private_link_libraries}
INCORPORATE_OBJECT_LIBRARIES
swiftRuntime swiftStdlibStubs
FRAMEWORK_DEPENDS
diff --git a/swift/stdlib/public/runtime/CMakeLists.txt b/swift/stdlib/public/runtime/CMakeLists.txt
index 001d97d5174..0b51e56f631 100644
--- a/swift/stdlib/public/runtime/CMakeLists.txt
+++ b/swift/stdlib/public/runtime/CMakeLists.txt
@@ -88,9 +88,7 @@ set(swift_runtime_library_compile_flags ${swift_runtime_compile_flags})
list(APPEND swift_runtime_library_compile_flags -DswiftCore_EXPORTS)
list(APPEND swift_runtime_library_compile_flags -I${SWIFT_SOURCE_DIR}/include)
-set(sdk "${SWIFT_HOST_VARIANT_SDK}")
-if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
- list(REMOVE_ITEM swift_runtime_sources ImageInspectionELF.cpp)
+function(swift_runtime_static_libraries sdk)
set(static_binary_lnk_file_list)
string(TOLOWER "${sdk}" lowercase_sdk)
@@ -99,6 +97,7 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
ImageInspectionELF.cpp
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
LINK_FLAGS ${swift_runtime_linker_flags}
+ TARGET_SDKS ${sdk}
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
INSTALL_IN_COMPONENT stdlib)
@@ -149,7 +148,7 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
DESTINATION "lib/swift_static/${lowercase_sdk}"
COMPONENT stdlib)
add_custom_target(static_binary_magic ALL DEPENDS ${static_binary_lnk_file_list})
- foreach(arch IN LISTS SWIFT_SDK_LINUX_ARCHITECTURES)
+ foreach(arch IN LISTS SWIFT_SDK_${sdk}_ARCHITECTURES)
add_dependencies(static_binary_magic ${swift_image_inspection_${arch}_static})
endforeach()
add_dependencies(static_binary_magic ${swift_image_inspection_static_primary_arch})
@@ -159,9 +158,10 @@ if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX")
ImageInspectionELF.cpp
C_COMPILE_FLAGS ${swift_runtime_library_compile_flags}
LINK_FLAGS ${swift_runtime_linker_flags}
+ TARGET_SDKS ${sdk}
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
INSTALL_IN_COMPONENT never_install)
-endif()
+endfunction()
if(SWIFT_STDLIB_USE_NONATOMIC_RC)
set(_RUNTIME_NONATOMIC_FLAGS -DSWIFT_STDLIB_USE_NONATOMIC_RC)
@@ -174,7 +174,7 @@ add_swift_target_library(swiftRuntime OBJECT_LIBRARY
set(ELFISH_SDKS)
set(COFF_SDKS)
-foreach(sdk ${SWIFT_CONFIGURED_SDKS})
+foreach(sdk ${SWIFT_SDKS})
if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF")
list(APPEND ELFISH_SDKS ${sdk})
elseif("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "COFF")
@@ -201,7 +201,7 @@ add_swift_target_library(swiftImageRegistrationObjectCOFF
SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
INSTALL_IN_COMPONENT none)
-foreach(sdk ${SWIFT_CONFIGURED_SDKS})
+foreach(sdk ${SWIFT_SDKS})
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
set(arch_subdir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}")
set(arch_suffix "${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
diff --git a/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake b/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake
index 7a77e125f95..7eddfea2054 100644
--- a/swift/tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake

View File

@ -39,9 +39,9 @@ index 0e019d8d30..00e0b794e7 100644
if(${CFLAGS_ARCH} STREQUAL x86_64)
# this is the minimum architecture that supports 16 byte CAS, which is necessary to avoid a dependency to libatomic
@@ -441,11 +431,6 @@ function(_add_host_variant_link_flags)
# link against the custom C++ library
swift_android_cxx_libraries_for_arch(${LFLAGS_ARCH} cxx_link_libraries)
list(APPEND link_libraries ${cxx_link_libraries})
list(APPEND link_libraries
${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_I18N}
${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_UC})
-
- swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
- foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)
@ -318,9 +318,9 @@ index a2f682ece6..d2f6c27890 100644
if(${CFLAGS_ARCH} STREQUAL x86_64)
# this is the minimum architecture that supports 16 byte CAS, which is necessary to avoid a dependency to libatomic
@@ -363,11 +357,6 @@ function(_add_target_variant_link_flags)
# link against the custom C++ library
swift_android_cxx_libraries_for_arch(${LFLAGS_ARCH} cxx_link_libraries)
list(APPEND link_libraries ${cxx_link_libraries})
list(APPEND link_libraries
${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_I18N}
${SWIFT_ANDROID_${LFLAGS_ARCH}_ICU_UC})
-
- swift_android_lib_for_arch(${LFLAGS_ARCH} ${LFLAGS_ARCH}_LIB)
- foreach(path IN LISTS ${LFLAGS_ARCH}_LIB)

View File

@ -86,15 +86,6 @@ index b1d060328bc..218c9215260 100755
fi
build_targets=(all)
;;
@@ -1623,7 +1675,7 @@ for host in "${ALL_HOSTS[@]}"; do
-DCLANG_TOOL_ARCMT_TEST_BUILD=NO
-DCLANG_TOOL_C_ARCMT_TEST_BUILD=NO
-DCLANG_TOOL_C_INDEX_TEST_BUILD=NO
- -DCLANG_TOOL_DRIVER_BUILD=$(false_true "${BUILD_RUNTIME_WITH_HOST_COMPILER}")
+ -DCLANG_TOOL_DRIVER_BUILD=TRUE
-DCLANG_TOOL_DIAGTOOL_BUILD=NO
-DCLANG_TOOL_SCAN_BUILD_BUILD=NO
-DCLANG_TOOL_SCAN_VIEW_BUILD=NO
@@ -1652,6 +1688,10 @@ for host in "${ALL_HOSTS[@]}"; do
-DLLVM_NATIVE_BUILD=$(build_directory "${LOCAL_HOST}" llvm)
)