swift: fix build
This commit is contained in:
parent
8a60770f6b
commit
e2783b299c
@ -12,7 +12,6 @@
|
|||||||
, swig
|
, swig
|
||||||
, bash
|
, bash
|
||||||
, libxml2
|
, libxml2
|
||||||
, llvm
|
|
||||||
, clang
|
, clang
|
||||||
, python
|
, python
|
||||||
, ncurses
|
, ncurses
|
||||||
@ -28,8 +27,10 @@
|
|||||||
, git
|
, git
|
||||||
, libgit2
|
, libgit2
|
||||||
, fetchFromGitHub
|
, fetchFromGitHub
|
||||||
|
, fetchpatch
|
||||||
, paxctl
|
, paxctl
|
||||||
, findutils
|
, findutils
|
||||||
|
, makeWrapper
|
||||||
#, systemtap
|
#, systemtap
|
||||||
}:
|
}:
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ let
|
|||||||
name = "${repo}-${version}-src";
|
name = "${repo}-${version}-src";
|
||||||
};
|
};
|
||||||
|
|
||||||
sources = {
|
sources = {
|
||||||
# FYI: SourceKit probably would work but currently requires building everything twice
|
# FYI: SourceKit probably would work but currently requires building everything twice
|
||||||
# For more inforation, see: https://github.com/apple/swift/pull/3594#issuecomment-234169759
|
# For more inforation, see: https://github.com/apple/swift/pull/3594#issuecomment-234169759
|
||||||
clang = fetch {
|
clang = fetch {
|
||||||
@ -119,6 +120,8 @@ sources = {
|
|||||||
];
|
];
|
||||||
|
|
||||||
builder = ''
|
builder = ''
|
||||||
|
NIX_CFLAGS_COMPILE=$( echo ${clang.default_cxx_stdlib_compile} )
|
||||||
|
|
||||||
$SWIFT_SOURCE_ROOT/swift/utils/build-script \
|
$SWIFT_SOURCE_ROOT/swift/utils/build-script \
|
||||||
--preset=buildbot_linux \
|
--preset=buildbot_linux \
|
||||||
installable_package=$INSTALLABLE_PACKAGE \
|
installable_package=$INSTALLABLE_PACKAGE \
|
||||||
@ -126,6 +129,20 @@ sources = {
|
|||||||
install_destdir=$SWIFT_INSTALL_DIR \
|
install_destdir=$SWIFT_INSTALL_DIR \
|
||||||
extra_cmake_options="${stdenv.lib.concatStringsSep "," cmakeFlags}"'';
|
extra_cmake_options="${stdenv.lib.concatStringsSep "," cmakeFlags}"'';
|
||||||
|
|
||||||
|
# from llvm/4/llvm.nix
|
||||||
|
sigaltstackPatch = fetchpatch {
|
||||||
|
name = "sigaltstack.patch"; # for glibc-2.26
|
||||||
|
url = https://github.com/llvm-mirror/compiler-rt/commit/8a5e425a68d.diff;
|
||||||
|
sha256 = "0h4y5vl74qaa7dl54b1fcyqalvlpd8zban2d1jxfkxpzyi7m8ifi";
|
||||||
|
};
|
||||||
|
|
||||||
|
# https://bugs.swift.org/browse/SR-6409
|
||||||
|
sigunusedPatch = fetchpatch {
|
||||||
|
name = "sigunused.patch";
|
||||||
|
url = "https://github.com/apple/swift-llbuild/commit/303a89bc6da606c115560921a452686aa0655f5e.diff";
|
||||||
|
sha256 = "04sw7ym1grzggj1v3xrzr2ljxz8rf9rnn9n5fg1xjbwlrdagkc7m";
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "swift-${version_friendly}";
|
name = "swift-${version_friendly}";
|
||||||
@ -145,6 +162,7 @@ stdenv.mkDerivation rec {
|
|||||||
rsync
|
rsync
|
||||||
which
|
which
|
||||||
findutils
|
findutils
|
||||||
|
makeWrapper
|
||||||
] ++ stdenv.lib.optional stdenv.needsPax paxctl;
|
] ++ stdenv.lib.optional stdenv.needsPax paxctl;
|
||||||
|
|
||||||
# TODO: Revisit what's propagated and how
|
# TODO: Revisit what's propagated and how
|
||||||
@ -209,6 +227,10 @@ stdenv.mkDerivation rec {
|
|||||||
patch -p1 -d swift -i ${./patches/0002-build-presets-linux-allow-custom-install-prefix.patch}
|
patch -p1 -d swift -i ${./patches/0002-build-presets-linux-allow-custom-install-prefix.patch}
|
||||||
patch -p1 -d swift -i ${./patches/0003-build-presets-linux-disable-tests.patch}
|
patch -p1 -d swift -i ${./patches/0003-build-presets-linux-disable-tests.patch}
|
||||||
patch -p1 -d swift -i ${./patches/0004-build-presets-linux-plumb-extra-cmake-options.patch}
|
patch -p1 -d swift -i ${./patches/0004-build-presets-linux-plumb-extra-cmake-options.patch}
|
||||||
|
# https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27xlocale.h.27
|
||||||
|
patch -p1 -i ${./patches/remove_xlocale.patch}
|
||||||
|
# https://bugs.swift.org/browse/SR-4633
|
||||||
|
patch -p1 -d swift -i ${./patches/icu59.patch}
|
||||||
|
|
||||||
substituteInPlace clang/lib/Driver/ToolChains.cpp \
|
substituteInPlace clang/lib/Driver/ToolChains.cpp \
|
||||||
--replace ' addPathIfExists(D, SysRoot + "/usr/lib", Paths);' \
|
--replace ' addPathIfExists(D, SysRoot + "/usr/lib", Paths);' \
|
||||||
@ -232,6 +254,11 @@ stdenv.mkDerivation rec {
|
|||||||
--replace usr "$PREFIX"
|
--replace usr "$PREFIX"
|
||||||
substituteInPlace swiftpm/Utilities/bootstrap \
|
substituteInPlace swiftpm/Utilities/bootstrap \
|
||||||
--replace "usr" "$PREFIX"
|
--replace "usr" "$PREFIX"
|
||||||
|
'' + stdenv.lib.optionalString (stdenv ? glibc) ''
|
||||||
|
patch -p1 -d compiler-rt -i ${sigaltstackPatch}
|
||||||
|
patch -p1 -d compiler-rt -i ${./patches/sigaltstack.patch}
|
||||||
|
patch -p1 -d llbuild -i ${sigunusedPatch}
|
||||||
|
patch -p1 -i ${./patches/sigunused.patch}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
@ -251,6 +278,10 @@ stdenv.mkDerivation rec {
|
|||||||
# TODO: Use wrappers to get these on the PATH for swift tools, instead
|
# TODO: Use wrappers to get these on the PATH for swift tools, instead
|
||||||
ln -s ${clang}/bin/* $out/bin/
|
ln -s ${clang}/bin/* $out/bin/
|
||||||
ln -s ${targetPackages.stdenv.cc.bintools}/bin/ar $out/bin/ar
|
ln -s ${targetPackages.stdenv.cc.bintools}/bin/ar $out/bin/ar
|
||||||
|
|
||||||
|
wrapProgram $out/bin/swift \
|
||||||
|
--suffix C_INCLUDE_PATH : $out/lib/swift/clang/include \
|
||||||
|
--suffix CPLUS_INCLUDE_PATH : $out/lib/swift/clang/include
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Hack to avoid TMPDIR in RPATHs.
|
# Hack to avoid TMPDIR in RPATHs.
|
||||||
@ -263,7 +294,6 @@ stdenv.mkDerivation rec {
|
|||||||
license = licenses.asl20;
|
license = licenses.asl20;
|
||||||
# Swift doesn't support 32bit Linux, unknown on other platforms.
|
# Swift doesn't support 32bit Linux, unknown on other platforms.
|
||||||
platforms = [ "x86_64-linux" ];
|
platforms = [ "x86_64-linux" ];
|
||||||
broken = true;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
101
pkgs/development/compilers/swift/patches/icu59.patch
Normal file
101
pkgs/development/compilers/swift/patches/icu59.patch
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
--- a/stdlib/public/stubs/UnicodeNormalization.cpp
|
||||||
|
+++ b/stdlib/public/stubs/UnicodeNormalization.cpp
|
||||||
|
@@ -86,11 +86,8 @@ ASCIICollation() {
|
||||||
|
for (unsigned char c = 0; c < 128; ++c) {
|
||||||
|
UErrorCode ErrorCode = U_ZERO_ERROR;
|
||||||
|
intptr_t NumCollationElts = 0;
|
||||||
|
-#if defined(__CYGWIN__) || defined(_MSC_VER)
|
||||||
|
UChar Buffer[1];
|
||||||
|
-#else
|
||||||
|
- uint16_t Buffer[1];
|
||||||
|
-#endif
|
||||||
|
+
|
||||||
|
Buffer[0] = c;
|
||||||
|
|
||||||
|
UCollationElements *CollationIterator =
|
||||||
|
@@ -127,18 +124,9 @@ swift::_swift_stdlib_unicode_compare_utf16_utf16(const uint16_t *LeftString,
|
||||||
|
int32_t LeftLength,
|
||||||
|
const uint16_t *RightString,
|
||||||
|
int32_t RightLength) {
|
||||||
|
-#if defined(__CYGWIN__) || defined(_MSC_VER)
|
||||||
|
- // ICU UChar type is platform dependent. In Cygwin, it is defined
|
||||||
|
- // as wchar_t which size is 2. It seems that the underlying binary
|
||||||
|
- // representation is same with swift utf16 representation.
|
||||||
|
return ucol_strcoll(GetRootCollator(),
|
||||||
|
reinterpret_cast<const UChar *>(LeftString), LeftLength,
|
||||||
|
reinterpret_cast<const UChar *>(RightString), RightLength);
|
||||||
|
-#else
|
||||||
|
- return ucol_strcoll(GetRootCollator(),
|
||||||
|
- LeftString, LeftLength,
|
||||||
|
- RightString, RightLength);
|
||||||
|
-#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Compares the strings via the Unicode Collation Algorithm on the root locale.
|
||||||
|
@@ -156,12 +144,8 @@ swift::_swift_stdlib_unicode_compare_utf8_utf16(const unsigned char *LeftString,
|
||||||
|
UErrorCode ErrorCode = U_ZERO_ERROR;
|
||||||
|
|
||||||
|
uiter_setUTF8(&LeftIterator, reinterpret_cast<const char *>(LeftString), LeftLength);
|
||||||
|
-#if defined(__CYGWIN__) || defined(_MSC_VER)
|
||||||
|
uiter_setString(&RightIterator, reinterpret_cast<const UChar *>(RightString),
|
||||||
|
RightLength);
|
||||||
|
-#else
|
||||||
|
- uiter_setString(&RightIterator, RightString, RightLength);
|
||||||
|
-#endif
|
||||||
|
|
||||||
|
uint32_t Diff = ucol_strcollIter(GetRootCollator(),
|
||||||
|
&LeftIterator, &RightIterator, &ErrorCode);
|
||||||
|
@@ -199,14 +183,10 @@ swift::_swift_stdlib_unicode_compare_utf8_utf8(const unsigned char *LeftString,
|
||||||
|
void *swift::_swift_stdlib_unicodeCollationIterator_create(
|
||||||
|
const __swift_uint16_t *Str, __swift_uint32_t Length) {
|
||||||
|
UErrorCode ErrorCode = U_ZERO_ERROR;
|
||||||
|
-#if defined(__CYGWIN__) || defined(_MSC_VER)
|
||||||
|
UCollationElements *CollationIterator = ucol_openElements(
|
||||||
|
GetRootCollator(), reinterpret_cast<const UChar *>(Str), Length,
|
||||||
|
&ErrorCode);
|
||||||
|
-#else
|
||||||
|
- UCollationElements *CollationIterator = ucol_openElements(
|
||||||
|
- GetRootCollator(), Str, Length, &ErrorCode);
|
||||||
|
-#endif
|
||||||
|
+
|
||||||
|
if (U_FAILURE(ErrorCode)) {
|
||||||
|
swift::crash("_swift_stdlib_unicodeCollationIterator_create: ucol_openElements() failed.");
|
||||||
|
}
|
||||||
|
@@ -244,17 +224,12 @@ swift::_swift_stdlib_unicode_strToUpper(uint16_t *Destination,
|
||||||
|
const uint16_t *Source,
|
||||||
|
int32_t SourceLength) {
|
||||||
|
UErrorCode ErrorCode = U_ZERO_ERROR;
|
||||||
|
-#if defined(__CYGWIN__) || defined(_MSC_VER)
|
||||||
|
uint32_t OutputLength = u_strToUpper(reinterpret_cast<UChar *>(Destination),
|
||||||
|
DestinationCapacity,
|
||||||
|
reinterpret_cast<const UChar *>(Source),
|
||||||
|
SourceLength,
|
||||||
|
"", &ErrorCode);
|
||||||
|
-#else
|
||||||
|
- uint32_t OutputLength = u_strToUpper(Destination, DestinationCapacity,
|
||||||
|
- Source, SourceLength,
|
||||||
|
- "", &ErrorCode);
|
||||||
|
-#endif
|
||||||
|
+
|
||||||
|
if (U_FAILURE(ErrorCode) && ErrorCode != U_BUFFER_OVERFLOW_ERROR) {
|
||||||
|
swift::crash("u_strToUpper: Unexpected error uppercasing unicode string.");
|
||||||
|
}
|
||||||
|
@@ -271,17 +246,12 @@ swift::_swift_stdlib_unicode_strToLower(uint16_t *Destination,
|
||||||
|
const uint16_t *Source,
|
||||||
|
int32_t SourceLength) {
|
||||||
|
UErrorCode ErrorCode = U_ZERO_ERROR;
|
||||||
|
-#if defined(__CYGWIN__) || defined(_MSC_VER)
|
||||||
|
uint32_t OutputLength = u_strToLower(reinterpret_cast<UChar *>(Destination),
|
||||||
|
DestinationCapacity,
|
||||||
|
reinterpret_cast<const UChar *>(Source),
|
||||||
|
SourceLength,
|
||||||
|
"", &ErrorCode);
|
||||||
|
-#else
|
||||||
|
- uint32_t OutputLength = u_strToLower(Destination, DestinationCapacity,
|
||||||
|
- Source, SourceLength,
|
||||||
|
- "", &ErrorCode);
|
||||||
|
-#endif
|
||||||
|
+
|
||||||
|
if (U_FAILURE(ErrorCode) && ErrorCode != U_BUFFER_OVERFLOW_ERROR) {
|
||||||
|
swift::crash("u_strToLower: Unexpected error lowercasing unicode string.");
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
--- a/swift/stdlib/public/SDK/os/os_trace_blob.c
|
||||||
|
+++ b/swift/stdlib/public/SDK/os/os_trace_blob.c
|
||||||
|
@@ -14,7 +14,6 @@
|
||||||
|
#include <dispatch/dispatch.h>
|
||||||
|
#include <os/base.h>
|
||||||
|
#include <os/log.h>
|
||||||
|
-#include <xlocale.h>
|
||||||
|
#include "os_trace_blob.h"
|
||||||
|
|
||||||
|
OS_NOINLINE
|
||||||
|
|
||||||
|
--- a/swift/stdlib/public/stubs/Stubs.cpp
|
||||||
|
+++ b/swift/stdlib/public/stubs/Stubs.cpp
|
||||||
|
@@ -61,7 +61,6 @@
|
||||||
|
#define strtof_l swift_strtof_l
|
||||||
|
#define strtold_l swift_strtold_l
|
||||||
|
#else
|
||||||
|
-#include <xlocale.h>
|
||||||
|
#endif
|
||||||
|
#include <limits>
|
||||||
|
#include "llvm/ADT/StringExtras.h"
|
||||||
|
|
||||||
|
--- a/swift-corelibs-foundation/CoreFoundation/String.subproj/CFStringDefaultEncoding.h
|
||||||
|
+++ b/swift-corelibs-foundation/CoreFoundation/String.subproj/CFStringDefaultEncoding.h
|
||||||
|
@@ -20,7 +20,6 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
-#include <xlocale.h>
|
||||||
|
|
||||||
|
CF_EXTERN_C_BEGIN
|
||||||
|
|
||||||
|
|
||||||
|
--- a/swift-corelibs-foundation/CoreFoundation/String.subproj/CFStringEncodings.c
|
||||||
|
+++ b/swift-corelibs-foundation/CoreFoundation/String.subproj/CFStringEncodings.c
|
||||||
|
@@ -24,7 +24,6 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
-#include <xlocale.h>
|
||||||
|
#include <CoreFoundation/CFStringDefaultEncoding.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
--- a/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFInternal.h
|
||||||
|
+++ b/swift-corelibs-foundation/CoreFoundation/Base.subproj/CFInternal.h
|
||||||
|
@@ -95,7 +95,6 @@
|
||||||
|
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_EMBEDDED_MINI || DEPLOYMENT_TARGET_LINUX || DEPLOYMENT_TARGET_FREEBSD
|
||||||
|
#if TARGET_OS_CYGWIN
|
||||||
|
#else
|
||||||
|
-#include <xlocale.h>
|
||||||
|
#endif
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/time.h>
|
11
pkgs/development/compilers/swift/patches/sigaltstack.patch
Normal file
11
pkgs/development/compilers/swift/patches/sigaltstack.patch
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
--- a/lib/esan/esan_sideline_linux.cpp
|
||||||
|
+++ b/lib/esan/esan_sideline_linux.cpp
|
||||||
|
@@ -70,7 +70,7 @@ int SidelineThread::runSideline(void *Arg) {
|
||||||
|
|
||||||
|
// Set up a signal handler on an alternate stack for safety.
|
||||||
|
InternalScopedBuffer<char> StackMap(SigAltStackSize);
|
||||||
|
- struct sigaltstack SigAltStack;
|
||||||
|
+ stack_t SigAltStack;
|
||||||
|
SigAltStack.ss_sp = StackMap.data();
|
||||||
|
SigAltStack.ss_size = SigAltStackSize;
|
||||||
|
SigAltStack.ss_flags = 0;
|
24
pkgs/development/compilers/swift/patches/sigunused.patch
Normal file
24
pkgs/development/compilers/swift/patches/sigunused.patch
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
--- a/swift-corelibs-libdispatch/libpwq/src/posix/manager.c
|
||||||
|
+++ b/swift-corelibs-libdispatch/libpwq/src/posix/manager.c
|
||||||
|
@@ -273,9 +273,6 @@ static void sigmask_init(void)
|
||||||
|
sigdelset(&sigmask, SIGFPE);
|
||||||
|
sigdelset(&sigmask, SIGBUS);
|
||||||
|
sigdelset(&sigmask, SIGSEGV);
|
||||||
|
-#if SIGSYS != SIGUNUSED
|
||||||
|
- sigdelset(&sigmask, SIGSYS);
|
||||||
|
-#endif
|
||||||
|
sigdelset(&sigmask, SIGPIPE);
|
||||||
|
sigdelset(&sigmask, SIGPROF);
|
||||||
|
|
||||||
|
|
||||||
|
--- a/swiftpm/Sources/Utility/Process.swift
|
||||||
|
+++ b/swiftpm/Sources/Utility/Process.swift
|
||||||
|
@@ -140,7 +140,7 @@ public final class Process: ObjectIdentifierProtocol {
|
||||||
|
// modify, so we have to take care about the set we use.
|
||||||
|
var mostSignals = sigset_t()
|
||||||
|
sigemptyset(&mostSignals);
|
||||||
|
- for i in 1 ..< SIGUNUSED {
|
||||||
|
+ for i in 1 ..< SIGSYS {
|
||||||
|
if i == SIGKILL || i == SIGSTOP {
|
||||||
|
continue
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user