2021-02-05 17:12:51 +00:00
|
|
|
|
{ lib, stdenv
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, cmake
|
|
|
|
|
, coreutils
|
|
|
|
|
, glibc
|
2020-08-20 17:08:02 +00:00
|
|
|
|
, gccForLibs
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, which
|
|
|
|
|
, perl
|
|
|
|
|
, libedit
|
|
|
|
|
, ninja
|
2021-02-05 17:12:51 +00:00
|
|
|
|
, pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, sqlite
|
|
|
|
|
, libxml2
|
2022-09-09 14:08:57 +00:00
|
|
|
|
, clang_13
|
2021-08-22 07:53:02 +00:00
|
|
|
|
, python3
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, ncurses
|
|
|
|
|
, libuuid
|
|
|
|
|
, icu
|
2021-08-22 07:53:02 +00:00
|
|
|
|
, libgcc
|
2020-04-24 23:36:52 +00:00
|
|
|
|
, libblocksruntime
|
|
|
|
|
, curl
|
|
|
|
|
, rsync
|
|
|
|
|
, git
|
|
|
|
|
, libgit2
|
|
|
|
|
, fetchFromGitHub
|
|
|
|
|
, makeWrapper
|
|
|
|
|
, gnumake
|
|
|
|
|
, file
|
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
let
|
2022-02-10 20:34:41 +00:00
|
|
|
|
# The Swift toolchain script builds projects with separate repos. By convention, some of them share
|
|
|
|
|
# the same version with the main Swift compiler project per release. We fetch these with
|
|
|
|
|
# `fetchSwiftRelease`. The rest have their own versions locked to each Swift release, as defined in the
|
|
|
|
|
# Swift compiler repo:
|
|
|
|
|
# utils/update_checkout/update_checkout-config.json.
|
|
|
|
|
#
|
|
|
|
|
# ... among projects listed in that file, we provide our own:
|
|
|
|
|
# - CMake
|
|
|
|
|
# - ninja
|
|
|
|
|
# - icu
|
|
|
|
|
#
|
|
|
|
|
# ... we'd like to include the following in the future:
|
|
|
|
|
# - stress-tester
|
|
|
|
|
# - integration-tests
|
|
|
|
|
|
|
|
|
|
versions = {
|
2022-09-09 14:08:57 +00:00
|
|
|
|
swift = "5.6.2";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
yams = "4.0.2";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
argumentParser = "1.0.3";
|
|
|
|
|
format = "release/5.6";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
crypto = "1.1.5";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
nio = "2.31.2";
|
|
|
|
|
nio-ssl = "2.15.0";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
|
fetchAppleRepo = { repo, rev, sha256 }:
|
|
|
|
|
fetchFromGitHub {
|
|
|
|
|
owner = "apple";
|
|
|
|
|
inherit repo rev sha256;
|
|
|
|
|
name = "${repo}-${rev}-src";
|
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
|
|
|
|
|
|
fetchSwiftRelease = { repo, sha256, fetchSubmodules ? false }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
fetchFromGitHub {
|
|
|
|
|
owner = "apple";
|
|
|
|
|
inherit repo sha256 fetchSubmodules;
|
2022-02-10 20:34:41 +00:00
|
|
|
|
rev = "swift-${versions.swift}-RELEASE";
|
|
|
|
|
name = "${repo}-${versions.swift}-src";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
sources = {
|
2022-02-10 20:34:41 +00:00
|
|
|
|
# Projects that share `versions.swift` for each release.
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
swift = fetchSwiftRelease {
|
|
|
|
|
repo = "swift";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-wiRXAXWEksJuy+YQQ+B7tzr2iLkSVkgV6o+wIz7yKJA=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
|
cmark = fetchSwiftRelease {
|
|
|
|
|
repo = "swift-cmark";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-f0BoTs4HYdx/aJ9HIGCWMalhl8PvClWD6R4QK3qSgAw=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
|
llbuild = fetchSwiftRelease {
|
|
|
|
|
repo = "swift-llbuild";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-SQ6V0zVshIYMjayx+ZpYuLijgQ89tqRnPlXBPf2FYqM=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
|
driver = fetchSwiftRelease {
|
|
|
|
|
repo = "swift-driver";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-D5/C4Rbv5KIsKpy6YbuMxGIGaQkn80PD4Cp0l6bPKzY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
|
toolsSupportCore = fetchSwiftRelease {
|
|
|
|
|
repo = "swift-tools-support-core";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-FbtQCq1sSlzrskCrgzD4iYuo5eGaXrAUUxoNX/BiOfg=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
|
swiftpm = fetchSwiftRelease {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
repo = "swift-package-manager";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-esO4Swz3UYngbVgxoV+fkhSC0AU3IaxVjWkgK/s3x68=";
|
2021-08-22 07:53:02 +00:00
|
|
|
|
};
|
|
|
|
|
syntax = fetchSwiftRelease {
|
|
|
|
|
repo = "swift-syntax";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-C9FPCtq49BvKXtTWWeReYWNrU70pHzT2DhAv3NiTbPU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
|
corelibsXctest = fetchSwiftRelease {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
repo = "swift-corelibs-xctest";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-0hizfnKJaUUA+jXuXzXWk72FmlSyc+UGEf7BTLdJrx4=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
|
corelibsFoundation = fetchSwiftRelease {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
repo = "swift-corelibs-foundation";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-8sCL8Ia6yb6bRsJZ52gUJH0jN3lwClM573G8jgUdEhw=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
|
corelibsLibdispatch = fetchSwiftRelease {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
repo = "swift-corelibs-libdispatch";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-1tIskUMnfblnvZaFDQPUMBfWTmBYG98s7rEww7PwZO8=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
fetchSubmodules = true;
|
|
|
|
|
};
|
2021-08-22 07:53:02 +00:00
|
|
|
|
indexstoreDb = fetchSwiftRelease {
|
|
|
|
|
repo = "indexstore-db";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-/PO4eMiASZN3pjFjBQ1r8vYwGRn6xm3SWaB2HDZlkPs=";
|
2021-08-22 07:53:02 +00:00
|
|
|
|
};
|
|
|
|
|
sourcekitLsp = fetchSwiftRelease {
|
|
|
|
|
repo = "sourcekit-lsp";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-ttgUC4ZHD3P/xLHllEbACtHVrJ6HXqeVWccXcoPMkts=";
|
2021-08-22 07:53:02 +00:00
|
|
|
|
};
|
|
|
|
|
llvmProject = fetchSwiftRelease {
|
|
|
|
|
repo = "llvm-project";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-YVs3lKV2RlaovpYkdGO+vzypolrmXmbKBBP4+osNMYw=";
|
|
|
|
|
};
|
|
|
|
|
docc = fetchSwiftRelease {
|
|
|
|
|
repo = "swift-docc";
|
|
|
|
|
sha256 = "sha256-rWiaNamZoHTO1bKpubxuT7m1IBOl7amT5M71mNauilY=";
|
|
|
|
|
};
|
|
|
|
|
docc-render-artifact = fetchSwiftRelease {
|
|
|
|
|
repo = "swift-docc-render-artifact";
|
|
|
|
|
sha256 = "sha256-AX+rtDLhq8drk7N6/hoH3fQioudmmTCnEhR45bME8uU=";
|
|
|
|
|
};
|
|
|
|
|
docc-symbolkit = fetchSwiftRelease {
|
|
|
|
|
repo = "swift-docc-symbolkit";
|
|
|
|
|
sha256 = "sha256-Xy1TQ5ucDW+MnkeOvVznsATBmwcQ3p1x+ofQ22ofk+o=";
|
|
|
|
|
};
|
|
|
|
|
lmdb = fetchSwiftRelease {
|
|
|
|
|
repo = "swift-lmdb";
|
|
|
|
|
sha256 = "sha256-i2GkWRWq1W5j8rF4PiHwWgT4Dur5FCY2o44HvUU3vtQ=";
|
|
|
|
|
};
|
|
|
|
|
markdown = fetchSwiftRelease {
|
|
|
|
|
repo = "swift-markdown";
|
|
|
|
|
sha256 = "sha256-XtFSBiNHhmULjS4OqSpMgUetLu3peRg7l6HpjwVsTj8=";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
cmark-gfm = fetchAppleRepo {
|
|
|
|
|
repo = "swift-cmark";
|
|
|
|
|
rev = "swift-${versions.swift}-RELEASE-gfm";
|
|
|
|
|
sha256 = "sha256-g28iKmMR2W0r1urf8Fk1HBxAp5OlonNYSVN3Ril66tQ=";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Projects that have their own versions during each release
|
|
|
|
|
|
|
|
|
|
argumentParser = fetchAppleRepo {
|
|
|
|
|
repo = "swift-argument-parser";
|
|
|
|
|
rev = "${versions.argumentParser}";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-vNqkuAwSZNCWvwe6E5BqbXQdIbmIia0dENmmSQ9P8Mo=";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
};
|
|
|
|
|
format = fetchAppleRepo {
|
|
|
|
|
repo = "swift-format";
|
|
|
|
|
rev = "${versions.format}";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-1f5sIrv9IbPB7Vnahq1VwH8gT41dcjWldRwvVEaMdto=";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
};
|
|
|
|
|
crypto = fetchAppleRepo {
|
|
|
|
|
repo = "swift-crypto";
|
|
|
|
|
rev = "${versions.crypto}";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-jwxXQuOF+CnpLMwTZ2z52Fgx2b97yWzXiPTx0Ye8KCQ=";
|
|
|
|
|
};
|
|
|
|
|
nio = fetchAppleRepo {
|
|
|
|
|
repo = "swift-nio";
|
|
|
|
|
rev = versions.nio;
|
|
|
|
|
sha256 = "sha256-FscOA/S7on31QCR/MZFjg4ZB3FGJ+rdptZ6MRZJXexE=";
|
|
|
|
|
};
|
|
|
|
|
nio-ssl = fetchAppleRepo {
|
|
|
|
|
repo = "swift-nio-ssl";
|
|
|
|
|
rev = versions.nio-ssl;
|
|
|
|
|
sha256 = "sha256-5QGkmkCOXhG3uOdf0bd3Fo1MFekB8/WcveBXGhtVZKo=";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
};
|
|
|
|
|
yams = fetchFromGitHub {
|
|
|
|
|
owner = "jpsim";
|
|
|
|
|
repo = "Yams";
|
|
|
|
|
rev = versions.yams;
|
2022-09-09 14:08:57 +00:00
|
|
|
|
sha256 = "sha256-cTkCAwxxLc35laOon1ZXXV8eAxX02oDolJyPauhZado=";
|
2022-02-10 20:34:41 +00:00
|
|
|
|
name = "Yams-${versions.yams}-src";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
devInputs = [
|
|
|
|
|
curl
|
|
|
|
|
glibc
|
|
|
|
|
icu
|
|
|
|
|
libblocksruntime
|
|
|
|
|
libedit
|
2021-08-22 07:53:02 +00:00
|
|
|
|
libgcc
|
2020-04-24 23:36:52 +00:00
|
|
|
|
libuuid
|
|
|
|
|
libxml2
|
|
|
|
|
ncurses
|
|
|
|
|
sqlite
|
|
|
|
|
];
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
python = (python3.withPackages (ps: [ps.six]));
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
cmakeFlags = [
|
|
|
|
|
"-DGLIBC_INCLUDE_PATH=${stdenv.cc.libc.dev}/include"
|
2021-02-05 17:12:51 +00:00
|
|
|
|
"-DC_INCLUDE_DIRS=${lib.makeSearchPathOutput "dev" "include" devInputs}:${libxml2.dev}/include/libxml2"
|
2020-08-20 17:08:02 +00:00
|
|
|
|
"-DGCC_INSTALL_PREFIX=${gccForLibs}"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
stdenv.mkDerivation {
|
2022-03-10 19:12:11 +00:00
|
|
|
|
pname = "swift";
|
|
|
|
|
version = versions.swift;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
|
cmake
|
2021-08-22 07:53:02 +00:00
|
|
|
|
git
|
2020-04-24 23:36:52 +00:00
|
|
|
|
makeWrapper
|
|
|
|
|
ninja
|
|
|
|
|
perl
|
2021-02-05 17:12:51 +00:00
|
|
|
|
pkg-config
|
2020-04-24 23:36:52 +00:00
|
|
|
|
python
|
|
|
|
|
rsync
|
|
|
|
|
which
|
|
|
|
|
];
|
|
|
|
|
buildInputs = devInputs ++ [
|
2022-09-09 14:08:57 +00:00
|
|
|
|
clang_13
|
2020-04-24 23:36:52 +00:00
|
|
|
|
];
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# TODO: Revisit what needs to be propagated and how.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
propagatedBuildInputs = [
|
2021-08-22 07:53:02 +00:00
|
|
|
|
libgcc
|
2020-04-24 23:36:52 +00:00
|
|
|
|
libgit2
|
|
|
|
|
python
|
|
|
|
|
];
|
2021-02-05 17:12:51 +00:00
|
|
|
|
propagatedUserEnvPkgs = [ git pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
hardeningDisable = [ "format" ]; # for LLDB
|
|
|
|
|
|
|
|
|
|
unpackPhase = ''
|
|
|
|
|
mkdir src
|
|
|
|
|
cd src
|
|
|
|
|
export SWIFT_SOURCE_ROOT=$PWD
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
cp -r ${sources.swift} swift
|
2020-04-24 23:36:52 +00:00
|
|
|
|
cp -r ${sources.cmark} cmark
|
|
|
|
|
cp -r ${sources.llbuild} llbuild
|
2021-08-22 07:53:02 +00:00
|
|
|
|
cp -r ${sources.argumentParser} swift-argument-parser
|
|
|
|
|
cp -r ${sources.driver} swift-driver
|
|
|
|
|
cp -r ${sources.toolsSupportCore} swift-tools-support-core
|
|
|
|
|
cp -r ${sources.swiftpm} swiftpm
|
|
|
|
|
cp -r ${sources.syntax} swift-syntax
|
|
|
|
|
cp -r ${sources.corelibsXctest} swift-corelibs-xctest
|
|
|
|
|
cp -r ${sources.corelibsFoundation} swift-corelibs-foundation
|
|
|
|
|
cp -r ${sources.corelibsLibdispatch} swift-corelibs-libdispatch
|
|
|
|
|
cp -r ${sources.yams} yams
|
|
|
|
|
cp -r ${sources.indexstoreDb} indexstore-db
|
|
|
|
|
cp -r ${sources.sourcekitLsp} sourcekit-lsp
|
|
|
|
|
cp -r ${sources.format} swift-format
|
2022-02-10 20:34:41 +00:00
|
|
|
|
cp -r ${sources.crypto} swift-crypto
|
2021-08-22 07:53:02 +00:00
|
|
|
|
cp -r ${sources.llvmProject} llvm-project
|
2022-09-09 14:08:57 +00:00
|
|
|
|
cp -r ${sources.cmark-gfm} swift-cmark-gfm
|
|
|
|
|
cp -r ${sources.docc} swift-docc
|
|
|
|
|
cp -r ${sources.docc-render-artifact} swift-docc-render-artifact
|
|
|
|
|
cp -r ${sources.docc-symbolkit} swift-docc-symbolkit
|
|
|
|
|
cp -r ${sources.lmdb} swift-lmdb
|
|
|
|
|
cp -r ${sources.markdown} swift-markdown
|
|
|
|
|
cp -r ${sources.nio} swift-nio
|
|
|
|
|
cp -r ${sources.nio-ssl} swift-nio-ssl
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
chmod -R u+w .
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
patchPhase = ''
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# Just patch all the things for now, we can focus this later.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
patchShebangs $SWIFT_SOURCE_ROOT
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# TODO: eliminate use of env.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
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'
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# Build configuration patches.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
patch -p1 -d swift -i ${./patches/0001-build-presets-linux-don-t-require-using-Ninja.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-don-t-build-extra-libs.patch}
|
|
|
|
|
patch -p1 -d swift -i ${./patches/0004-build-presets-linux-plumb-extra-cmake-options.patch}
|
2022-09-09 14:08:57 +00:00
|
|
|
|
patch -p1 -d swift -i ${./patches/0007-build-presets-linux-os-stdlib.patch}
|
2021-08-22 07:53:02 +00:00
|
|
|
|
substituteInPlace swift/cmake/modules/SwiftConfigureSDK.cmake \
|
|
|
|
|
--replace '/usr/include' "${stdenv.cc.libc.dev}/include"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
sed -i swift/utils/build-presets.ini \
|
|
|
|
|
-e 's/^test-installable-package$/# \0/' \
|
|
|
|
|
-e 's/^test$/# \0/' \
|
|
|
|
|
-e 's/^validation-test$/# \0/' \
|
|
|
|
|
-e 's/^long-test$/# \0/' \
|
|
|
|
|
-e 's/^stress-test$/# \0/' \
|
|
|
|
|
-e 's/^test-optimized$/# \0/' \
|
|
|
|
|
-e 's/^swift-install-components=autolink.*$/\0;editor-integration/'
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# LLVM toolchain patches.
|
|
|
|
|
patch -p1 -d llvm-project/clang -i ${./patches/0005-clang-toolchain-dir.patch}
|
|
|
|
|
patch -p1 -d llvm-project/clang -i ${./patches/0006-clang-purity.patch}
|
|
|
|
|
substituteInPlace llvm-project/clang/lib/Driver/ToolChains/Linux.cpp \
|
|
|
|
|
--replace 'SysRoot + "/lib' '"${glibc}/lib" "' \
|
|
|
|
|
--replace 'SysRoot + "/usr/lib' '"${glibc}/lib" "' \
|
|
|
|
|
--replace 'LibDir = "lib";' 'LibDir = "${glibc}/lib";' \
|
|
|
|
|
--replace 'LibDir = "lib64";' 'LibDir = "${glibc}/lib";' \
|
|
|
|
|
--replace 'LibDir = X32 ? "libx32" : "lib64";' 'LibDir = "${glibc}/lib";'
|
|
|
|
|
|
|
|
|
|
# Substitute ncurses for curses in llbuild.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
sed -i 's/curses/ncurses/' llbuild/*/*/CMakeLists.txt
|
2021-08-22 07:53:02 +00:00
|
|
|
|
sed -i 's/curses/ncurses/' llbuild/*/*/*/CMakeLists.txt
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# uuid.h is not part of glibc, but of libuuid.
|
|
|
|
|
sed -i 's|''${GLIBC_INCLUDE_PATH}/uuid/uuid.h|${libuuid.dev}/include/uuid/uuid.h|' swift/stdlib/public/Platform/glibc.modulemap.gyb
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# Support library build script patches.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
PREFIX=''${out/#\/}
|
2021-08-22 07:53:02 +00:00
|
|
|
|
substituteInPlace swift/utils/swift_build_support/swift_build_support/products/benchmarks.py \
|
|
|
|
|
--replace \
|
|
|
|
|
"'--toolchain', toolchain_path," \
|
|
|
|
|
"'--toolchain', '/build/install/$PREFIX',"
|
|
|
|
|
substituteInPlace swift/benchmark/scripts/build_script_helper.py \
|
|
|
|
|
--replace \
|
|
|
|
|
"swiftbuild_path = os.path.join(args.toolchain, \"usr\", \"bin\", \"swift-build\")" \
|
|
|
|
|
"swiftbuild_path = os.path.join(args.toolchain, \"bin\", \"swift-build\")"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
substituteInPlace swift-corelibs-xctest/build_script.py \
|
|
|
|
|
--replace usr "$PREFIX"
|
2022-09-09 14:08:57 +00:00
|
|
|
|
|
|
|
|
|
# Can be removed in later swift-docc versions, see
|
|
|
|
|
# https://github.com/apple/swift-docc/commit/bff70b847008f91ac729cfd299a85481eef3f581
|
|
|
|
|
substituteInPlace swift-docc/build-script-helper.py \
|
|
|
|
|
--replace \
|
|
|
|
|
"subprocess.check_output(cmd, env=env).strip(), 'docc')" \
|
|
|
|
|
"subprocess.check_output(cmd, env=env).strip().decode(), 'docc')"
|
|
|
|
|
|
|
|
|
|
# Can be removed in later Swift versions, see
|
|
|
|
|
# https://github.com/apple/swift/pull/58755
|
|
|
|
|
substituteInPlace swift/utils/process-stats-dir.py \
|
|
|
|
|
--replace \
|
|
|
|
|
"type=argparse.FileType('wb', 0)," \
|
|
|
|
|
"type=argparse.FileType('w', 0),"
|
|
|
|
|
|
|
|
|
|
# Apply Python 3 fix, see
|
|
|
|
|
# https://github.com/apple/swift/commit/ec6bc595092974628b27b114a472e84162261bbd
|
|
|
|
|
substituteInPlace swift/utils/swift_build_support/swift_build_support/productpipeline_list_builder.py \
|
|
|
|
|
--replace \
|
|
|
|
|
"filter(lambda x: x is not None, pipeline)" \
|
|
|
|
|
"[p for p in pipeline if p is not None]"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
|
|
mkdir build install
|
|
|
|
|
export SWIFT_BUILD_ROOT=$PWD/build
|
|
|
|
|
export SWIFT_INSTALL_DIR=$PWD/install
|
|
|
|
|
|
|
|
|
|
export INSTALLABLE_PACKAGE=$PWD/swift.tar.gz
|
|
|
|
|
export NIX_ENFORCE_PURITY=
|
|
|
|
|
|
|
|
|
|
cd $SWIFT_BUILD_ROOT
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
buildPhase = ''
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# Explicitly include C++ headers to prevent errors where stdlib.h is not found from cstdlib.
|
2022-09-09 14:08:57 +00:00
|
|
|
|
export NIX_CFLAGS_COMPILE="$(< ${clang_13}/nix-support/libcxx-cxxflags) $NIX_CFLAGS_COMPILE"
|
2021-08-22 07:53:02 +00:00
|
|
|
|
|
|
|
|
|
# During the Swift build, a full local LLVM build is performed and the resulting clang is
|
|
|
|
|
# invoked. This compiler is not using the Nix wrappers, so it needs some help to find things.
|
2020-08-20 17:08:02 +00:00
|
|
|
|
export NIX_LDFLAGS_BEFORE="-rpath ${gccForLibs.lib}/lib -L${gccForLibs.lib}/lib $NIX_LDFLAGS_BEFORE"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# However, we want to use the wrapped compiler whenever possible.
|
2022-09-09 14:08:57 +00:00
|
|
|
|
export CC="${clang_13}/bin/clang"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
$SWIFT_SOURCE_ROOT/swift/utils/build-script \
|
|
|
|
|
--preset=buildbot_linux \
|
|
|
|
|
installable_package=$INSTALLABLE_PACKAGE \
|
|
|
|
|
install_prefix=$out \
|
|
|
|
|
install_destdir=$SWIFT_INSTALL_DIR \
|
2021-02-05 17:12:51 +00:00
|
|
|
|
extra_cmake_options="${lib.concatStringsSep "," cmakeFlags}"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
|
|
|
|
|
|
checkInputs = [ file ];
|
|
|
|
|
|
|
|
|
|
checkPhase = ''
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# Remove compiler build system tests which fail due to our modified default build profile and
|
|
|
|
|
# nixpkgs-provided version of CMake.
|
|
|
|
|
rm $SWIFT_SOURCE_ROOT/swift/validation-test/BuildSystem/infer_implies_install_all.test
|
|
|
|
|
rm $SWIFT_SOURCE_ROOT/swift/validation-test/BuildSystem/infer_dumps_deps_if_verbose_build.test
|
|
|
|
|
|
|
|
|
|
# This test apparently requires Python 2 (strings are assumed to be bytes-like), but the build
|
|
|
|
|
# process overall now otherwise requires Python 3 (which is what we have updated to). A fix PR
|
|
|
|
|
# has been submitted upstream.
|
|
|
|
|
rm $SWIFT_SOURCE_ROOT/swift/validation-test/SIL/verify_all_overlays.py
|
|
|
|
|
|
|
|
|
|
# TODO: consider fixing and re-adding. This test fails due to a non-standard "install_prefix".
|
|
|
|
|
rm $SWIFT_SOURCE_ROOT/swift/validation-test/Python/build_swift.swift
|
|
|
|
|
|
|
|
|
|
# We cannot handle the SDK location being in "Weird Location" due to Nix isolation.
|
|
|
|
|
rm $SWIFT_SOURCE_ROOT/swift/test/DebugInfo/compiler-flags.swift
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# TODO: Fix issue with ld.gold invoked from script finding crtbeginS.o and crtendS.o.
|
|
|
|
|
rm $SWIFT_SOURCE_ROOT/swift/test/IRGen/ELF-remove-autolink-section.swift
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
|
# The following two tests fail because we use don't use the bundled libicu:
|
|
|
|
|
# [SOURCE_DIR/utils/build-script] ERROR: can't find source directory for libicu (tried /build/src/icu)
|
|
|
|
|
rm $SWIFT_SOURCE_ROOT/swift/validation-test/BuildSystem/default_build_still_performs_epilogue_opts_after_split.test
|
|
|
|
|
rm $SWIFT_SOURCE_ROOT/swift/validation-test/BuildSystem/test_early_swift_driver_and_infer.swift
|
|
|
|
|
|
|
|
|
|
# TODO: This test fails for some unknown reason
|
|
|
|
|
rm $SWIFT_SOURCE_ROOT/swift/test/Serialization/restrict-swiftmodule-to-revision.swift
|
|
|
|
|
|
|
|
|
|
# This test was flaky in ofborg, see #186476
|
|
|
|
|
rm $SWIFT_SOURCE_ROOT/swift/test/AutoDiff/compiler_crashers_fixed/sr14290-missing-debug-scopes-in-pullback-trampoline.swift
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# TODO: consider using stress-tester and integration-test.
|
|
|
|
|
|
|
|
|
|
# Match the wrapped version of Swift to be installed.
|
2021-12-24 04:21:11 +00:00
|
|
|
|
export LIBRARY_PATH=${lib.makeLibraryPath [icu libgcc libuuid]}:$l
|
2021-08-22 07:53:02 +00:00
|
|
|
|
|
|
|
|
|
checkTarget=check-swift-all-${stdenv.hostPlatform.parsed.kernel.name}-${stdenv.hostPlatform.parsed.cpu.name}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
ninjaFlags='-C buildbot_linux/swift-${stdenv.hostPlatform.parsed.kernel.name}-${stdenv.hostPlatform.parsed.cpu.name}'
|
|
|
|
|
ninjaCheckPhase
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
mkdir -p $out
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# Extract the generated tarball into the store.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
tar xf $INSTALLABLE_PACKAGE -C $out --strip-components=3 ''${out/#\/}
|
|
|
|
|
find $out -type d -empty -delete
|
|
|
|
|
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# Fix installation weirdness, also present in Apple’s official tarballs.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
mv $out/local/include/indexstore $out/include
|
|
|
|
|
rmdir $out/local/include $out/local
|
|
|
|
|
rm -r $out/bin/sdk-module-lists $out/bin/swift-api-checker.py
|
|
|
|
|
|
|
|
|
|
wrapProgram $out/bin/swift \
|
2021-08-22 07:53:02 +00:00
|
|
|
|
--set CC $out/bin/clang \
|
|
|
|
|
--suffix C_INCLUDE_PATH : $out/lib/swift/clang/include \
|
|
|
|
|
--suffix CPLUS_INCLUDE_PATH : $out/lib/swift/clang/include \
|
2022-09-09 14:08:57 +00:00
|
|
|
|
--suffix LIBRARY_PATH : ${lib.makeLibraryPath [icu libgcc libuuid]} \
|
|
|
|
|
--suffix PATH : ${lib.makeBinPath [ stdenv.cc.bintools ]}
|
2021-08-22 07:53:02 +00:00
|
|
|
|
|
|
|
|
|
wrapProgram $out/bin/swiftc \
|
|
|
|
|
--set CC $out/bin/clang \
|
2020-04-24 23:36:52 +00:00
|
|
|
|
--suffix C_INCLUDE_PATH : $out/lib/swift/clang/include \
|
|
|
|
|
--suffix CPLUS_INCLUDE_PATH : $out/lib/swift/clang/include \
|
2022-09-09 14:08:57 +00:00
|
|
|
|
--suffix LIBRARY_PATH : ${lib.makeLibraryPath [icu libgcc libuuid]} \
|
|
|
|
|
--suffix PATH : ${lib.makeBinPath [ stdenv.cc.bintools ]}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
# Hack to avoid build and install directories in RPATHs.
|
2021-02-05 17:12:51 +00:00
|
|
|
|
preFixup = "rm -rf $SWIFT_BUILD_ROOT $SWIFT_INSTALL_DIR";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
description = "The Swift Programming Language";
|
|
|
|
|
homepage = "https://github.com/apple/swift";
|
2022-09-09 14:08:57 +00:00
|
|
|
|
maintainers = with maintainers; [ dtzWill trepetti dduan trundle ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
license = licenses.asl20;
|
2021-08-22 07:53:02 +00:00
|
|
|
|
# Swift doesn't support 32-bit Linux, unknown on other platforms.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
platforms = platforms.linux;
|
|
|
|
|
badPlatforms = platforms.i686;
|
2021-08-22 07:53:02 +00:00
|
|
|
|
timeout = 86400; # 24 hours.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
}
|