From e2783b299c906756b3954948b08aa8a08b90878f Mon Sep 17 00:00:00 2001 From: taku0 Date: Sun, 4 Feb 2018 14:38:20 +0900 Subject: [PATCH 01/16] swift: fix build --- pkgs/development/compilers/swift/default.nix | 36 ++++++- .../compilers/swift/patches/icu59.patch | 101 ++++++++++++++++++ .../swift/patches/remove_xlocale.patch | 54 ++++++++++ .../compilers/swift/patches/sigaltstack.patch | 11 ++ .../compilers/swift/patches/sigunused.patch | 24 +++++ 5 files changed, 223 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/compilers/swift/patches/icu59.patch create mode 100644 pkgs/development/compilers/swift/patches/remove_xlocale.patch create mode 100644 pkgs/development/compilers/swift/patches/sigaltstack.patch create mode 100644 pkgs/development/compilers/swift/patches/sigunused.patch diff --git a/pkgs/development/compilers/swift/default.nix b/pkgs/development/compilers/swift/default.nix index 937977b0a97d..62edb9044e58 100644 --- a/pkgs/development/compilers/swift/default.nix +++ b/pkgs/development/compilers/swift/default.nix @@ -12,7 +12,6 @@ , swig , bash , libxml2 -, llvm , clang , python , ncurses @@ -28,8 +27,10 @@ , git , libgit2 , fetchFromGitHub +, fetchpatch , paxctl , findutils +, makeWrapper #, systemtap }: @@ -47,7 +48,7 @@ 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 { @@ -119,6 +120,8 @@ sources = { ]; builder = '' + NIX_CFLAGS_COMPILE=$( echo ${clang.default_cxx_stdlib_compile} ) + $SWIFT_SOURCE_ROOT/swift/utils/build-script \ --preset=buildbot_linux \ installable_package=$INSTALLABLE_PACKAGE \ @@ -126,6 +129,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 +162,7 @@ stdenv.mkDerivation rec { rsync which findutils + makeWrapper ] ++ stdenv.lib.optional stdenv.needsPax paxctl; # 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/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} substituteInPlace clang/lib/Driver/ToolChains.cpp \ --replace ' addPathIfExists(D, SysRoot + "/usr/lib", Paths);' \ @@ -232,6 +254,11 @@ stdenv.mkDerivation rec { --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 +278,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 +294,6 @@ stdenv.mkDerivation rec { license = licenses.asl20; # Swift doesn't support 32bit Linux, unknown on other platforms. platforms = [ "x86_64-linux" ]; - broken = true; }; } diff --git a/pkgs/development/compilers/swift/patches/icu59.patch b/pkgs/development/compilers/swift/patches/icu59.patch new file mode 100644 index 000000000000..83d7e62636a4 --- /dev/null +++ b/pkgs/development/compilers/swift/patches/icu59.patch @@ -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(LeftString), LeftLength, + reinterpret_cast(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(LeftString), LeftLength); +-#if defined(__CYGWIN__) || defined(_MSC_VER) + uiter_setString(&RightIterator, reinterpret_cast(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(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(Destination), + DestinationCapacity, + reinterpret_cast(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(Destination), + DestinationCapacity, + reinterpret_cast(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."); + } diff --git a/pkgs/development/compilers/swift/patches/remove_xlocale.patch b/pkgs/development/compilers/swift/patches/remove_xlocale.patch new file mode 100644 index 000000000000..8ef7e3916962 --- /dev/null +++ b/pkgs/development/compilers/swift/patches/remove_xlocale.patch @@ -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 + #include + #include +-#include + #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 + #endif + #include + #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 + #include + #include +-#include + + 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 + #include + #include +-#include + #include + #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 + #endif + #include + #include diff --git a/pkgs/development/compilers/swift/patches/sigaltstack.patch b/pkgs/development/compilers/swift/patches/sigaltstack.patch new file mode 100644 index 000000000000..c529fa3777b3 --- /dev/null +++ b/pkgs/development/compilers/swift/patches/sigaltstack.patch @@ -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 StackMap(SigAltStackSize); +- struct sigaltstack SigAltStack; ++ stack_t SigAltStack; + SigAltStack.ss_sp = StackMap.data(); + SigAltStack.ss_size = SigAltStackSize; + SigAltStack.ss_flags = 0; diff --git a/pkgs/development/compilers/swift/patches/sigunused.patch b/pkgs/development/compilers/swift/patches/sigunused.patch new file mode 100644 index 000000000000..42e6e297e0a8 --- /dev/null +++ b/pkgs/development/compilers/swift/patches/sigunused.patch @@ -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 + } From c275c3dc303938fa205df09cb3f9c1152bd5f03e Mon Sep 17 00:00:00 2001 From: taku0 Date: Mon, 12 Feb 2018 15:31:47 +0900 Subject: [PATCH 02/16] swift: 3.1.1 -> 4.0.3 --- pkgs/development/compilers/swift/default.nix | 46 +++++++++++-------- ...ts-linux-allow-custom-install-prefix.patch | 4 +- .../compilers/swift/patches/icu59.patch | 12 +++++ .../compilers/swift/patches/sigunused.patch | 21 ++------- 4 files changed, 46 insertions(+), 37 deletions(-) diff --git a/pkgs/development/compilers/swift/default.nix b/pkgs/development/compilers/swift/default.nix index 62edb9044e58..360f96e12427 100644 --- a/pkgs/development/compilers/swift/default.nix +++ b/pkgs/development/compilers/swift/default.nix @@ -31,11 +31,13 @@ , 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}"; @@ -53,48 +55,48 @@ let # 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"; }; }; @@ -120,7 +122,8 @@ let ]; builder = '' - NIX_CFLAGS_COMPILE=$( echo ${clang.default_cxx_stdlib_compile} ) + # 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 \ @@ -163,6 +166,7 @@ stdenv.mkDerivation rec { which findutils makeWrapper + gnumake ] ++ stdenv.lib.optional stdenv.needsPax paxctl; # TODO: Revisit what's propagated and how @@ -216,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 \ @@ -232,6 +244,9 @@ stdenv.mkDerivation rec { # 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);' \ ' addPathIfExists(D, SysRoot + "/usr/lib", Paths); addPathIfExists(D, "${glibc}/lib", Paths);' @@ -239,16 +254,11 @@ 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" diff --git a/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch b/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch index 0e18e8812a84..66723f1cdf39 100644 --- a/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch +++ b/pkgs/development/compilers/swift/patches/0002-build-presets-linux-allow-custom-install-prefix.patch @@ -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 -- diff --git a/pkgs/development/compilers/swift/patches/icu59.patch b/pkgs/development/compilers/swift/patches/icu59.patch index 83d7e62636a4..26337814cafa 100644 --- a/pkgs/development/compilers/swift/patches/icu59.patch +++ b/pkgs/development/compilers/swift/patches/icu59.patch @@ -99,3 +99,15 @@ 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( +- ubrk_open(static_cast(type), locale, text, textLength, ++ ubrk_open(static_cast(type), locale, reinterpret_cast(text), textLength, + ptr_cast(status))); + } + diff --git a/pkgs/development/compilers/swift/patches/sigunused.patch b/pkgs/development/compilers/swift/patches/sigunused.patch index 42e6e297e0a8..2701d1a3ae25 100644 --- a/pkgs/development/compilers/swift/patches/sigunused.patch +++ b/pkgs/development/compilers/swift/patches/sigunused.patch @@ -1,22 +1,9 @@ ---- 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 { +--- 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); + sigemptyset(&mostSignals) - for i in 1 ..< SIGUNUSED { + for i in 1 ..< SIGSYS { if i == SIGKILL || i == SIGSTOP { From e288febee0809db7c594ceb42e655dd5d43a6369 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 00:09:25 -0500 Subject: [PATCH 03/16] Add riscv{32,64} crossSystems. --- lib/systems/examples.nix | 8 ++++++++ lib/systems/platforms.nix | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index f5562e28a09d..bd68ee9460e7 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -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 # diff --git a/lib/systems/platforms.nix b/lib/systems/platforms.nix index 58a7afa7679d..3106c05dd5d2 100644 --- a/lib/systems/platforms.nix +++ b/lib/systems/platforms.nix @@ -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; From 3bec7812887923fc3c0c7ab804196c1e086f2acd Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 00:11:28 -0500 Subject: [PATCH 04/16] Use gcc 7 for RISC-V support. --- pkgs/top-level/all-packages.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1b4fbf8c1e6f..0c262e43a693 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5784,8 +5784,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 { @@ -5865,6 +5869,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 { @@ -5872,7 +5877,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; From 1d493f6171e9a84a3ff7c77745230a7c3910217e Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 00:12:40 -0500 Subject: [PATCH 05/16] Use Linux 4.15 kernel headers for RISC-V support. --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0c262e43a693..cf8d8d6d5e99 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12942,7 +12942,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 { }; From 4f8a9ff1ac4e9b671a732f8a6e4044551f51cc93 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 00:13:17 -0500 Subject: [PATCH 06/16] Use glibc-2.27 for RISC-V support. --- pkgs/top-level/all-packages.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index cf8d8d6d5e99..57bc0ec071d2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -8763,7 +8763,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; }; From 158cf6449c58b559a02dccc40096d4171c8a6589 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 00:13:43 -0500 Subject: [PATCH 07/16] pcre: Disable JIT on RISC-V. --- pkgs/development/libraries/pcre/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix index b34c9ff31f2c..2ea5e923bad0 100644 --- a/pkgs/development/libraries/pcre/default.nix +++ b/pkgs/development/libraries/pcre/default.nix @@ -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" ] From a61fdebc2532d1547640346118c72ecad0191fc7 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 00:52:55 -0500 Subject: [PATCH 08/16] libatomic_ops: Add patch for RISC-V support. --- .../libraries/libatomic_ops/default.nix | 5 ++- .../libraries/libatomic_ops/riscv.patch | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/libraries/libatomic_ops/riscv.patch diff --git a/pkgs/development/libraries/libatomic_ops/default.nix b/pkgs/development/libraries/libatomic_ops/default.nix index 3aae754be405..714e9361440c 100644 --- a/pkgs/development/libraries/libatomic_ops/default.nix +++ b/pkgs/development/libraries/libatomic_ops/default.nix @@ -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 '' diff --git a/pkgs/development/libraries/libatomic_ops/riscv.patch b/pkgs/development/libraries/libatomic_ops/riscv.patch new file mode 100644 index 000000000000..27f2408c34c6 --- /dev/null +++ b/pkgs/development/libraries/libatomic_ops/riscv.patch @@ -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 \ From f3f79bd6c6027277b123921edd4064a396358cd3 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 01:40:29 -0500 Subject: [PATCH 09/16] boehmgc: Add patch for RISC-V support. --- .../libraries/boehm-gc/default.nix | 4 +- .../libraries/boehm-gc/riscv.patch | 53 +++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/libraries/boehm-gc/riscv.patch diff --git a/pkgs/development/libraries/boehm-gc/default.nix b/pkgs/development/libraries/boehm-gc/default.nix index c1bcb46bae6e..d4e91deb7449 100644 --- a/pkgs/development/libraries/boehm-gc/default.nix +++ b/pkgs/development/libraries/boehm-gc/default.nix @@ -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" ] diff --git a/pkgs/development/libraries/boehm-gc/riscv.patch b/pkgs/development/libraries/boehm-gc/riscv.patch new file mode 100644 index 000000000000..249137d0a0dc --- /dev/null +++ b/pkgs/development/libraries/boehm-gc/riscv.patch @@ -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 From a933aa9a8df44fa141eb24a802e38d7be3473918 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 01:48:07 -0500 Subject: [PATCH 10/16] busybox-sandbox-shell: Fix build on RISC-V --- pkgs/os-specific/linux/busybox/sandbox-shell.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/busybox/sandbox-shell.nix b/pkgs/os-specific/linux/busybox/sandbox-shell.nix index 1755bd4f3f74..b94fae7f787b 100644 --- a/pkgs/os-specific/linux/busybox/sandbox-shell.nix +++ b/pkgs/os-specific/linux/busybox/sandbox-shell.nix @@ -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 = '' From 5a0eec1de1d25a3a63c65010e2351aee60bac958 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 02:47:08 -0500 Subject: [PATCH 11/16] nixUnstable: 2.0pre5950_3a5a241b -> 2.0pre5951_690ac7c9. --- pkgs/tools/package-management/nix/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix index 21b333f32316..cb1f5192822d 100644 --- a/pkgs/tools/package-management/nix/default.nix +++ b/pkgs/tools/package-management/nix/default.nix @@ -124,12 +124,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; }; }; From 765194d7abb34f82fad697a769c570dd71f87530 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 02:48:03 -0500 Subject: [PATCH 12/16] nixUnstable: Disable seccomp support on RISC-V. --- pkgs/tools/package-management/nix/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix index cb1f5192822d..f6e6988270ad 100644 --- a/pkgs/tools/package-management/nix/default.nix +++ b/pkgs/tools/package-management/nix/default.nix @@ -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"; From a551e6debce4cfc0bac3a051f5256a523cd32459 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 04:56:40 -0500 Subject: [PATCH 13/16] gnumake: Fix build against glibc 2.27. --- .../libraries/glibc/common-2.27.nix | 2 ++ .../build-managers/gnumake/4.2/default.nix | 4 +++- .../gnumake/4.2/glibc-2.27.patch | 24 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27.patch diff --git a/pkgs/development/libraries/glibc/common-2.27.nix b/pkgs/development/libraries/glibc/common-2.27.nix index d493feb35fa8..6c443ebbb932 100644 --- a/pkgs/development/libraries/glibc/common-2.27.nix +++ b/pkgs/development/libraries/glibc/common-2.27.nix @@ -192,6 +192,8 @@ stdenv.mkDerivation ({ maintainers = [ lib.maintainers.eelco ]; platforms = lib.platforms.linux; } // meta; + + passthru = { inherit version; }; } // lib.optionalAttrs (cross != null) { diff --git a/pkgs/development/tools/build-managers/gnumake/4.2/default.nix b/pkgs/development/tools/build-managers/gnumake/4.2/default.nix index e175205143fc..1094cacb7af3 100644 --- a/pkgs/development/tools/build-managers/gnumake/4.2/default.nix +++ b/pkgs/development/tools/build-managers/gnumake/4.2/default.nix @@ -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 ]; diff --git a/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27.patch b/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27.patch new file mode 100644 index 000000000000..c2639c6cc927 --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/4.2/glibc-2.27.patch @@ -0,0 +1,24 @@ +From 48c8a116a914a325a0497721f5d8b58d5bba34d4 Mon Sep 17 00:00:00 2001 +From: Paul Smith +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 + #include + +-#define GLOB_INTERFACE_VERSION 1 + #if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1 + # include +-# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION ++# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2 + gnu glob + # endif + #endif From 4839b568de509478e7c49cd06a1efb5c40687e5c Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 14:08:22 -0500 Subject: [PATCH 14/16] qemu: Add patch for statfs f_flags in Linux user mode. --- pkgs/applications/virtualization/qemu/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix index 48a9296fa97d..694026d3bac2 100644 --- a/pkgs/applications/virtualization/qemu/default.nix +++ b/pkgs/applications/virtualization/qemu/default.nix @@ -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; From e3f947a19a8f64fd190972561d75557f92d8a953 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 14:33:43 -0500 Subject: [PATCH 15/16] Add missing files --- .../virtualization/qemu/statfs-flags.patch | 200 ++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 pkgs/applications/virtualization/qemu/statfs-flags.patch diff --git a/pkgs/applications/virtualization/qemu/statfs-flags.patch b/pkgs/applications/virtualization/qemu/statfs-flags.patch new file mode 100644 index 000000000000..c0f0162aacc9 --- /dev/null +++ b/pkgs/applications/virtualization/qemu/statfs-flags.patch @@ -0,0 +1,200 @@ +commit d3282d2512774dc5027c98930a3852b2b6e8407a +Author: Shea Levy +Date: Sun Feb 18 13:50:11 2018 -0500 + + linux-user: Support f_flags in statfs when available. + + Signed-off-by: Shea Levy + +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 < ++ ++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 + From 0a0ecc4c2c0c6b55a250f7c31e06fb090e307259 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sun, 18 Feb 2018 15:12:33 -0500 Subject: [PATCH 16/16] Enable building riscv64 cross bootstrap tools Fixes #35089 --- pkgs/stdenv/linux/make-bootstrap-tools-cross.nix | 1 + pkgs/stdenv/linux/make-bootstrap-tools.nix | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix index d08be79e6c55..6c217be4ea3c 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-cross.nix @@ -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; } diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix index 86801e3f0447..71347ef83927 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix @@ -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