Merge remote-tracking branch 'origin/master' into staging

This commit is contained in:
Shea Levy 2018-02-18 16:56:39 -05:00
commit bbfc9ce376
No known key found for this signature in database
GPG Key ID: 5C0BD6957D86FE27
23 changed files with 624 additions and 42 deletions

View File

@ -68,6 +68,14 @@ rec {
musl64 = { config = "x86_64-unknown-linux-musl"; };
musl32 = { config = "i686-unknown-linux-musl"; };
riscv = bits: {
config = "riscv${bits}-unknown-linux-gnu";
platform = platforms.riscv-multiplatform bits;
};
riscv64 = riscv "64";
riscv32 = riscv "32";
#
# Darwin
#

View File

@ -541,6 +541,12 @@ rec {
};
};
riscv-multiplatform = bits: {
name = "riscv-multiplatform";
kernelArch = "riscv";
bfdEmulation = "elf${bits}lriscv";
};
selectBySystem = system: {
"i686-linux" = pc32;
"x86_64-linux" = pc64;

View File

@ -61,7 +61,7 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
patches = [ ./no-etc-install.patch ]
patches = [ ./no-etc-install.patch ./statfs-flags.patch ]
++ optional nixosTestRunner ./force-uid0-on-9p.patch
++ optional pulseSupport ./fix-hda-recording.patch;

View File

@ -0,0 +1,200 @@
commit d3282d2512774dc5027c98930a3852b2b6e8407a
Author: Shea Levy <shea@shealevy.com>
Date: Sun Feb 18 13:50:11 2018 -0500
linux-user: Support f_flags in statfs when available.
Signed-off-by: Shea Levy <shea@shealevy.com>
diff --git a/configure b/configure
index 913e14839d..52fe2bf941 100755
--- a/configure
+++ b/configure
@@ -5303,6 +5303,22 @@ if compile_prog "" "" ; then
have_utmpx=yes
fi
+##########################################
+# Check for newer fields of struct statfs on Linux
+
+if test "$linux_user" = "yes"; then
+ cat > $TMPC <<EOF
+#include <sys/vfs.h>
+
+int main(void) {
+ struct statfs fs;
+ fs.f_flags = 0;
+}
+EOF
+ if compile_object ; then
+ have_statfs_flags=yes
+ fi
+fi
##########################################
# checks for sanitizers
@@ -6518,6 +6534,10 @@ if test "$have_utmpx" = "yes" ; then
echo "HAVE_UTMPX=y" >> $config_host_mak
fi
+if test "$have_statfs_flags" = "yes" ; then
+ echo "HAVE_STATFS_FLAGS=y" >> $config_host_mak
+fi
+
if test "$ivshmem" = "yes" ; then
echo "CONFIG_IVSHMEM=y" >> $config_host_mak
fi
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 82b35a6bdf..77481eca2c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9534,6 +9534,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
__put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]);
__put_user(stfs.f_namelen, &target_stfs->f_namelen);
__put_user(stfs.f_frsize, &target_stfs->f_frsize);
+#ifdef HAVE_STATFS_FLAGS
+ __put_user(stfs.f_flags, &target_stfs->f_flags);
+#endif
memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare));
unlock_user_struct(target_stfs, arg2, 1);
}
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index a35c52a60a..9f90451caf 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -362,7 +362,14 @@ struct kernel_statfs {
int f_ffree;
kernel_fsid_t f_fsid;
int f_namelen;
+#ifdef HAVE_STATFS_FLAGS
+ int f_frsize;
+ int f_flags;
+ int f_spare[4];
+#else
int f_spare[6];
+#endif
+
};
struct target_dirent {
@@ -2223,7 +2230,13 @@ struct target_statfs {
/* Linux specials */
target_fsid_t f_fsid;
int32_t f_namelen;
+#ifdef HAVE_STATFS_FLAGS
+ int32_t f_frsize;
+ int32_t f_flags;
+ int32_t f_spare[4];
+#else
int32_t f_spare[6];
+#endif
};
#else
struct target_statfs {
@@ -2239,7 +2252,13 @@ struct target_statfs {
/* Linux specials */
target_fsid_t f_fsid;
abi_long f_namelen;
+#ifdef HAVE_STATFS_FLAGS
+ abi_long f_frsize;
+ abi_long f_flags;
+ abi_long f_spare[4];
+#else
abi_long f_spare[6];
+#endif
};
#endif
@@ -2255,7 +2274,13 @@ struct target_statfs64 {
uint64_t f_bavail;
target_fsid_t f_fsid;
uint32_t f_namelen;
+#ifdef HAVE_STATFS_FLAGS
+ uint32_t f_frsize;
+ uint32_t f_flags;
+ uint32_t f_spare[4];
+#else
uint32_t f_spare[6];
+#endif
};
#elif (defined(TARGET_PPC64) || defined(TARGET_X86_64) || \
defined(TARGET_SPARC64) || defined(TARGET_AARCH64)) && \
@@ -2271,7 +2296,12 @@ struct target_statfs {
target_fsid_t f_fsid;
abi_long f_namelen;
abi_long f_frsize;
+#ifdef HAVE_STATFS_FLAGS
+ abi_long f_flags;
+ abi_long f_spare[4];
+#else
abi_long f_spare[5];
+#endif
};
struct target_statfs64 {
@@ -2285,7 +2315,12 @@ struct target_statfs64 {
target_fsid_t f_fsid;
abi_long f_namelen;
abi_long f_frsize;
+#ifdef HAVE_STATFS_FLAGS
+ abi_long f_flags;
+ abi_long f_spare[4];
+#else
abi_long f_spare[5];
+#endif
};
#elif defined(TARGET_S390X)
struct target_statfs {
@@ -2299,7 +2334,13 @@ struct target_statfs {
kernel_fsid_t f_fsid;
int32_t f_namelen;
int32_t f_frsize;
+#ifdef HAVE_STATFS_FLAGS
+ int32_t f_flags;
+ int32_t f_spare[4];
+#else
int32_t f_spare[5];
+#endif
+
};
struct target_statfs64 {
@@ -2313,7 +2354,12 @@ struct target_statfs64 {
kernel_fsid_t f_fsid;
int32_t f_namelen;
int32_t f_frsize;
+#ifdef HAVE_STATFS_FLAGS
+ int32_t f_flags;
+ int32_t f_spare[4];
+#else
int32_t f_spare[5];
+#endif
};
#else
struct target_statfs {
@@ -2327,7 +2373,12 @@ struct target_statfs {
target_fsid_t f_fsid;
uint32_t f_namelen;
uint32_t f_frsize;
+#ifdef HAVE_STATFS_FLAGS
+ uint32_t f_flags;
+ uint32_t f_spare[4];
+#else
uint32_t f_spare[5];
+#endif
};
struct target_statfs64 {
@@ -2341,7 +2392,12 @@ struct target_statfs64 {
target_fsid_t f_fsid;
uint32_t f_namelen;
uint32_t f_frsize;
+#ifdef HAVE_STATFS_FLAGS
+ uint32_t f_flags;
+ uint32_t f_spare[4];
+#else
uint32_t f_spare[5];
+#endif
};
#endif

View File

@ -12,7 +12,6 @@
, swig
, bash
, libxml2
, llvm
, clang
, python
, ncurses
@ -28,13 +27,17 @@
, git
, libgit2
, fetchFromGitHub
, fetchpatch
, paxctl
, findutils
, makeWrapper
, gnumake
, file
#, systemtap
}:
let
v_major = "3.1.1";
v_major = "4.0.3";
version = "${v_major}-RELEASE";
version_friendly = "${v_major}";
@ -47,53 +50,53 @@ let
name = "${repo}-${version}-src";
};
sources = {
sources = {
# FYI: SourceKit probably would work but currently requires building everything twice
# For more inforation, see: https://github.com/apple/swift/pull/3594#issuecomment-234169759
clang = fetch {
repo = "swift-clang";
sha256 = "1gmdgr8jph87nya8cgdl7iwrggbji2sag996m27hkbszw4nxy8sd";
sha256 = "0zm624iwiprk3c3nzqf4p1fd9zqic4yi3jv51cw3249ax4x6vy10";
};
llvm = fetch {
repo = "swift-llvm";
sha256 = "0nwd7cp6mbj7f6a2rx8123n7ygs8406hsx7hp7ybagww6v75bwzi";
sha256 = "11vw6461c0cdvwm1wna1a5709fjj14hzp6br6jg94p4f6jp3yv4d";
};
compilerrt = fetch {
repo = "swift-compiler-rt";
sha256 = "1gjcr6g3ffs3nhf4a84iwg4flbd7rqcf9rvvclwyq96msa3mj950";
sha256 = "1hj4qaj4c9n2wzg2cvarbyl0n708zd1dlw4zkzq07fjxxqs36nfa";
};
cmark = fetch {
repo = "swift-cmark";
sha256 = "0qf2f3zd8lndkfbxbz6vkznzz8rvq5gigijh7pgmfx9fi4zcssqx";
sha256 = "1nmxp0fj749sgar682c5nsj7zxxigqwg973baxj2r656a7ybh325";
};
lldb = fetch {
repo = "swift-lldb";
sha256 = "17n4whpf3wxw9zaayiq21gk9q3547qxi4rvxld2hybh0k7a1bj5c";
sha256 = "0yk5qg85008vcn63vn2jpn5ls9pdhda222p2w1cfkrj27k5k8vqr";
};
llbuild = fetch {
repo = "swift-llbuild";
sha256 = "1l3hnb2s01jby91k1ipbc3bhszq14vyx5pzdhf2chld1yhpg420d";
sha256 = "0jffw6z1s6ck1i05brw59x6vsg7zrxbz5n2wz72fj29rh3nppc7a";
};
pm = fetch {
repo = "swift-package-manager";
sha256 = "1ayy5vk3mjk354pg9bf68wvnaj3jymx23w0qnlw1jxz256ff8fwi";
sha256 = "0xj070b8fii7ijfsnyq4fxgv6569vdrg0yippi85h2p1l7s9aagh";
};
xctest = fetch {
repo = "swift-corelibs-xctest";
sha256 = "0cj5y7wanllfldag08ci567x12aw793c79afckpbsiaxmwy4xhnm";
sha256 = "0l355wq8zfwrpv044xf4smjwbm0bmib360748n8cwls3vkr9l2yv";
};
foundation = fetch {
repo = "swift-corelibs-foundation";
sha256 = "1d1ldk7ckqn4mhmdhsx2zrmsd6jfxzgdywn2pki7limk979hcwjc";
sha256 = "0s7yc5gsbd96a4bs8c6q24dyfjm4xhcr2nzhl2ics8dmi60j15s4";
};
libdispatch = fetch {
repo = "swift-corelibs-libdispatch";
sha256 = "0ckjg41fjak06i532azhryckjq64fkxzsal4svf5v4s8n9mkq2sg";
sha256 = "0x8zzq3shhvmhq4sbhaaa0ddiv3nw347pz6ayym6jyzq7j9n15ia";
fetchSubmodules = true;
};
swift = fetch {
repo = "swift";
sha256 = "0879jlv37lmxc1apzi53xn033y72548i86r7fzwr0g52124q5gry";
sha256 = "0a1gq0k5701i418f0qi7kywv16q7vh4a4wp0f6fpyv4sjkq27msx";
};
};
@ -119,6 +122,9 @@ sources = {
];
builder = ''
# gcc-6.4.0/include/c++/6.4.0/cstdlib:75:15: fatal error: 'stdlib.h' file not found
NIX_CFLAGS_COMPILE="$( echo ${clang.default_cxx_stdlib_compile} ) $NIX_CFLAGS_COMPILE"
$SWIFT_SOURCE_ROOT/swift/utils/build-script \
--preset=buildbot_linux \
installable_package=$INSTALLABLE_PACKAGE \
@ -126,6 +132,20 @@ sources = {
install_destdir=$SWIFT_INSTALL_DIR \
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
stdenv.mkDerivation rec {
name = "swift-${version_friendly}";
@ -145,6 +165,8 @@ stdenv.mkDerivation rec {
rsync
which
findutils
makeWrapper
gnumake
] ++ stdenv.lib.optional stdenv.needsPax paxctl;
# TODO: Revisit what's propagated and how
@ -198,6 +220,14 @@ stdenv.mkDerivation rec {
# Just patch all the things for now, we can focus this later
patchShebangs $SWIFT_SOURCE_ROOT
# TODO eliminate use of env.
find -type f -print0 | xargs -0 sed -i \
-e 's|/usr/bin/env|${coreutils}/bin/env|g' \
-e 's|/usr/bin/make|${gnumake}/bin/make|g' \
-e 's|/bin/mkdir|${coreutils}/bin/mkdir|g' \
-e 's|/bin/cp|${coreutils}/bin/cp|g' \
-e 's|/usr/bin/file|${file}/bin/file|g'
substituteInPlace swift/stdlib/public/Platform/CMakeLists.txt \
--replace '/usr/include' "${stdenv.cc.libc.dev}/include"
substituteInPlace swift/utils/build-script-impl \
@ -209,6 +239,13 @@ stdenv.mkDerivation rec {
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/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}
# https://bugs.swift.org/browse/SR-5779
sed -i -e 's|"-latomic"|"-Wl,-rpath,${clang.cc.gcc.lib}/lib" "-L${clang.cc.gcc.lib}/lib" "-latomic"|' swift/cmake/modules/AddSwift.cmake
substituteInPlace clang/lib/Driver/ToolChains.cpp \
--replace ' addPathIfExists(D, SysRoot + "/usr/lib", Paths);' \
@ -217,21 +254,21 @@ stdenv.mkDerivation rec {
# Workaround hardcoded dep on "libcurses" (vs "libncurses"):
sed -i 's,curses,ncurses,' llbuild/*/*/CMakeLists.txt
substituteInPlace llbuild/tests/BuildSystem/Build/basic.llbuild \
--replace /usr/bin/env $(type -p env)
# This test fails on one of my machines, not sure why.
# Disabling for now.
rm llbuild/tests/Examples/buildsystem-capi.llbuild
substituteInPlace swift-corelibs-foundation/lib/script.py \
--replace /bin/cp $(type -p cp)
PREFIX=''${out/#\/}
substituteInPlace swift-corelibs-xctest/build_script.py \
--replace usr "$PREFIX"
substituteInPlace swiftpm/Utilities/bootstrap \
--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;
@ -251,6 +288,10 @@ stdenv.mkDerivation rec {
# TODO: Use wrappers to get these on the PATH for swift tools, instead
ln -s ${clang}/bin/* $out/bin/
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.
@ -263,7 +304,6 @@ stdenv.mkDerivation rec {
license = licenses.asl20;
# Swift doesn't support 32bit Linux, unknown on other platforms.
platforms = [ "x86_64-linux" ];
broken = true;
};
}

View File

@ -11,13 +11,13 @@ diff --git a/utils/build-presets.ini b/utils/build-presets.ini
index e6b0af3581..1095cbaab7 100644
--- a/utils/build-presets.ini
+++ b/utils/build-presets.ini
@@ -692,7 +692,7 @@ install-lldb
@@ -708,7 +708,7 @@ install-lldb
install-llbuild
install-swiftpm
install-xctest
-install-prefix=/usr
+install-prefix=%(install_prefix)s
swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license
swift-install-components=autolink-driver;compiler;clang-builtin-headers;stdlib;swift-remote-mirror;sdk-overlay;license;sourcekit-inproc
build-swift-static-stdlib
build-swift-static-sdk-overlay
--

View File

@ -0,0 +1,113 @@
--- 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.");
}
@@ -300,9 +300,9 @@
swift::__swift_stdlib_UBreakIterator *swift::__swift_stdlib_ubrk_open(
swift::__swift_stdlib_UBreakIteratorType type, const char *locale,
- const UChar *text, int32_t textLength, __swift_stdlib_UErrorCode *status) {
+ const __swift_stdlib_UChar * text, __swift_int32_t textLength, __swift_stdlib_UErrorCode *status) {
return ptr_cast<swift::__swift_stdlib_UBreakIterator>(
- ubrk_open(static_cast<UBreakIteratorType>(type), locale, text, textLength,
+ ubrk_open(static_cast<UBreakIteratorType>(type), locale, reinterpret_cast<const UChar *>(text), textLength,
ptr_cast<UErrorCode>(status)));
}

View File

@ -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>

View 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;

View File

@ -0,0 +1,11 @@
--- a/swiftpm/Sources/Basic/Process.swift
+++ b/swiftpm/Sources/Basic/Process.swift
@@ -258,7 +258,7 @@ public func launch() throws {
// 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
}

View File

@ -27,7 +27,9 @@ stdenv.mkDerivation rec {
patches = [ (fetchpatch {
url = "https://raw.githubusercontent.com/gentoo/musl/85b6a600996bdd71162b357e9ba93d8559342432/dev-libs/boehm-gc/files/boehm-gc-7.6.0-sys_select.patch";
sha256 = "1gydwlklvci30f5dpp5ccw2p2qpph5y41r55wx9idamjlq66fbb3";
}) ];
}) ] ++
# https://github.com/ivmai/bdwgc/pull/208
lib.optional hostPlatform.isRiscV ./riscv.patch;
configureFlags =
[ "--enable-cplusplus" ]

View File

@ -0,0 +1,53 @@
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index a8e55dd2..439cc88d 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -650,6 +650,15 @@
# endif
# define mach_type_known
# endif
+# if defined(__riscv) && defined(LINUX)
+# if __riscv_xlen == 32
+# define RISCV32
+# define mach_type_known
+# elif __riscv_xlen == 64
+# define RISCV64
+# define mach_type_known
+# endif
+# endif
# if defined(SN_TARGET_PSP2)
# define mach_type_known
@@ -2970,6 +2979,32 @@
# endif
# endif
+# ifdef RISCV32
+# define CPP_WORDSZ 32
+# define MACH_TYPE "RISC-V 32"
+# define ALIGNMENT 4
+# ifdef LINUX
+# define OS_TYPE "LINUX"
+ extern int __data_start[];
+# define DATASTART ((ptr_t)__data_start)
+# define LINUX_STACKBOTTOM
+# define DYNAMIC_LOADING
+# endif
+# endif
+
+# ifdef RISCV64
+# define CPP_WORDSZ 64
+# define MACH_TYPE "RISC-V 64"
+# define ALIGNMENT 8
+# ifdef LINUX
+# define OS_TYPE "LINUX"
+ extern int __data_start[];
+# define DATASTART ((ptr_t)__data_start)
+# define LINUX_STACKBOTTOM
+# define DYNAMIC_LOADING
+# endif
+# endif
+
#if defined(__GLIBC__) && !defined(DONT_USE_LIBC_PRIVATES)
/* Use glibc's stack-end marker. */
# define USE_LIBC_PRIVATES

View File

@ -192,6 +192,8 @@ stdenv.mkDerivation ({
maintainers = [ lib.maintainers.eelco ];
platforms = lib.platforms.linux;
} // meta;
passthru = { inherit version; };
}
// lib.optionalAttrs (cross != null) {

View File

@ -1,4 +1,4 @@
{ stdenv, fetchurl, autoconf, automake, libtool }:
{ stdenv, fetchurl, autoconf, automake, libtool, hostPlatform }:
stdenv.mkDerivation rec {
name = "libatomic_ops-${version}";
@ -12,6 +12,9 @@ stdenv.mkDerivation rec {
sha256 ="1rif2hjscq5mh639nsnjhb90c01gnmy1sbmj6x6hsn1xmpnj95r1";
};
# https://github.com/ivmai/libatomic_ops/pull/32
patches = if hostPlatform.isRiscV then [ ./riscv.patch ] else null;
nativeBuildInputs = stdenv.lib.optionals stdenv.isCygwin [ autoconf automake libtool ];
preConfigure = stdenv.lib.optionalString stdenv.isCygwin ''

View File

@ -0,0 +1,40 @@
diff -Naur libatomic_ops-7.6.2-orig/src/atomic_ops/sysdeps/gcc/riscv.h libatomic_ops-7.6.2/src/atomic_ops/sysdeps/gcc/riscv.h
--- libatomic_ops-7.6.2-orig/src/atomic_ops/sysdeps/gcc/riscv.h 1969-12-31 19:00:00.000000000 -0500
+++ libatomic_ops-7.6.2/src/atomic_ops/sysdeps/gcc/riscv.h 2018-02-18 00:48:53.581721375 -0500
@@ -0,0 +1 @@
+#include "generic.h"
diff -Naur libatomic_ops-7.6.2-orig/src/atomic_ops.h libatomic_ops-7.6.2/src/atomic_ops.h
--- libatomic_ops-7.6.2-orig/src/atomic_ops.h 2017-12-24 03:31:12.000000000 -0500
+++ libatomic_ops-7.6.2/src/atomic_ops.h 2018-02-18 00:48:53.580721359 -0500
@@ -352,6 +352,9 @@
# if defined(__tile__)
# include "atomic_ops/sysdeps/gcc/tile.h"
# endif
+# if defined(__riscv)
+# include "atomic_ops/sysdeps/gcc/riscv.h"
+# endif
#endif /* __GNUC__ && !AO_USE_PTHREAD_DEFS */
#if (defined(__IBMC__) || defined(__IBMCPP__)) && !defined(__GNUC__) \
diff -Naur libatomic_ops-7.6.2-orig/src/Makefile.am libatomic_ops-7.6.2/src/Makefile.am
--- libatomic_ops-7.6.2-orig/src/Makefile.am 2017-12-24 03:31:12.000000000 -0500
+++ libatomic_ops-7.6.2/src/Makefile.am 2018-02-18 00:48:53.579721342 -0500
@@ -92,6 +92,7 @@
atomic_ops/sysdeps/gcc/mips.h \
atomic_ops/sysdeps/gcc/nios2.h \
atomic_ops/sysdeps/gcc/powerpc.h \
+ atomic_ops/sysdeps/gcc/riscv.h \
atomic_ops/sysdeps/gcc/s390.h \
atomic_ops/sysdeps/gcc/sh.h \
atomic_ops/sysdeps/gcc/sparc.h \
diff -Naur libatomic_ops-7.6.2-orig/src/Makefile.in libatomic_ops-7.6.2/src/Makefile.in
--- libatomic_ops-7.6.2-orig/src/Makefile.in 2017-12-24 03:32:23.000000000 -0500
+++ libatomic_ops-7.6.2/src/Makefile.in 2018-02-18 00:49:14.005062121 -0500
@@ -446,6 +446,7 @@
atomic_ops/sysdeps/gcc/mips.h \
atomic_ops/sysdeps/gcc/nios2.h \
atomic_ops/sysdeps/gcc/powerpc.h \
+ atomic_ops/sysdeps/gcc/riscv.h \
atomic_ops/sysdeps/gcc/s390.h \
atomic_ops/sysdeps/gcc/sh.h \
atomic_ops/sysdeps/gcc/sparc.h \

View File

@ -24,8 +24,7 @@ in stdenv.mkDerivation rec {
outputs = [ "bin" "dev" "out" "doc" "man" ];
configureFlags = [
"--enable-jit"
configureFlags = optional (!hostPlatform.isRiscV) "--enable-jit" ++ [
"--enable-unicode-properties"
"--disable-cpp"
]

View File

@ -4,6 +4,8 @@ assert guileSupport -> ( pkgconfig != null && guile != null );
let
version = "4.2.1";
needGlibcPatch = (stdenv.cc.libc.version or "") == "2.27";
in
stdenv.mkDerivation {
name = "gnumake-${version}";
@ -20,7 +22,7 @@ stdenv.mkDerivation {
# included Makefiles, don't look in /usr/include and friends.
./impure-dirs.patch
./pselect.patch
];
] ++ stdenv.lib.optional needGlibcPatch ./glibc-2.27.patch;
nativeBuildInputs = stdenv.lib.optionals guileSupport [ pkgconfig ];
buildInputs = stdenv.lib.optionals guileSupport [ guile ];

View File

@ -0,0 +1,24 @@
From 48c8a116a914a325a0497721f5d8b58d5bba34d4 Mon Sep 17 00:00:00 2001
From: Paul Smith <psmith@gnu.org>
Date: Sun, 19 Nov 2017 15:09:16 -0500
Subject: * configure.ac: Support GLIBC glob interface version 2
---
configure.ac | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff -Naur a/configure b/configure
--- configure 2016-06-10 19:03:21.000000000 -0400
+++ configure 2018-02-18 04:40:32.971371555 -0500
@@ -11481,10 +11481,9 @@
#include <glob.h>
#include <fnmatch.h>
-#define GLOB_INTERFACE_VERSION 1
#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
# include <gnu-versions.h>
-# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
+# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2
gnu glob
# endif
#endif

View File

@ -1,8 +1,9 @@
{ busybox }:
{ busybox, hostPlatform }:
# Minimal shell for use as basic /bin/sh in sandbox builds
busybox.override {
useMusl = true;
# musl roadmap has RISC-V support projected for 1.1.20
useMusl = !hostPlatform.isRiscV;
enableStatic = true;
enableMinimal = true;
extraConfig = ''

View File

@ -17,4 +17,5 @@ in with (import ../../../lib).systems.examples; {
i686-musl = make musl32;
armv6l-musl = make muslpi;
aarch64-musl = make aarch64-multiplatform-musl;
riscv64 = make riscv64;
}

View File

@ -5,6 +5,7 @@
let
pkgs = import ../../.. { inherit localSystem crossSystem; };
libc = pkgs.stdenv.cc.libc;
isl = with pkgs; if targetPlatform.isRiscV then isl_0_17 else isl_0_14;
in with pkgs; rec {
@ -19,7 +20,7 @@ in with pkgs; rec {
tarMinimal = gnutar.override { acl = null; };
busyboxMinimal = busybox.override {
useMusl = true;
useMusl = !targetPlatform.isRiscV;
enableStatic = true;
enableMinimal = true;
extraConfig = ''
@ -143,7 +144,7 @@ in with pkgs; rec {
# These needed for cross but not native tools because the stdenv
# GCC has certain things built in statically. See
# pkgs/stdenv/linux/default.nix for the details.
cp -d ${isl_0_14.out}/lib/libisl*.so* $out/lib
cp -d ${isl.out}/lib/libisl*.so* $out/lib
'' + ''
cp -d ${bzip2.out}/lib/libbz2.so* $out/lib

View File

@ -30,7 +30,7 @@ let
buildInputs = [ curl openssl sqlite xz bzip2 ]
++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
++ lib.optionals fromGit [ brotli ] # Since 1.12
++ lib.optional stdenv.isLinux libseccomp
++ lib.optional (stdenv.isLinux && !hostPlatform.isRiscV) libseccomp
++ lib.optional ((stdenv.isLinux || stdenv.isDarwin) && is20)
(aws-sdk-cpp.override {
apis = ["s3"];
@ -55,7 +55,9 @@ let
]
++ lib.optional (
hostPlatform != buildPlatform && hostPlatform ? nix && hostPlatform.nix ? system
) ''--with-system=${hostPlatform.nix.system}'';
) ''--with-system=${hostPlatform.nix.system}''
# RISC-V support in progress https://github.com/seccomp/libseccomp/pull/50
++ lib.optional hostPlatform.isRiscV "--disable-seccomp-sandboxing";
makeFlags = "profiledir=$(out)/etc/profile.d";
@ -124,12 +126,12 @@ in rec {
nixUnstable = (lib.lowPrio (common rec {
name = "nix-2.0${suffix}";
suffix = "pre5950_3a5a241b";
suffix = "pre5951_690ac7c9";
src = fetchFromGitHub {
owner = "NixOS";
repo = "nix";
rev = "3a5a241b3209f14f8801b902ba20b5cb0666c9df";
sha256 = "0cwjyhgyfzi2dz561nj897zhkbyx6lzi49avcyia2pr4498jcl6k";
rev = "690ac7c90b5bf3c599e210c53365c7d229c8b0ff";
sha256 = "1yn2p38kp1i67makbawr1rhdiwihgnvk2zwrz0gvf6q65mj2k89c";
};
fromGit = true;
})) // { perl-bindings = perl-bindings { nix = nixUnstable; }; };

View File

@ -5790,8 +5790,12 @@ with pkgs;
gambit = callPackage ../development/compilers/gambit { };
gerbil = callPackage ../development/compilers/gerbil { };
gccFun = callPackage ../development/compilers/gcc/6;
gcc = gcc6;
# !!! When updating to gcc7 everywhere we can get rid of the
# isRiscV overrides here and in gccCrossStageStatic
gccFun6 = callPackage ../development/compilers/gcc/6;
gccFun7 = callPackage ../development/compilers/gcc/7;
gccFun = if targetPlatform.isRiscV then gccFun7 else gccFun6;
gcc = if targetPlatform.isRiscV then gcc7 else gcc6;
gcc-unwrapped = gcc.cc;
gccStdenv = if stdenv.cc.isGNU then stdenv else stdenv.override {
@ -5871,6 +5875,7 @@ with pkgs;
bintools = binutils-unwrapped;
libc = libcCross1;
};
isl = if targetPlatform.isRiscV then isl_0_17 else isl_0_14;
in wrapCCWith {
name = "gcc-cross-wrapper";
cc = gccFun {
@ -5878,7 +5883,7 @@ with pkgs;
inherit noSysDirs;
# PGO seems to speed up compilation by gcc by ~10%, see #445 discussion
profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64));
isl = if !stdenv.isDarwin then isl_0_14 else null;
isl = if !stdenv.isDarwin then isl else null;
# just for stage static
crossStageStatic = true;
@ -8764,7 +8769,11 @@ with pkgs;
};
# Being redundant to avoid cycles on boot. TODO: find a better way
glibcCross = callPackage ../development/libraries/glibc {
glibcCross = let
expr = if hostPlatform.isRiscV
then ../development/libraries/glibc/2.27.nix
else ../development/libraries/glibc;
in callPackage expr {
installLocales = config.glibc.locales or false;
stdenv = crossLibcStdenv;
};
@ -12943,7 +12952,7 @@ with pkgs;
inherit (callPackages ../os-specific/linux/kernel-headers { })
linuxHeaders_4_4 linuxHeaders_4_15;
linuxHeaders = if hostPlatform.isMusl then linuxHeaders_4_15 else linuxHeaders_4_4;
linuxHeaders = if hostPlatform.isMusl || hostPlatform.isRiscV then linuxHeaders_4_15 else linuxHeaders_4_4;
kernelPatches = callPackage ../os-specific/linux/kernel/patches.nix { };