diff --git a/pkgs/development/compilers/swift/compiler/default.nix b/pkgs/development/compilers/swift/compiler/default.nix deleted file mode 100644 index 454bee2c49f7..000000000000 --- a/pkgs/development/compilers/swift/compiler/default.nix +++ /dev/null @@ -1,842 +0,0 @@ -{ - lib, - stdenv, - callPackage, - cmake, - bash, - coreutils, - gnugrep, - perl, - ninja_1_11, - pkg-config, - clang, - bintools, - python312Packages, - git, - fetchpatch, - fetchpatch2, - makeWrapper, - gnumake, - file, - runCommand, - writeShellScriptBin, - # For lldb - libedit, - ncurses, - swig, - libxml2, - # Linux-specific - glibc, - libuuid, - # Darwin-specific - replaceVars, - fixDarwinDylibNames, - xcbuild, - cctools, # libtool - sigtool, - DarwinTools, - apple-sdk_14, - darwinMinVersionHook, -}: - -let - apple-sdk_swift = apple-sdk_14; # Use the SDK that was available when Swift shipped. - - deploymentVersion = - if lib.versionOlder (targetPlatform.darwinMinVersion or "0") "10.15" then - "10.15" - else - targetPlatform.darwinMinVersion; - - # Use Python 3.12 for now because Swift 5.8 depends on Python's PyEval_ThreadsInitialized(), which was removed in 3.13. - python3 = python312Packages.python.withPackages (p: [ p.setuptools ]); # python 3.12 compat. - - inherit (stdenv) hostPlatform targetPlatform; - - sources = callPackage ../sources.nix { }; - - # There are apparently multiple naming conventions on Darwin. Swift uses the - # xcrun naming convention. See `configure_sdk_darwin` calls in CMake files. - swiftOs = - if targetPlatform.isDarwin then - { - "macos" = "macosx"; - "ios" = "iphoneos"; - #iphonesimulator - #appletvos - #appletvsimulator - #watchos - #watchsimulator - } - .${targetPlatform.darwinPlatform} - or (throw "Cannot build Swift for target Darwin platform '${targetPlatform.darwinPlatform}'") - else - targetPlatform.parsed.kernel.name; - - # This causes swiftPackages.XCTest to fail to build on aarch64-linux - # as I believe this is because Apple calls the architecture aarch64 - # on Linux rather than arm64 when used with macOS. - swiftArch = - if hostPlatform.isDarwin then hostPlatform.darwinArch else targetPlatform.parsed.cpu.name; - - # On Darwin, a `.swiftmodule` is a subdirectory in `lib/swift/`, - # containing binaries for supported archs. On other platforms, binaries are - # installed to `lib/swift//`. Note that our setup-hook also adds - # `lib/swift` for convenience. - swiftLibSubdir = "lib/swift/${swiftOs}"; - swiftModuleSubdir = - if hostPlatform.isDarwin then "lib/swift/${swiftOs}" else "lib/swift/${swiftOs}/${swiftArch}"; - - # And then there's also a separate subtree for statically linked modules. - toStaticSubdir = lib.replaceStrings [ "/swift/" ] [ "/swift_static/" ]; - swiftStaticLibSubdir = toStaticSubdir swiftLibSubdir; - swiftStaticModuleSubdir = toStaticSubdir swiftModuleSubdir; - - # This matches _SWIFT_DEFAULT_COMPONENTS, with specific components disabled. - swiftInstallComponents = [ - "autolink-driver" - "compiler" - # "clang-builtin-headers" - "stdlib" - "sdk-overlay" - "static-mirror-lib" - "editor-integration" - # "tools" - # "testsuite-tools" - "toolchain-tools" - "toolchain-dev-tools" - "license" - (if stdenv.hostPlatform.isDarwin then "sourcekit-xpc-service" else "sourcekit-inproc") - "swift-remote-mirror" - "swift-remote-mirror-headers" - ]; - - clangForWrappers = clang.override (prev: { - extraBuildCommands = - prev.extraBuildCommands - # We need to use the resource directory corresponding to Swift’s - # version of Clang instead of passing along the one from the - # `cc-wrapper` flags. - + '' - substituteInPlace $out/nix-support/cc-cflags \ - --replace-fail " -resource-dir=$out/resource-root" "" - '' - + - lib.optionalString - (targetPlatform.isLinux && targetPlatform.isx86 && lib.versionAtLeast (lib.getVersion clang) "19.1") - '' - # Swift bundles Clang 16, which predates -mtls-dialect=gnu2 - # support (added in Clang 19.1). The cc-wrapper adds it based - # on the system Clang version, so strip it here. - substituteInPlace $out/nix-support/add-local-cc-cflags-before.sh \ - --replace-fail "'-mtls-dialect=gnu2'" "" - ''; - }); - - # Build a tool used during the build to create a custom clang wrapper, with - # which we wrap the clang produced by the swift build. - # - # This is used in a `POST_BUILD` for the CMake target, so we rename the - # actual clang to clang-unwrapped, then put the wrapper in place. - # - # We replace the `exec ...` command with `exec -a "$0"` in order to - # preserve $0 for clang. This is because, unlike Nix, we don't have - # separate wrappers for clang/clang++, and clang uses $0 to detect C++. - # - # Similarly, the C++ detection in the wrapper itself also won't work for us, - # so we base it on $0 as well. - makeClangWrapper = writeShellScriptBin "nix-swift-make-clang-wrapper" '' - set -euo pipefail - - targetFile="$1" - unwrappedClang="$targetFile-unwrapped" - - mv "$targetFile" "$unwrappedClang" - sed < '${clangForWrappers}/bin/clang' > "$targetFile" \ - -e 's|^\s*exec|exec -a "$0"|g' \ - -e 's|^\[\[ "${clang.cc}/bin/clang" = \*++ ]]|[[ "$0" = *++ ]]|' \ - -e "s|${clang.cc}/bin/clang|$unwrappedClang|g" \ - -e "s|^\(\s*\)\($unwrappedClang\) \"@\\\$responseFile\"|\1argv0=\$0\n\1${bash}/bin/bash -c \"exec -a '\$argv0' \2 '@\$responseFile'\"|" \ - ${lib.optionalString (clang.libcxx != null) '' - -e 's|$NIX_CXXSTDLIB_COMPILE_${clang.suffixSalt}|-isystem '$SWIFT_BUILD_ROOT'/libcxx/include/c++/v1|g' - ''} - chmod a+x "$targetFile" - ''; - - # Create a tool used during the build to create a custom swift wrapper for - # each of the swift executables produced by the build. - # - # The build produces several `swift-frontend` executables during - # bootstrapping. Each of these has numerous aliases via symlinks, and the - # executable uses $0 to detect what tool is called. - wrapperParams = { - inherit bintools; - coreutils_bin = lib.getBin coreutils; - gnugrep_bin = gnugrep; - suffixSalt = lib.replaceStrings [ "-" "." ] [ "_" "_" ] targetPlatform.config; - use_response_file_by_default = 1; - swiftDriver = ""; - # NOTE: @cc_wrapper@ and @prog@ need to be filled elsewhere. - }; - swiftWrapper = runCommand "swift-wrapper.sh" wrapperParams '' - # Make empty to avoid adding the SDK’s modules in the bootstrap wrapper. Otherwise, the SDK conflicts with the - # shims the wrapper tries to build. - darwinMinVersion="" substituteAll '${../wrapper/wrapper.sh}' "$out" - ''; - makeSwiftcWrapper = writeShellScriptBin "nix-swift-make-swift-wrapper" '' - set -euo pipefail - - targetFile="$1" - unwrappedSwift="$targetFile-unwrapped" - - mv "$targetFile" "$unwrappedSwift" - sed < '${swiftWrapper}' > "$targetFile" \ - -e "s|@prog@|'$unwrappedSwift'|g" \ - -e 's|@cc_wrapper@|${clangForWrappers}|g' \ - -e 's|exec "$prog"|exec -a "$0" "$prog"|g' \ - ${lib.optionalString (clang.libcxx != null) '' - -e 's|$NIX_CXXSTDLIB_COMPILE_${clang.suffixSalt}|-isystem '$SWIFT_BUILD_ROOT'/libcxx/include/c++/v1|g' - ''} - chmod a+x "$targetFile" - ''; - - # On Darwin, we need to use BOOTSTRAPPING-WITH-HOSTLIBS because of ABI - # stability, and have to provide the definitions for the system stdlib. - appleSwiftCore = stdenv.mkDerivation { - name = "apple-swift-core"; - dontUnpack = true; - - buildInputs = [ apple-sdk_swift ]; - - installPhase = '' - mkdir -p $out/lib/swift - cp -r \ - "$SDKROOT/usr/lib/swift/Swift.swiftmodule" \ - "$SDKROOT/usr/lib/swift/CoreFoundation.swiftmodule" \ - "$SDKROOT/usr/lib/swift/Dispatch.swiftmodule" \ - "$SDKROOT/usr/lib/swift/ObjectiveC.swiftmodule" \ - "$SDKROOT/usr/lib/swift/libswiftCore.tbd" \ - "$SDKROOT/usr/lib/swift/libswiftCoreFoundation.tbd" \ - "$SDKROOT/usr/lib/swift/libswiftDispatch.tbd" \ - "$SDKROOT/usr/lib/swift/libswiftFoundation.tbd" \ - "$SDKROOT/usr/lib/swift/libswiftObjectiveC.tbd" \ - $out/lib/swift/ - ''; - }; - - # https://github.com/NixOS/nixpkgs/issues/327836 - # Fail to build with ninja 1.12 when NIX_BUILD_CORES is low (Hydra or Github Actions). - # Can reproduce using `nix --option cores 2 build -f . swiftPackages.swift-unwrapped`. - # Until we find out the exact cause, follow [swift upstream][1], pin ninja to version - # 1.11.1. - # [1]: https://github.com/swiftlang/swift/pull/72989 - ninja = ninja_1_11; - -in -stdenv.mkDerivation { - pname = "swift"; - inherit (sources) version; - - outputs = [ - "out" - "lib" - "dev" - "doc" - "man" - ]; - - nativeBuildInputs = [ - cmake - git - ninja - perl # pod2man - pkg-config - python3 - makeWrapper - makeClangWrapper - makeSwiftcWrapper - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - xcbuild - sigtool # codesign - DarwinTools # sw_vers - fixDarwinDylibNames - cctools.libtool - ]; - - buildInputs = [ - # For lldb - python3 - swig - libxml2 - ] - ++ lib.optionals stdenv.hostPlatform.isLinux [ - libuuid - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - apple-sdk_swift - ]; - - # Will effectively be `buildInputs` when swift is put in `nativeBuildInputs`. - depsTargetTargetPropagated = lib.optionals stdenv.targetPlatform.isDarwin [ - apple-sdk_swift - ]; - - # This is a partial reimplementation of our setup hook. Because we reuse - # the Swift wrapper for the Swift build itself, we need to do some of the - # same preparation. - postHook = '' - for pkg in "''${pkgsHostTarget[@]}" '${clang.libc}'; do - for subdir in ${swiftModuleSubdir} ${swiftStaticModuleSubdir} lib/swift; do - if [[ -d "$pkg/$subdir" ]]; then - export NIX_SWIFTFLAGS_COMPILE+=" -I $pkg/$subdir" - fi - done - for subdir in ${swiftLibSubdir} ${swiftStaticLibSubdir} lib/swift; do - if [[ -d "$pkg/$subdir" ]]; then - export NIX_LDFLAGS+=" -L $pkg/$subdir" - fi - done - done - ''; - - # We setup custom build directories. - dontUseCmakeBuildDir = true; - - unpackPhase = - let - copySource = repo: "cp -r ${sources.${repo}} ${repo}"; - in - '' - mkdir src - cd src - - ${copySource "swift-cmark"} - ${copySource "llvm-project"} - ${copySource "swift"} - ${copySource "swift-experimental-string-processing"} - ${copySource "swift-syntax"} - ${lib.optionalString (!stdenv.hostPlatform.isDarwin) (copySource "swift-corelibs-libdispatch")} - - chmod -R u+w . - ''; - - patchPhase = '' - # Just patch all the things for now, we can focus this later. - # TODO: eliminate use of env. - find -type f -print0 | xargs -0 sed -i \ - ${lib.optionalString stdenv.hostPlatform.isDarwin "-e 's|/usr/libexec/PlistBuddy|${xcbuild}/bin/PlistBuddy|g'"} \ - -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' - - patch -p1 -d swift -i ${./patches/swift-wrap.patch} - patch -p1 -d swift -i ${./patches/swift-linux-fix-libc-paths.patch} - patch -p1 -d swift -i ${ - replaceVars ./patches/swift-linux-fix-linking.patch { - inherit clang; - } - } - patch -p1 -d swift -i ${ - replaceVars ./patches/swift-darwin-plistbuddy-workaround.patch { - inherit swiftArch; - } - } - patch -p1 -d swift -i ${ - replaceVars ./patches/swift-prevent-sdk-dirs-warning.patch { - inherit (builtins) storeDir; - } - } - patch -p1 -d swift -i ${./patches/swift-Frontend-Fix-a-small-unique_ptr-array-access.patch} - - # This patch needs to know the lib output location, so must be substituted - # in the same derivation as the compiler. - storeDir="${builtins.storeDir}" \ - substituteAll ${./patches/swift-separate-lib.patch} $TMPDIR/swift-separate-lib.patch - patch -p1 -d swift -i $TMPDIR/swift-separate-lib.patch - - patch -p1 -d llvm-project/llvm -i ${./patches/llvm-module-cache.patch} - for root in llvm-project/llvm swift/stdlib; do - patch -p1 -d $root -i ${ - (fetchpatch { - name = "fix-SmallVector-compile-error.patch"; - url = "https://github.com/llvm/llvm-project/commit/7e44305041d96b064c197216b931ae3917a34ac1.patch"; - stripLen = 1; - hash = "sha256-1htuzsaPHbYgravGc1vrR8sqpQ/NSQ8PUZeAU8ucCFk="; - }) - } - done - patch -p2 -d llvm-project/llvm -i ${./patches/llvm-fix-X86MCTargetDesc-compile-error.patch} - - for lldbPatch in ${ - lib.escapeShellArgs [ - # Fix the build with modern libc++. - (fetchpatch { - name = "add-cstdio.patch"; - url = "https://github.com/llvm/llvm-project/commit/73e15b5edb4fa4a77e68c299a6e3b21e610d351f.patch"; - stripLen = 1; - hash = "sha256-eFcvxZaAuBsY/bda1h9212QevrXyvCHw8Cr9ngetDr0="; - }) - (fetchpatch { - url = "https://github.com/llvm/llvm-project/commit/68744ffbdd7daac41da274eef9ac0d191e11c16d.patch"; - stripLen = 1; - hash = "sha256-QCGhsL/mi7610ZNb5SqxjRGjwJeK2rwtsFVGeG3PUGc="; - }) - (fetchpatch { - name = "LLDB-Add-cstdint-to-AddressableBits-102110.patch"; - url = "https://github.com/llvm/llvm-project/commit/bb59f04e7e75dcbe39f1bf952304a157f0035314.patch"; - stripLen = 1; - hash = "sha256-+CcmZRxCaozFe1Kuf2HX+kGKuh/PDuoFBEFA/t7tL9A="; - }) - ] - }; do - patch -p1 -d llvm-project/lldb -i $lldbPatch - done - - patch -p1 -d llvm-project/clang -i ${./patches/clang-toolchain-dir.patch} - patch -p1 -d llvm-project/clang -i ${./patches/clang-wrap.patch} - patch -p1 -d llvm-project/clang -i ${./patches/clang-purity.patch} - - patch -p1 -d llvm-project/cmake -i ${ - fetchpatch2 { - name = "cmake-fix.patch"; - url = "https://github.com/llvm/llvm-project/commit/3676a86a4322e8c2b9c541f057b5d3704146b8f3.patch?full_index=1"; - stripLen = 1; - hash = "sha256-zP9dQOmWs7qrxkBRj70DyQBbRjH78B6tNJVy6ilA1xM="; - } - } - - ${lib.optionalString stdenv.hostPlatform.isLinux '' - substituteInPlace llvm-project/clang/lib/Driver/ToolChains/Linux.cpp \ - --replace-fail 'LibDir = "lib";' 'LibDir = "${glibc}/lib";' \ - --replace-fail 'LibDir = "lib64";' 'LibDir = "${glibc}/lib";' \ - --replace-fail 'LibDir = X32 ? "libx32" : "lib64";' 'LibDir = "${glibc}/lib";' - - # 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 - ''} - - # Remove tests for cross compilation, which we don't currently support. - rm swift/test/Interop/Cxx/class/constructors-copy-irgen-*.swift - rm swift/test/Interop/Cxx/class/constructors-irgen-*.swift - - # TODO: consider fixing and re-adding. This test fails due to a non-standard "install_prefix". - rm swift/validation-test/Python/build_swift.swift - - # We cannot handle the SDK location being in "Weird Location" due to Nix isolation. - rm swift/test/DebugInfo/compiler-flags.swift - - # TODO: Fix issue with ld.gold invoked from script finding crtbeginS.o and crtendS.o. - rm swift/test/IRGen/ELF-remove-autolink-section.swift - - # 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/validation-test/BuildSystem/default_build_still_performs_epilogue_opts_after_split.test - rm swift/validation-test/BuildSystem/test_early_swift_driver_and_infer.swift - - # TODO: This test fails for some unknown reason - rm swift/test/Serialization/restrict-swiftmodule-to-revision.swift - - # This test was flaky in ofborg, see #186476 - rm swift/test/AutoDiff/compiler_crashers_fixed/issue-56649-missing-debug-scopes-in-pullback-trampoline.swift - - patchShebangs . - - ${lib.optionalString (!stdenv.hostPlatform.isDarwin) '' - patch -p1 -d swift-corelibs-libdispatch -i ${ - # Fix the build with modern Clang. - fetchpatch { - url = "https://github.com/swiftlang/swift-corelibs-libdispatch/commit/30bb8019ba79cdae0eb1dc0c967c17996dd5cc0a.patch"; - hash = "sha256-wPZQ4wtEWk8HaKMfzjamlU6p/IW5EFiTssY63rGM+ZA="; - } - } - patch -p1 -d swift-corelibs-libdispatch -i ${ - # Fix the build with modern Clang. - fetchpatch { - url = "https://github.com/swiftlang/swift-corelibs-libdispatch/commit/38872e2d44d66d2fb94186988509defc734888a5.patch"; - hash = "sha256-GABwDeTjciV36Sa0FS10mCfFCqRoBBstgW/OiKdPahA="; - } - } - ''} - ''; - - # > clang-15-unwrapped: error: unsupported option '-fzero-call-used-regs=used-gpr' for target 'arm64-apple-macosx10.9.0' - # > clang-15-unwrapped: error: argument unused during compilation: '-fstack-clash-protection' [-Werror,-Wunused-command-line-argument] - hardeningDisable = lib.optionals stdenv.hostPlatform.isAarch64 [ - "zerocallusedregs" - "stackclashprotection" - ]; - - configurePhase = '' - export SWIFT_SOURCE_ROOT="$PWD" - mkdir -p ../build - cd ../build - export SWIFT_BUILD_ROOT="$PWD" - ''; - - # These steps are derived from doing a normal build with. - # - # ./swift/utils/build-toolchain test --dry-run - # - # But dealing with the custom Python build system is far more trouble than - # simply invoking CMake directly. Few variables it passes to CMake are - # actually required or non-default. - # - # Using CMake directly also allows us to split up the already large build, - # and package Swift components separately. - # - # Besides `--dry-run`, another good way to compare build changes between - # Swift releases is to diff the scripts: - # - # git diff swift-5.6.3-RELEASE..swift-5.7-RELEASE -- utils/build* - # - buildPhase = '' - # Helper to build a subdirectory. - # - # Always reset cmakeFlags before calling this. The cmakeConfigurePhase - # amends flags and would otherwise keep expanding it. - function buildProject() { - mkdir -p $SWIFT_BUILD_ROOT/$1 - cd $SWIFT_BUILD_ROOT/$1 - - cmakeDir=$SWIFT_SOURCE_ROOT/''${2-$1} - cmakeConfigurePhase - - ninjaBuildPhase - } - - cmakeFlags="-GNinja" - buildProject swift-cmark - - ${lib.optionalString (clang.libcxx != null) '' - # Install the libc++ headers corresponding to the LLVM version of - # Swift’s Clang. - cmakeFlags=" - -GNinja - -DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi - -DLIBCXXABI_INSTALL_INCLUDE_DIR=$dev/include/c++/v1 - " - ninjaFlags="install-cxx-headers install-cxxabi-headers" - buildProject libcxx llvm-project/runtimes - unset ninjaFlags - ''} - - # Some notes: - # - The Swift build just needs Clang. - # - We can further reduce targets to just our targetPlatform. - cmakeFlags=" - -GNinja - -DLLVM_BUILD_TOOLS=NO - -DLLVM_ENABLE_PROJECTS=clang - -DLLVM_TARGETS_TO_BUILD=${ - { - "x86_64" = "X86"; - "aarch64" = "AArch64"; - } - .${targetPlatform.parsed.cpu.name} - or (throw "Unsupported CPU architecture: ${targetPlatform.parsed.cpu.name}") - } - " - buildProject llvm llvm-project/llvm - - # Ensure that the built Clang can find the runtime libraries by - # copying the symlinks from the main wrapper. - cp -P ${clang}/resource-root/{lib,share} $SWIFT_BUILD_ROOT/llvm/lib/clang/16.0.0/ - - '' - + lib.optionalString stdenv.hostPlatform.isDarwin '' - # Add appleSwiftCore to the search paths. Adding the whole SDK results in build failures. - OLD_NIX_SWIFTFLAGS_COMPILE="$NIX_SWIFTFLAGS_COMPILE" - OLD_NIX_LDFLAGS="$NIX_LDFLAGS" - OLD_NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE" - export NIX_SWIFTFLAGS_COMPILE=" -I ${appleSwiftCore}/lib/swift" - export NIX_LDFLAGS+=" -L ${appleSwiftCore}/lib/swift" - export NIX_CFLAGS_COMPILE+=" -Wno-error=unguarded-availability" - '' - + '' - - # Some notes: - # - BOOTSTRAPPING_MODE defaults to OFF in CMake, but is enabled in standard - # builds, so we enable it as well. On Darwin, we have to use the system - # Swift libs because of ABI-stability, but this may be trouble if the - # builder is an older macOS. - # - Experimental features are OFF by default in CMake, but are enabled in - # official builds, so we do the same. (Concurrency is also required in - # the stdlib. StringProcessing is often implicitely imported, causing - # lots of warnings if missing.) - # - SWIFT_STDLIB_ENABLE_OBJC_INTEROP is set explicitely because its check - # is buggy. (Uses SWIFT_HOST_VARIANT_SDK before initialized.) - # Fixed in: https://github.com/apple/swift/commit/84083afef1de5931904d5c815d53856cdb3fb232 - cmakeFlags=" - -GNinja - -DBOOTSTRAPPING_MODE=BOOTSTRAPPING${lib.optionalString stdenv.hostPlatform.isDarwin "-WITH-HOSTLIBS"} - -DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=ON - -DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=ON - -DSWIFT_ENABLE_EXPERIMENTAL_CXX_INTEROP=ON - -DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=ON - -DSWIFT_ENABLE_EXPERIMENTAL_STRING_PROCESSING=ON - -DSWIFT_ENABLE_BACKTRACING=ON - -DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION=ON - -DLLVM_DIR=$SWIFT_BUILD_ROOT/llvm/lib/cmake/llvm - -DClang_DIR=$SWIFT_BUILD_ROOT/llvm/lib/cmake/clang - -DSWIFT_PATH_TO_CMARK_SOURCE=$SWIFT_SOURCE_ROOT/swift-cmark - -DSWIFT_PATH_TO_CMARK_BUILD=$SWIFT_BUILD_ROOT/swift-cmark - -DSWIFT_PATH_TO_LIBDISPATCH_SOURCE=$SWIFT_SOURCE_ROOT/swift-corelibs-libdispatch - -DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=$SWIFT_SOURCE_ROOT/swift-syntax - -DSWIFT_PATH_TO_STRING_PROCESSING_SOURCE=$SWIFT_SOURCE_ROOT/swift-experimental-string-processing - -DSWIFT_INSTALL_COMPONENTS=${lib.concatStringsSep ";" swiftInstallComponents} - -DSWIFT_STDLIB_ENABLE_OBJC_INTEROP=${if stdenv.hostPlatform.isDarwin then "ON" else "OFF"} - -DSWIFT_DARWIN_DEPLOYMENT_VERSION_OSX=${deploymentVersion} - " - buildProject swift - - '' - + lib.optionalString stdenv.hostPlatform.isDarwin '' - # Restore search paths to remove appleSwiftCore. - export NIX_SWIFTFLAGS_COMPILE="$OLD_NIX_SWIFTFLAGS_COMPILE" - export NIX_LDFLAGS="$OLD_NIX_LDFLAGS" - export NIX_CFLAGS_COMPILE="$OLD_NIX_CFLAGS_COMPILE" - '' - + '' - - # These are based on flags in `utils/build-script-impl`. - # - # LLDB_USE_SYSTEM_DEBUGSERVER=ON disables the debugserver build on Darwin, - # which requires a special signature. - # - # CMAKE_BUILD_WITH_INSTALL_NAME_DIR ensures we don't use rpath on Darwin. - cmakeFlags=" - -GNinja - -DLLDB_SWIFTC=$SWIFT_BUILD_ROOT/swift/bin/swiftc - -DLLDB_SWIFT_LIBS=$SWIFT_BUILD_ROOT/swift/lib/swift - -DLLVM_DIR=$SWIFT_BUILD_ROOT/llvm/lib/cmake/llvm - -DClang_DIR=$SWIFT_BUILD_ROOT/llvm/lib/cmake/clang - -DSwift_DIR=$SWIFT_BUILD_ROOT/swift/lib/cmake/swift - -DLLDB_ENABLE_CURSES=ON - -DLLDB_ENABLE_LIBEDIT=ON - -DLLDB_ENABLE_PYTHON=ON - -DLLDB_ENABLE_LZMA=OFF - -DLLDB_ENABLE_LUA=OFF - -DLLDB_INCLUDE_TESTS=OFF - -DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON - ${lib.optionalString stdenv.hostPlatform.isDarwin '' - -DLLDB_USE_SYSTEM_DEBUGSERVER=ON - ''} - -DLibEdit_INCLUDE_DIRS=${lib.getInclude libedit}/include - -DLibEdit_LIBRARIES=${lib.getLib libedit}/lib/libedit${stdenv.hostPlatform.extensions.sharedLibrary} - -DCURSES_INCLUDE_DIRS=${lib.getInclude ncurses}/include - -DCURSES_LIBRARIES=${lib.getLib ncurses}/lib/libncurses${stdenv.hostPlatform.extensions.sharedLibrary} - -DPANEL_LIBRARIES=${lib.getLib ncurses}/lib/libpanel${stdenv.hostPlatform.extensions.sharedLibrary} - "; - buildProject lldb llvm-project/lldb - - ${lib.optionalString stdenv.targetPlatform.isDarwin '' - # Need to do a standalone build of concurrency for Darwin back deployment. - # Based on: utils/swift_build_support/swift_build_support/products/backdeployconcurrency.py - cmakeFlags=" - -GNinja - -DCMAKE_Swift_COMPILER=$SWIFT_BUILD_ROOT/swift/bin/swiftc - -DSWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE=$SWIFT_SOURCE_ROOT/swift-syntax - - -DTOOLCHAIN_DIR=/var/empty - -DSWIFT_NATIVE_LLVM_TOOLS_PATH=${stdenv.cc}/bin - -DSWIFT_NATIVE_CLANG_TOOLS_PATH=${stdenv.cc}/bin - -DSWIFT_NATIVE_SWIFT_TOOLS_PATH=$SWIFT_BUILD_ROOT/swift/bin - - -DCMAKE_CROSSCOMPILING=ON - - -DBUILD_SWIFT_CONCURRENCY_BACK_DEPLOYMENT_LIBRARIES=ON - -DSWIFT_INCLUDE_TOOLS=OFF - -DSWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT=OFF - -DSWIFT_BUILD_TEST_SUPPORT_MODULES=OFF - -DSWIFT_BUILD_STDLIB=OFF - -DSWIFT_BUILD_DYNAMIC_STDLIB=OFF - -DSWIFT_BUILD_STATIC_STDLIB=OFF - -DSWIFT_BUILD_REMOTE_MIRROR=OFF - -DSWIFT_BUILD_SDK_OVERLAY=OFF - -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY=OFF - -DSWIFT_BUILD_STATIC_SDK_OVERLAY=OFF - -DSWIFT_INCLUDE_TESTS=OFF - -DSWIFT_BUILD_PERF_TESTSUITE=OFF - - -DSWIFT_HOST_VARIANT_ARCH=${swiftArch} - -DBUILD_STANDALONE=ON - - -DSWIFT_INSTALL_COMPONENTS=back-deployment - - -DSWIFT_SDKS=${ - { - "macos" = "OSX"; - "ios" = "IOS"; - #IOS_SIMULATOR - #TVOS - #TVOS_SIMULATOR - #WATCHOS - #WATCHOS_SIMULATOR - } - .${targetPlatform.darwinPlatform} - } - - -DLLVM_DIR=$SWIFT_BUILD_ROOT/llvm/lib/cmake/llvm - - -DSWIFT_DEST_ROOT=$out - -DSWIFT_HOST_VARIANT_SDK=OSX - - -DSWIFT_DARWIN_DEPLOYMENT_VERSION_OSX=${deploymentVersion} - -DSWIFT_DARWIN_DEPLOYMENT_VERSION_IOS=13.0 - -DSWIFT_DARWIN_DEPLOYMENT_VERSION_MACCATALYST=13.0 - -DSWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS=13.0 - -DSWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS=6.0 - " - - # This depends on the special Clang build specific to the Swift branch. - # We also need to call a specific Ninja target. - export CC=$SWIFT_BUILD_ROOT/llvm/bin/clang - export CXX=$SWIFT_BUILD_ROOT/llvm/bin/clang++ - ninjaFlags="back-deployment" - - buildProject swift-concurrency-backdeploy swift - - export CC=$NIX_CC/bin/clang - export CXX=$NIX_CC/bin/clang++ - unset ninjaFlags - ''} - ''; - - # TODO: ~50 failing tests on x86_64-linux. Other platforms not checked. - doCheck = false; - nativeCheckInputs = [ file ]; - # TODO: consider using stress-tester and integration-test. - checkPhase = '' - cd $SWIFT_BUILD_ROOT/swift - checkTarget=check-swift-all - ninjaCheckPhase - unset checkTarget - ''; - - installPhase = '' - # Undo the clang and swift wrapping we did for the build. - # (This happened via patches to cmake files.) - cd $SWIFT_BUILD_ROOT - mv llvm/bin/clang-16{-unwrapped,} - mv swift/bin/swift-frontend{-unwrapped,} - - mkdir $lib - - # Install clang binaries only. We hide these with the wrapper, so they are - # for private use by Swift only. - cd $SWIFT_BUILD_ROOT/llvm - installTargets=install-clang - ninjaInstallPhase - unset installTargets - - # LLDB is also a private install. - cd $SWIFT_BUILD_ROOT/lldb - ninjaInstallPhase - - cd $SWIFT_BUILD_ROOT/swift - ninjaInstallPhase - - ${lib.optionalString stdenv.hostPlatform.isDarwin '' - cd $SWIFT_BUILD_ROOT/swift-concurrency-backdeploy - installTargets=install-back-deployment - ninjaInstallPhase - unset installTargets - ''} - - # Separate $lib output here, because specific logic follows. - # Only move the dynamic run-time parts, to keep $lib small. Every Swift - # build will depend on it. - moveToOutput "lib/swift" "$lib" - moveToOutput "lib/libswiftDemangle.*" "$lib" - - # This link is here because various tools (swiftpm) check for stdlib - # relative to the swift compiler. It's fine if this is for build-time - # stuff, but we should patch all cases were it would end up in an output. - ln -s $lib/lib/swift $out/lib/swift - - # Swift has a separate resource root from Clang, but locates the Clang - # resource root via subdir or symlink. - mv $SWIFT_BUILD_ROOT/llvm/lib/clang/16.0.0 $lib/lib/swift/clang - ''; - - preFixup = lib.optionalString stdenv.hostPlatform.isLinux '' - # This is cheesy, but helps the patchelf hook remove /build from RPATH. - cd $SWIFT_BUILD_ROOT/.. - mv build buildx - ''; - - postFixup = lib.optionalString stdenv.hostPlatform.isDarwin '' - # These libraries need to use the system install name. The official SDK - # does the same (as opposed to using rpath). Presumably, they are part of - # the stable ABI. Not using the system libraries at run-time is known to - # cause ObjC class conflicts and segfaults. - declare -A systemLibs=( - [libswiftCore.dylib]=1 - [libswiftDarwin.dylib]=1 - [libswiftSwiftOnoneSupport.dylib]=1 - [libswift_Concurrency.dylib]=1 - ) - - for systemLib in "''${!systemLibs[@]}"; do - install_name_tool -id /usr/lib/swift/$systemLib $lib/${swiftLibSubdir}/$systemLib - done - - for file in $out/bin/swift-frontend $lib/${swiftLibSubdir}/*.dylib; do - changeArgs="" - for dylib in $(otool -L $file | awk '{ print $1 }'); do - if [[ ''${systemLibs["$(basename $dylib)"]} ]]; then - changeArgs+=" -change $dylib /usr/lib/swift/$(basename $dylib)" - elif [[ "$dylib" = */bootstrapping1/* ]]; then - changeArgs+=" -change $dylib $lib/lib/swift/$(basename $dylib)" - fi - done - if [[ -n "$changeArgs" ]]; then - install_name_tool $changeArgs $file - fi - done - - wrapProgram $out/bin/swift-frontend \ - --prefix PATH : ${lib.makeBinPath [ cctools.libtool ]} - - # Needs to be propagated by the compiler not by its dev output. - moveToOutput nix-support/propagated-target-target-deps "$out" - ''; - - passthru = { - inherit - swiftOs - swiftArch - swiftModuleSubdir - swiftLibSubdir - swiftStaticModuleSubdir - swiftStaticLibSubdir - ; - - tests = { - cxx-interop-test = callPackage ../cxx-interop-test { }; - }; - - # Internal attr for the wrapper. - _wrapperParams = wrapperParams; - }; - - meta = { - description = "Swift Programming Language"; - homepage = "https://github.com/apple/swift"; - teams = [ lib.teams.swift ]; - license = lib.licenses.asl20; - platforms = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - # Swift doesn't support 32-bit Linux, unknown on other platforms. - badPlatforms = lib.platforms.i686; - timeout = 86400; # 24 hours. - }; -} diff --git a/pkgs/development/compilers/swift/compiler/patches/clang-purity.patch b/pkgs/development/compilers/swift/compiler/patches/clang-purity.patch deleted file mode 100644 index dcb7771008d9..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/clang-purity.patch +++ /dev/null @@ -1,21 +0,0 @@ -From 4add81bba40dcec62c4ea4481be8e35ac53e89d8 Mon Sep 17 00:00:00 2001 -From: Will Dietz -Date: Thu, 18 May 2017 11:56:12 -0500 -Subject: [PATCH] "purity" patch for 5.0 - ---- clang/lib/Driver/ToolChains/Gnu.cpp -+++ clang/lib/Driver/ToolChains/Gnu.cpp -@@ -480,13 +480,6 @@ - } else { - if (Args.hasArg(options::OPT_rdynamic)) - CmdArgs.push_back("-export-dynamic"); -- -- if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE && -- !Args.hasArg(options::OPT_r)) { -- CmdArgs.push_back("-dynamic-linker"); -- CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) + -- ToolChain.getDynamicLinker(Args))); -- } - } - - CmdArgs.push_back("-o"); diff --git a/pkgs/development/compilers/swift/compiler/patches/clang-toolchain-dir.patch b/pkgs/development/compilers/swift/compiler/patches/clang-toolchain-dir.patch deleted file mode 100644 index 40d7728cf788..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/clang-toolchain-dir.patch +++ /dev/null @@ -1,13 +0,0 @@ -Use the Nix include dirs and gcc runtime dir, when no sysroot is configured. - ---- a/lib/Driver/ToolChains/Linux.cpp -+++ b/lib/Driver/ToolChains/Linux.cpp -@@ -574,7 +574,7 @@ - - // Check for configure-time C include directories. - StringRef CIncludeDirs(C_INCLUDE_DIRS); -- if (CIncludeDirs != "") { -+ if (CIncludeDirs != "" && (SysRoot.empty() || SysRoot == "/")) { - SmallVector dirs; - CIncludeDirs.split(dirs, ":"); - for (StringRef dir : dirs) { diff --git a/pkgs/development/compilers/swift/compiler/patches/clang-wrap.patch b/pkgs/development/compilers/swift/compiler/patches/clang-wrap.patch deleted file mode 100644 index 9c6cafed3699..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/clang-wrap.patch +++ /dev/null @@ -1,18 +0,0 @@ -Wrap the clang produced during the build - ---- a/tools/driver/CMakeLists.txt -+++ b/tools/driver/CMakeLists.txt -@@ -59,6 +59,13 @@ endif() - - add_dependencies(clang clang-resource-headers) - -+# Nix: wrap the clang build. -+add_custom_command( -+ TARGET clang POST_BUILD -+ COMMAND nix-swift-make-clang-wrapper $ -+ VERBATIM -+) -+ - if(NOT CLANG_LINKS_TO_CREATE) - set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp) - endif() diff --git a/pkgs/development/compilers/swift/compiler/patches/llvm-fix-X86MCTargetDesc-compile-error.patch b/pkgs/development/compilers/swift/compiler/patches/llvm-fix-X86MCTargetDesc-compile-error.patch deleted file mode 100644 index 3ced4d2c32b8..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/llvm-fix-X86MCTargetDesc-compile-error.patch +++ /dev/null @@ -1,34 +0,0 @@ -From f03ab75680385b1ea62af3ab15c423a3bc0f3588 Mon Sep 17 00:00:00 2001 -From: Stephan Hageboeck -Date: Mon, 20 Jan 2025 17:52:47 +0100 -Subject: [PATCH] Add missing include to X86MCTargetDesc.h (#123320) - -In gcc-15, explicit includes of `` are required when fixed-size -integers are used. In this file, this include only happened as a side -effect of including SmallVector.h - -Although llvm compiles fine, the root-project would benefit from -explicitly including it here, so we can backport the patch. - -Maybe interesting for @hahnjo and @vgvassilev - -(cherry picked from commit 7abf44069aec61eee147ca67a6333fc34583b524) ---- - llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h -index d0530bd4d650..10b59462aebe 100644 ---- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h -+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h -@@ -13,6 +13,7 @@ - #ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H - #define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H - -+#include - #include - #include - --- -2.52.0 - diff --git a/pkgs/development/compilers/swift/compiler/patches/llvm-module-cache.patch b/pkgs/development/compilers/swift/compiler/patches/llvm-module-cache.patch deleted file mode 100644 index 9a22d0482ea5..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/llvm-module-cache.patch +++ /dev/null @@ -1,30 +0,0 @@ -The compiler fails if LLVM modules are enabled and it cannot write its module -cache. This patch detects and rejects the fake, non-existant $HOME used in Nix -builds. - -We could simply return false in `cache_directory`, but that completely disables -module caching, and may unnecessarily slow down builds. Instead, let it use -'/tmp/.cache'. - ---- a/lib/Support/Unix/Path.inc -+++ b/lib/Support/Unix/Path.inc -@@ -1380,6 +1380,9 @@ bool user_config_directory(SmallVectorImpl &result) { - if (!home_directory(result)) { - return false; - } -+ if (std::equal(result.begin(), result.end(), "/homeless-shelter")) { -+ return false; -+ } - append(result, ".config"); - return true; - } -@@ -1401,6 +1404,9 @@ bool cache_directory(SmallVectorImpl &result) { - if (!home_directory(result)) { - return false; - } -+ if (std::equal(result.begin(), result.end(), "/homeless-shelter")) { -+ system_temp_directory(true/*ErasedOnReboot*/, result); -+ } - append(result, ".cache"); - return true; - } diff --git a/pkgs/development/compilers/swift/compiler/patches/swift-Frontend-Fix-a-small-unique_ptr-array-access.patch b/pkgs/development/compilers/swift/compiler/patches/swift-Frontend-Fix-a-small-unique_ptr-array-access.patch deleted file mode 100644 index 0059c7f7c9ee..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/swift-Frontend-Fix-a-small-unique_ptr-array-access.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 1a2293c7593e4eeb3fbad74fa8d362abafb43b56 Mon Sep 17 00:00:00 2001 -From: Tony Allevato -Date: Wed, 9 Oct 2024 13:54:43 -0400 -Subject: [PATCH] [Frontend] Fix a small `unique_ptr` array access. - -When the size of the array accessed here is zero, retrieving the -address of the zero-th element here is undefined. When the frontend -is linked against a libc++ that has the `unique_ptr` hardening in -[this commit](https://github.com/llvm/llvm-project/commit/18df9d23ea390eaa50b41f3083a42f700a2b0e39) -enabled, it traps here. - -Instead, simply call `.get()` to retrieve the address of the -array, which works even when it is a zero-byte allocation. - -(cherry picked from commit bdf40184ab40eb59642cd825781d71d0711493eb) ---- - lib/FrontendTool/FrontendTool.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp -index afbc57cdf2f..ba64a306494 100644 ---- a/lib/FrontendTool/FrontendTool.cpp -+++ b/lib/FrontendTool/FrontendTool.cpp -@@ -2202,7 +2202,7 @@ int swift::performFrontend(ArrayRef Args, - std::make_unique[]>( - configurationFileBuffers.size()); - for_each(configurationFileBuffers.begin(), configurationFileBuffers.end(), -- &configurationFileStackTraces[0], -+ configurationFileStackTraces.get(), - [](const std::unique_ptr &buffer, - llvm::Optional &trace) { - trace.emplace(*buffer); --- -2.52.0 - diff --git a/pkgs/development/compilers/swift/compiler/patches/swift-darwin-plistbuddy-workaround.patch b/pkgs/development/compilers/swift/compiler/patches/swift-darwin-plistbuddy-workaround.patch deleted file mode 100644 index a3cf4f60675c..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/swift-darwin-plistbuddy-workaround.patch +++ /dev/null @@ -1,17 +0,0 @@ -CMake tries to read a list field from SDKSettings.plist, but the output of -facebook/xcbuild PlistBuddy is incompatible with Apple's. - -Simply set the supported architectures to the one target architecture we're -building for. - ---- a/cmake/modules/SwiftConfigureSDK.cmake -+++ b/cmake/modules/SwiftConfigureSDK.cmake -@@ -189,7 +189,7 @@ macro(configure_sdk_darwin - endif() - - # Remove any architectures not supported by the SDK. -- remove_sdk_unsupported_archs(${name} ${xcrun_name} ${SWIFT_SDK_${prefix}_PATH} SWIFT_SDK_${prefix}_ARCHITECTURES) -+ set(SWIFT_SDK_${prefix}_ARCHITECTURES "@swiftArch@") - - list_intersect( - "${SWIFT_DARWIN_MODULE_ARCHS}" # lhs diff --git a/pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-libc-paths.patch b/pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-libc-paths.patch deleted file mode 100644 index 61915c66f503..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-libc-paths.patch +++ /dev/null @@ -1,48 +0,0 @@ -This code injects an LLVM modulemap for glibc and libstdc++ by overriding -specific VFS paths. In order to do that, it needs to know the actual locations -of glibc and libstdc++, but it only searches `-sysroot` and fails. Here we -patch it to also consider `-idirafter` and `-isystem` as added by cc-wrapper. - ---- a/lib/ClangImporter/ClangIncludePaths.cpp -+++ b/lib/ClangImporter/ClangIncludePaths.cpp -@@ -142,6 +142,7 @@ - /// \return a path without dots (`../`, './'). - static llvm::Optional findFirstIncludeDir( - const llvm::opt::InputArgList &args, -+ const llvm::opt::ArgList &DriverArgs, - const ArrayRef expectedFileNames, - const llvm::IntrusiveRefCntPtr &vfs) { - // C++ stdlib paths are added as `-internal-isystem`. -@@ -151,6 +152,14 @@ - llvm::append_range(includeDirs, - args.getAllArgValues( - clang::driver::options::OPT_internal_externc_isystem)); -+ // Nix adds the C stdlib include path using `-idirafter`. -+ llvm::append_range(includeDirs, -+ DriverArgs.getAllArgValues( -+ clang::driver::options::OPT_idirafter)); -+ // Nix adds the C++ stdlib include path using `-cxx-isystem`. -+ llvm::append_range(includeDirs, -+ DriverArgs.getAllArgValues( -+ clang::driver::options::OPT_cxx_isystem)); - - for (const auto &includeDir : includeDirs) { - Path dir(includeDir); -@@ -218,7 +227,7 @@ - // modulemap are present. - Path glibcDir; - if (auto dir = findFirstIncludeDir( -- parsedIncludeArgs, {"inttypes.h", "unistd.h", "stdint.h"}, vfs)) { -+ parsedIncludeArgs, clangDriverArgs, {"inttypes.h", "unistd.h", "stdint.h"}, vfs)) { - glibcDir = dir.value(); - } else { - ctx.Diags.diagnose(SourceLoc(), diag::glibc_not_found, triple.str()); -@@ -276,7 +285,7 @@ - auto parsedStdlibArgs = parseClangDriverArgs(clangDriver, stdlibArgStrings); - - Path cxxStdlibDir; -- if (auto dir = findFirstIncludeDir(parsedStdlibArgs, -+ if (auto dir = findFirstIncludeDir(parsedStdlibArgs, clangDriverArgs, - {"cstdlib", "string", "vector"}, vfs)) { - cxxStdlibDir = dir.value(); - } else { diff --git a/pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-linking.patch b/pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-linking.patch deleted file mode 100644 index c10b4038a9c4..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-linking.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp -index c0ee9217e8..bf7737d6fa 100644 ---- a/lib/Driver/ToolChains.cpp -+++ b/lib/Driver/ToolChains.cpp -@@ -1489,6 +1489,12 @@ - LinkerDriver = Args.MakeArgString(tool.get()); - } - -+ // For Nix, prefer linking using the wrapped Nixpkgs clang, instead of using -+ // the unwrapped clang packaged with swift. The latter is unable to link, but -+ // we still want to use it for other purposes (clang importer). -+ if (auto tool = llvm::sys::findProgramByName(LinkerDriver, {"@clang@/bin"})) -+ return Args.MakeArgString(tool.get()); -+ - return LinkerDriver; - } - diff --git a/pkgs/development/compilers/swift/compiler/patches/swift-prevent-sdk-dirs-warning.patch b/pkgs/development/compilers/swift/compiler/patches/swift-prevent-sdk-dirs-warning.patch deleted file mode 100644 index 987b99d74539..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/swift-prevent-sdk-dirs-warning.patch +++ /dev/null @@ -1,39 +0,0 @@ -Prevents a user-visible warning on every compilation: - - ld: warning: directory not found for option '-L.../MacOSX11.0.sdk/usr/lib/swift' - ---- a/lib/Driver/ToolChains.cpp -+++ b/lib/Driver/ToolChains.cpp -@@ -1455,9 +1455,11 @@ void ToolChain::getRuntimeLibraryPaths(SmallVectorImpl &runtimeLibP - runtimeLibPaths.push_back(std::string(scratchPath.str())); - } - -+ if (!SDKPath.startswith("@storeDir@")) { - scratchPath = SDKPath; - llvm::sys::path::append(scratchPath, "usr", "lib", "swift"); - runtimeLibPaths.push_back(std::string(scratchPath.str())); -+ } - } - } - ---- a/lib/Frontend/CompilerInvocation.cpp -+++ b/lib/Frontend/CompilerInvocation.cpp -@@ -185,7 +185,9 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts, - RuntimeLibraryImportPaths.push_back(std::string(LibPath.str())); - } - -- LibPath = SearchPathOpts.getSDKPath(); -+ auto SDKPath = SearchPathOpts.getSDKPath(); -+ if (!SDKPath.startswith("@storeDir@")) { -+ LibPath = SDKPath; - llvm::sys::path::append(LibPath, "usr", "lib", "swift"); - if (!Triple.isOSDarwin()) { - // Use the non-architecture suffixed form with directory-layout -@@ -200,6 +202,7 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts, - llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple)); - } - RuntimeLibraryImportPaths.push_back(std::string(LibPath.str())); -+ } - } - SearchPathOpts.setRuntimeLibraryImportPaths(RuntimeLibraryImportPaths); - } diff --git a/pkgs/development/compilers/swift/compiler/patches/swift-separate-lib.patch b/pkgs/development/compilers/swift/compiler/patches/swift-separate-lib.patch deleted file mode 100644 index 20d81a6e8296..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/swift-separate-lib.patch +++ /dev/null @@ -1,26 +0,0 @@ -Patch paths to use the separate 'lib' output. One of the things this patch -fixes is the output of `swift -frontend -print-target-info`, which swiftpm uses -to set rpath on Linux. - -The check if the executable path starts with 'out' is necessary for -bootstrapping, or the compiler will fail when run from the build directory. - ---- a/lib/Frontend/CompilerInvocation.cpp -+++ b/lib/Frontend/CompilerInvocation.cpp -@@ -49,11 +49,16 @@ swift::CompilerInvocation::CompilerInvocation() { - void CompilerInvocation::computeRuntimeResourcePathFromExecutablePath( - StringRef mainExecutablePath, bool shared, - llvm::SmallVectorImpl &runtimeResourcePath) { -+ if (mainExecutablePath.startswith("@storeDir@")) { -+ auto libPath = StringRef("@lib@"); -+ runtimeResourcePath.append(libPath.begin(), libPath.end()); -+ } else { - runtimeResourcePath.append(mainExecutablePath.begin(), - mainExecutablePath.end()); - - llvm::sys::path::remove_filename(runtimeResourcePath); // Remove /swift - llvm::sys::path::remove_filename(runtimeResourcePath); // Remove /bin -+ } - appendSwiftLibDir(runtimeResourcePath, shared); - } - diff --git a/pkgs/development/compilers/swift/compiler/patches/swift-wrap.patch b/pkgs/development/compilers/swift/compiler/patches/swift-wrap.patch deleted file mode 100644 index e4697f631e70..000000000000 --- a/pkgs/development/compilers/swift/compiler/patches/swift-wrap.patch +++ /dev/null @@ -1,46 +0,0 @@ -Wrap the swift compiler produced during the build - ---- a/tools/driver/CMakeLists.txt -+++ b/tools/driver/CMakeLists.txt -@@ -16,6 +16,13 @@ if(${LIBSWIFT_BUILD_MODE} MATCHES "BOOTSTRAPPING.*") - swiftDriverTool - libswiftStub) - -+ # Nix: wrap the swift build. -+ add_custom_command( -+ TARGET swift-frontend-bootstrapping0 POST_BUILD -+ COMMAND nix-swift-make-swift-wrapper $ -+ VERBATIM -+ ) -+ - swift_create_post_build_symlink(swift-frontend-bootstrapping0 - SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}" - DESTINATION "swiftc${CMAKE_EXECUTABLE_SUFFIX}" -@@ -34,6 +41,13 @@ if(${LIBSWIFT_BUILD_MODE} MATCHES "BOOTSTRAPPING.*") - swiftDriverTool - libswift-bootstrapping1) - -+ # Nix: wrap the swift build. -+ add_custom_command( -+ TARGET swift-frontend-bootstrapping1 POST_BUILD -+ COMMAND nix-swift-make-swift-wrapper $ -+ VERBATIM -+ ) -+ - swift_create_post_build_symlink(swift-frontend-bootstrapping1 - SOURCE "swift-frontend${CMAKE_EXECUTABLE_SUFFIX}" - DESTINATION "swiftc${CMAKE_EXECUTABLE_SUFFIX}" -@@ -50,6 +64,13 @@ target_link_libraries(swift-frontend - swiftDriverTool - libswift) - -+# Nix: wrap the swift build. -+add_custom_command( -+ TARGET swift-frontend POST_BUILD -+ COMMAND nix-swift-make-swift-wrapper $ -+ VERBATIM -+) -+ - # Create a `swift-driver` executable adjacent to the `swift-frontend` executable - # to ensure that `swiftc` forwards to the standalone driver when invoked. - swift_create_early_driver_copies(swift-frontend) diff --git a/pkgs/development/compilers/swift/cxx-interop-test/default.nix b/pkgs/development/compilers/swift/cxx-interop-test/default.nix deleted file mode 100644 index 12640750d622..000000000000 --- a/pkgs/development/compilers/swift/cxx-interop-test/default.nix +++ /dev/null @@ -1,57 +0,0 @@ -{ - lib, - stdenv, - swift, - swiftpm, - swiftPackages, -}: - -swiftPackages.stdenv.mkDerivation (finalAttrs: { - name = "swift-cxx-interop-test"; - - src = ./src; - - nativeBuildInputs = [ - swift - swiftpm - ]; - - installPhase = '' - runHook preInstall - - binPath="$(swiftpmBinPath)" - mkdir -p -- "$out/bin" - cp -- "$binPath/${finalAttrs.meta.mainProgram}" "$out/bin" - - runHook postInstall - ''; - - installCheckPhase = '' - runHook preInstallCheck - - "$out/bin/${finalAttrs.meta.mainProgram}" | grep 'Hello, world!' - - runHook postInstallCheck - ''; - - doInstallCheck = true; - - env = { - # Gross hack copied from `protoc-gen-swift` :( - LD_LIBRARY_PATH = lib.optionalString stdenv.hostPlatform.isLinux ( - lib.makeLibraryPath [ - swiftPackages.Dispatch - ] - ); - }; - - meta = { - inherit (swift.meta) - team - platforms - badPlatforms - ; - license = lib.licenses.mit; - mainProgram = "CxxInteropTest"; - }; -}) diff --git a/pkgs/development/compilers/swift/cxx-interop-test/src/.gitignore b/pkgs/development/compilers/swift/cxx-interop-test/src/.gitignore deleted file mode 100644 index 3b29812086f2..000000000000 --- a/pkgs/development/compilers/swift/cxx-interop-test/src/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.DS_Store -/.build -/Packages -/*.xcodeproj -xcuserdata/ -DerivedData/ -.swiftpm/config/registries.json -.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata -.netrc diff --git a/pkgs/development/compilers/swift/cxx-interop-test/src/Package.swift b/pkgs/development/compilers/swift/cxx-interop-test/src/Package.swift deleted file mode 100644 index 4c664f22c467..000000000000 --- a/pkgs/development/compilers/swift/cxx-interop-test/src/Package.swift +++ /dev/null @@ -1,16 +0,0 @@ -// swift-tools-version: 5.10 - -import PackageDescription - -let package = Package( - name: "CxxInteropTest", - targets: [ - .executableTarget( - name: "CxxInteropTest", - path: "Sources", - swiftSettings: [ - .interoperabilityMode(.Cxx) - ] - ) - ] -) diff --git a/pkgs/development/compilers/swift/cxx-interop-test/src/Sources/main.swift b/pkgs/development/compilers/swift/cxx-interop-test/src/Sources/main.swift deleted file mode 100644 index abe1c879beba..000000000000 --- a/pkgs/development/compilers/swift/cxx-interop-test/src/Sources/main.swift +++ /dev/null @@ -1,3 +0,0 @@ -import CxxStdlib - -print(String(std.string("Hello, world!"))) diff --git a/pkgs/development/compilers/swift/default.nix b/pkgs/development/compilers/swift/default.nix deleted file mode 100644 index ad4fe81c46cb..000000000000 --- a/pkgs/development/compilers/swift/default.nix +++ /dev/null @@ -1,85 +0,0 @@ -{ - lib, - newScope, - stdenv, - llvmPackages, - darwin, -}: - -let - self = rec { - - callPackage = newScope self; - - # Provided for backwards compatibility. - inherit stdenv; - - swift-unwrapped = callPackage ./compiler { - inherit (llvmPackages) stdenv; - inherit (darwin) DarwinTools sigtool; - }; - - swiftNoSwiftDriver = callPackage ./wrapper { - swift = swift-unwrapped; - useSwiftDriver = false; - }; - - Dispatch = - if stdenv.hostPlatform.isDarwin then - null # part of apple-sdk - else - callPackage ./libdispatch { - inherit (llvmPackages) stdenv; - swift = swiftNoSwiftDriver; - }; - - Foundation = - if stdenv.hostPlatform.isDarwin then - null # part of apple-sdk - else - callPackage ./foundation { - inherit (llvmPackages) stdenv; - swift = swiftNoSwiftDriver; - }; - - # TODO: Apple distributes a binary XCTest with Xcode, but it is not part of - # CLTools (or SUS), so would have to figure out how to fetch it. The binary - # version has several extra features, like a test runner and ObjC support. - XCTest = callPackage ./xctest { - inherit (darwin) DarwinTools; - swift = swiftNoSwiftDriver; - }; - - swiftpm = callPackage ./swiftpm { - inherit (llvmPackages) stdenv; - inherit (darwin) DarwinTools; - swift = swiftNoSwiftDriver; - }; - - swift-driver = callPackage ./swift-driver { - inherit (llvmPackages) stdenv; - swift = swiftNoSwiftDriver; - }; - - swift = callPackage ./wrapper { - swift = swift-unwrapped; - }; - - sourcekit-lsp = callPackage ./sourcekit-lsp { - inherit (llvmPackages) stdenv; - }; - - swift-docc = callPackage ./swift-docc { - inherit (llvmPackages) stdenv; - }; - - swift-format = callPackage ./swift-format { - inherit (llvmPackages) stdenv; - }; - - swiftpm2nix = callPackage ./swiftpm2nix { }; - - }; - -in -self diff --git a/pkgs/development/compilers/swift/foundation/default.nix b/pkgs/development/compilers/swift/foundation/default.nix deleted file mode 100644 index 60d781ed7746..000000000000 --- a/pkgs/development/compilers/swift/foundation/default.nix +++ /dev/null @@ -1,71 +0,0 @@ -{ - lib, - stdenv, - fetchpatch, - callPackage, - cmake, - ninja, - swift, - Dispatch, - icu, - libxml2, - curl, -}: - -let - sources = callPackage ../sources.nix { }; -in -stdenv.mkDerivation { - pname = "swift-corelibs-foundation"; - - inherit (sources) version; - src = sources.swift-corelibs-foundation; - - outputs = [ - "out" - "dev" - ]; - - nativeBuildInputs = [ - cmake - ninja - swift - ]; - buildInputs = [ - icu - libxml2 - curl - ]; - propagatedBuildInputs = [ Dispatch ]; - - preConfigure = '' - # Fails to build with -D_FORTIFY_SOURCE. - NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/} - ''; - - postInstall = '' - # Split up the output. - mkdir $dev - mv $out/lib/swift/${swift.swiftOs} $out/swiftlibs - mv $out/lib/swift $dev/include - mkdir $out/lib/swift - mv $out/swiftlibs $out/lib/swift/${swift.swiftOs} - - # Provide a CMake module. This is primarily used to glue together parts of - # the Swift toolchain. Modifying the CMake config to do this for us is - # otherwise more trouble. - mkdir -p $dev/lib/cmake/Foundation - export dylibExt="${stdenv.hostPlatform.extensions.sharedLibrary}" - export swiftOs="${swift.swiftOs}" - substituteAll ${./glue.cmake} $dev/lib/cmake/Foundation/FoundationConfig.cmake - ''; - - meta = { - description = "Core utilities, internationalization, and OS independence for Swift"; - mainProgram = "plutil"; - homepage = "https://github.com/apple/swift-corelibs-foundation"; - platforms = lib.platforms.linux; - license = lib.licenses.asl20; - teams = [ lib.teams.swift ]; - }; -} diff --git a/pkgs/development/compilers/swift/foundation/glue.cmake b/pkgs/development/compilers/swift/foundation/glue.cmake deleted file mode 100644 index a34984d19f04..000000000000 --- a/pkgs/development/compilers/swift/foundation/glue.cmake +++ /dev/null @@ -1,8 +0,0 @@ -add_library(Foundation SHARED IMPORTED) -set_property(TARGET Foundation PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libFoundation@dylibExt@") - -add_library(FoundationNetworking SHARED IMPORTED) -set_property(TARGET FoundationNetworking PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libFoundationNetworking@dylibExt@") - -add_library(FoundationXML SHARED IMPORTED) -set_property(TARGET FoundationXML PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libFoundationXML@dylibExt@") diff --git a/pkgs/development/compilers/swift/libdispatch/default.nix b/pkgs/development/compilers/swift/libdispatch/default.nix deleted file mode 100644 index 3c99720ef75c..000000000000 --- a/pkgs/development/compilers/swift/libdispatch/default.nix +++ /dev/null @@ -1,68 +0,0 @@ -{ - lib, - stdenv, - callPackage, - fetchpatch, - cmake, - ninja, - useSwift ? true, - swift, -}: - -let - sources = callPackage ../sources.nix { }; -in -stdenv.mkDerivation { - pname = "swift-corelibs-libdispatch"; - - inherit (sources) version; - src = sources.swift-corelibs-libdispatch; - - outputs = [ - "out" - "dev" - "man" - ]; - - nativeBuildInputs = [ - cmake - ] - ++ lib.optionals useSwift [ - ninja - swift - ]; - - patches = [ - # Fix the build with modern Clang. - (fetchpatch { - url = "https://github.com/swiftlang/swift-corelibs-libdispatch/commit/30bb8019ba79cdae0eb1dc0c967c17996dd5cc0a.patch"; - hash = "sha256-wPZQ4wtEWk8HaKMfzjamlU6p/IW5EFiTssY63rGM+ZA="; - }) - (fetchpatch { - url = "https://github.com/swiftlang/swift-corelibs-libdispatch/commit/38872e2d44d66d2fb94186988509defc734888a5.patch"; - hash = "sha256-GABwDeTjciV36Sa0FS10mCfFCqRoBBstgW/OiKdPahA="; - }) - - ./disable-swift-overlay.patch - ]; - - cmakeFlags = lib.optional useSwift "-DENABLE_SWIFT=ON"; - - postInstall = '' - # Provide a CMake module. This is primarily used to glue together parts of - # the Swift toolchain. Modifying the CMake config to do this for us is - # otherwise more trouble. - mkdir -p $dev/lib/cmake/dispatch - export dylibExt="${stdenv.hostPlatform.extensions.sharedLibrary}" - substituteAll ${./glue.cmake} $dev/lib/cmake/dispatch/dispatchConfig.cmake - ''; - - meta = { - description = "Grand Central Dispatch"; - homepage = "https://github.com/swiftlang/swift-corelibs-libdispatch"; - platforms = lib.platforms.linux; - license = lib.licenses.asl20; - maintainers = with lib.maintainers; [ cmm ]; - teams = [ lib.teams.swift ]; - }; -} diff --git a/pkgs/development/compilers/swift/libdispatch/disable-swift-overlay.patch b/pkgs/development/compilers/swift/libdispatch/disable-swift-overlay.patch deleted file mode 100644 index 0ea1869d5528..000000000000 --- a/pkgs/development/compilers/swift/libdispatch/disable-swift-overlay.patch +++ /dev/null @@ -1,35 +0,0 @@ -Enabling Swift support is normally intended for building an overlay for a -Swift SDK, which changes the installation layout. Prevent this. - ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -287,7 +287,7 @@ configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in" - add_compile_definitions($<$,$>:HAVE_CONFIG_H>) - - --if(ENABLE_SWIFT) -+if(0) - set(INSTALL_TARGET_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$>:_static>/$" CACHE PATH "Path where the libraries will be installed") - set(INSTALL_DISPATCH_HEADERS_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$>:_static>/dispatch" CACHE PATH "Path where the headers will be installed for libdispatch") - set(INSTALL_BLOCK_HEADERS_DIR "${CMAKE_INSTALL_LIBDIR}/swift$<$>:_static>/Block" CACHE PATH "Path where the headers will be installed for the blocks runtime") ---- a/man/CMakeLists.txt -+++ b/man/CMakeLists.txt -@@ -1,6 +1,6 @@ - - # TODO(compnerd) add symlinks --if(NOT ENABLE_SWIFT) -+if(1) - install(FILES - dispatch.3 - dispatch_after.3 ---- a/src/swift/CMakeLists.txt -+++ b/src/swift/CMakeLists.txt -@@ -47,7 +47,7 @@ get_swift_host_arch(swift_arch) - install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftmodule - ${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftdoc -- DESTINATION ${INSTALL_TARGET_DIR}/${swift_arch}) -+ DESTINATION ${INSTALL_TARGET_DIR}/swift) - set_property(GLOBAL APPEND PROPERTY DISPATCH_EXPORTS swiftDispatch) - install(TARGETS swiftDispatch - EXPORT dispatchExports diff --git a/pkgs/development/compilers/swift/libdispatch/glue.cmake b/pkgs/development/compilers/swift/libdispatch/glue.cmake deleted file mode 100644 index dd696dc61085..000000000000 --- a/pkgs/development/compilers/swift/libdispatch/glue.cmake +++ /dev/null @@ -1,5 +0,0 @@ -add_library(dispatch SHARED IMPORTED) -set_property(TARGET dispatch PROPERTY IMPORTED_LOCATION "@out@/lib/libdispatch@dylibExt@") - -add_library(swiftDispatch SHARED IMPORTED) -set_property(TARGET swiftDispatch PROPERTY IMPORTED_LOCATION "@out@/lib/libswiftDispatch@dylibExt@") diff --git a/pkgs/development/compilers/swift/sourcekit-lsp/default.nix b/pkgs/development/compilers/swift/sourcekit-lsp/default.nix deleted file mode 100644 index 7ad17d6624bb..000000000000 --- a/pkgs/development/compilers/swift/sourcekit-lsp/default.nix +++ /dev/null @@ -1,89 +0,0 @@ -{ - lib, - stdenv, - callPackage, - fetchpatch, - pkg-config, - swift, - swiftpm, - swiftpm2nix, - Dispatch, - Foundation, - XCTest, - sqlite, - ncurses, -}: -let - sources = callPackage ../sources.nix { }; - generated = swiftpm2nix.helpers ./generated; - - # On Darwin, we only want ncurses in the linker search path, because headers - # are part of libsystem. Adding its headers to the search path causes strange - # mixing and errors. - # TODO: Find a better way to prevent this conflict. - ncursesInput = if stdenv.hostPlatform.isDarwin then ncurses.out else ncurses; -in -stdenv.mkDerivation { - pname = "sourcekit-lsp"; - - inherit (sources) version; - src = sources.sourcekit-lsp; - - nativeBuildInputs = [ - pkg-config - swift - swiftpm - ]; - buildInputs = [ - Foundation - XCTest - sqlite - ncursesInput - ]; - - env.LD_LIBRARY_PATH = lib.optionalString stdenv.hostPlatform.isLinux ( - lib.makeLibraryPath [ Dispatch ] - ); - - configurePhase = generated.configure + '' - swiftpmMakeMutable indexstore-db - patch -p1 -d .build/checkouts/indexstore-db -i ${./patches/indexstore-db-macos-target.patch} - patch -p1 -d .build/checkouts/indexstore-db -i ${ - # Fix the build with modern Clang. - fetchpatch { - url = "https://github.com/swiftlang/indexstore-db/commit/6120b53b1e8774ef4e2ad83438d4d94961331e72.patch"; - hash = "sha256-tMAfTIa3RKiA/jDtP02mHcpPaF2s9a+3q/PLJxqn30M="; - } - } - - # This toggles a section specific to Xcode XCTest, which doesn't work on - # Darwin, where we also use swift-corelibs-xctest. - substituteInPlace Sources/LSPTestSupport/PerfTestCase.swift \ - --replace-fail '#if os(macOS)' '#if false' - - # Required to link with swift-corelibs-xctest on Darwin. - export SWIFTTSC_MACOS_DEPLOYMENT_TARGET=10.12 - ''; - - # TODO: BuildServerBuildSystemTests fails - #doCheck = true; - - installPhase = '' - binPath="$(swiftpmBinPath)" - mkdir -p $out/bin - cp $binPath/sourcekit-lsp $out/bin/ - ''; - - # Canary to verify output of our Swift toolchain does not depend on the Swift - # compiler itself. (Only its 'lib' output.) - disallowedRequisites = [ swift.swift ]; - - meta = { - description = "Language Server Protocol implementation for Swift and C-based languages"; - mainProgram = "sourcekit-lsp"; - homepage = "https://github.com/swiftlang/sourcekit-lsp"; - platforms = with lib.platforms; linux ++ darwin; - license = lib.licenses.asl20; - teams = [ lib.teams.swift ]; - }; -} diff --git a/pkgs/development/compilers/swift/sourcekit-lsp/generated/default.nix b/pkgs/development/compilers/swift/sourcekit-lsp/generated/default.nix deleted file mode 100644 index eb316fdf48c8..000000000000 --- a/pkgs/development/compilers/swift/sourcekit-lsp/generated/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -# This file was generated by swiftpm2nix. -{ - workspaceStateFile = ./workspace-state.json; - hashes = { - "indexstore-db" = "sha256-2EIzEaVLHZ5vwO8skTaq9HoAaLuT9WFVLMgcgGYuVAk="; - "swift-argument-parser" = "sha256-qEJ329hqQyQVxtHScD7qPmWW9ZDf9bX+4xgpDlX0w5A="; - "swift-asn1" = "sha256-aN6BJOBvUCFn62mPv0nT4Z3edD1bQZ2zT5GubzdXZDw="; - "swift-certificates" = "sha256-34FcJfZgdufFehgjxgo8UbbFPnWnYsS6qR8SIba/WZg="; - "swift-collections" = "sha256-+f9Azcl+NbDvxlMsX0UbT3n87aYaBR1Kjp3rDqoLgkA="; - "swift-crypto" = "sha256-lcB497b/T1bHShPrjNjHthrs76pDFpU+4uN0uW4tz+4="; - "swift-driver" = "sha256-Xaz9gZuOspDb+PB67d6tXfpcs+kkDCPSkhu+eIfrb0A="; - "swift-llbuild" = "sha256-kUm8/+DWDBhuqU/kJBleqSl8/Vz478pMhx5QK2g7k0o="; - "swift-package-manager" = "sha256-7jkAum4nJj9ofVRF3RZDXAR6PyAjORPMnftTNnUrA+U="; - "swift-syntax" = "sha256-8XV2dlB3Vio5O+wFnS5EQeHyPCIgFyCjEYFGCWzOPwE="; - "swift-system" = "sha256-NpTzyppbOQR0Bg/0jrwdphZgbxyRrXy/4dnYcjFvY6w="; - "swift-tools-support-core" = "sha256-Pqy01AyDg7ZTyDM6lV69e6nhfhxwFTOhGFTfhcA1e9E="; - "Yams" = "sha256-AY/fIvB7THrl9GWzGJL8eDBbkcLw27tSRTGtUqmYw8k="; - }; -} diff --git a/pkgs/development/compilers/swift/sourcekit-lsp/generated/workspace-state.json b/pkgs/development/compilers/swift/sourcekit-lsp/generated/workspace-state.json deleted file mode 100644 index b0cf93cb193c..000000000000 --- a/pkgs/development/compilers/swift/sourcekit-lsp/generated/workspace-state.json +++ /dev/null @@ -1,229 +0,0 @@ -{ - "object": { - "artifacts": [], - "dependencies": [ - { - "basedOn": null, - "packageRef": { - "identity": "indexstore-db", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/indexstore-db.git", - "name": "IndexStoreDB" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "89ec16c2ac1bb271614e734a2ee792224809eb20" - }, - "name": "sourceControlCheckout" - }, - "subpath": "indexstore-db" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-argument-parser", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-argument-parser.git", - "name": "swift-argument-parser" - }, - "state": { - "checkoutState": { - "revision": "8f4d2753f0e4778c76d5f05ad16c74f707390531", - "version": "1.2.3" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-argument-parser" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-asn1", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-asn1.git", - "name": "swift-asn1" - }, - "state": { - "checkoutState": { - "revision": "df5d2fcd22e3f480e3ef85bf23e277a4a0ef524d", - "version": "1.2.0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-asn1" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-certificates", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-certificates.git", - "name": "swift-certificates" - }, - "state": { - "checkoutState": { - "revision": "83640c8097acaec17c9835a083e89678cb0f2b66", - "version": "1.3.0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-certificates" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-collections", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-collections.git", - "name": "swift-collections" - }, - "state": { - "checkoutState": { - "revision": "c11818f3cae0780656baa430b49e7f163f08dffd", - "version": "1.1.6" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-collections" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-crypto", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-crypto.git", - "name": "swift-crypto" - }, - "state": { - "checkoutState": { - "revision": "629f0b679d0fd0a6ae823d7f750b9ab032c00b80", - "version": "3.0.0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-crypto" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-driver", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-driver.git", - "name": "swift-driver" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "b461fd4fc51be8e1f2a3f4a2184b664b8846b46f" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-driver" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-llbuild", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-llbuild.git", - "name": "llbuild" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "fd7c2e0d9279edd023ced6b0a590f8407f5472f9" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-llbuild" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-package-manager", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-package-manager.git", - "name": "SwiftPM" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "b5f8ad931b7a40b81f64765fa08c2751164759b4" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-package-manager" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-syntax", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-syntax.git", - "name": "swift-syntax" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "cdd571f366a4298bb863a9dcfe1295bb595041d5" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-syntax" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-system", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-system.git", - "name": "swift-system" - }, - "state": { - "checkoutState": { - "revision": "d2ba781702a1d8285419c15ee62fd734a9437ff5", - "version": "1.3.2" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-system" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-tools-support-core", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-tools-support-core.git", - "name": "swift-tools-support-core" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "90bdc2a157ebacc5d3de0c83e085d05d22ca5fa0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-tools-support-core" - }, - { - "basedOn": null, - "packageRef": { - "identity": "yams", - "kind": "remoteSourceControl", - "location": "https://github.com/jpsim/Yams.git", - "name": "Yams" - }, - "state": { - "checkoutState": { - "revision": "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3", - "version": "5.0.6" - }, - "name": "sourceControlCheckout" - }, - "subpath": "Yams" - } - ] - }, - "version": 6 -} diff --git a/pkgs/development/compilers/swift/sourcekit-lsp/patches/indexstore-db-macos-target.patch b/pkgs/development/compilers/swift/sourcekit-lsp/patches/indexstore-db-macos-target.patch deleted file mode 100644 index 53e790874d5d..000000000000 --- a/pkgs/development/compilers/swift/sourcekit-lsp/patches/indexstore-db-macos-target.patch +++ /dev/null @@ -1,12 +0,0 @@ -Raise the deployment target of IndexStoreDB so it can link against our XCTest. - ---- a/Package.swift -+++ b/Package.swift -@@ -4,6 +4,7 @@ import PackageDescription - - let package = Package( - name: "IndexStoreDB", -+ platforms: [.macOS("10.12")], - products: [ - .library( - name: "IndexStoreDB", diff --git a/pkgs/development/compilers/swift/sources.nix b/pkgs/development/compilers/swift/sources.nix deleted file mode 100644 index 5b5c468a6d06..000000000000 --- a/pkgs/development/compilers/swift/sources.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ lib, fetchFromGitHub }: - -let - - # These packages are all part of the Swift toolchain, and have a single - # upstream version that should match. We also list the hashes here so a basic - # version upgrade touches only this file. - version = "5.10.1"; - hashes = { - llvm-project = "sha256-D+zZjLgnAFy6zBuUQwRI0VmDrgr2TQeNUnDbDtvtRZ4="; - sourcekit-lsp = "sha256-mMZ8zPkyoht0aSSnStIULWbLjowahdza9DQXboT1D0o="; - swift = "sha256-UK8yPwHu/sCvcuKKmBMCP9rGRJCZE3ct0ckdNw2BVbE="; - swift-cmark = "sha256-GK2tFu49Sw8jJWJpxQerVFqsuUJwkAhRloa2/aUTYB8="; - swift-corelibs-foundation = "sha256-izYpdCZaf3ktgz/k3pjmHJHH5BebdG7nj8l6vbuk+o0="; - swift-corelibs-libdispatch = "sha256-pta3wJj2LJ/lsYAWQpw0wSGLDMO41mN8Zbl78LUCaQo="; - swift-corelibs-xctest = "sha256-HgnVFYUuefCZKsOjXgt98ebMsLdMl0oXFXy2Pb2iUdw="; - swift-docc = "sha256-zgGahAanYI95nQZ+3zAYrs0h4APNamPrZfwF81k1si0="; - swift-docc-render-artifact = "sha256-Ky9l6tzAxQOpcPFq2FeGnFUl8i59TifRBSHNaZg8wfw="; - swift-driver = "sha256-Xaz9gZuOspDb+PB67d6tXfpcs+kkDCPSkhu+eIfrb0A="; - swift-experimental-string-processing = "sha256-gv3xY9s6gdv0lpXH8RGfiLAvZWM7xVsUSLcqyb4rSeQ="; - swift-format = "sha256-oYf9Qt0b/6G3+uQaoExQRKzgpi1RPYSSpZLfwhuRmF8="; - swift-package-manager = "sha256-yL/cPCt7pZ0XqbbxEnrbzM2X3EkU9klon7SzO2Z13SA="; - swift-syntax = "sha256-OcrOdlnLYpMxH5CGWNGbs5XW3gJaGgKWQqB9YtwmZeY="; - }; - - # Create fetch derivations. - sources = lib.mapAttrs ( - repo: hash: - fetchFromGitHub { - owner = "apple"; - inherit repo; - rev = "swift-${version}-RELEASE"; - name = "${repo}-${version}-src"; - hash = hashes.${repo}; - } - ) hashes; - -in -sources // { inherit version; } diff --git a/pkgs/development/compilers/swift/swift-docc/default.nix b/pkgs/development/compilers/swift/swift-docc/default.nix deleted file mode 100644 index 2ec0b4c10746..000000000000 --- a/pkgs/development/compilers/swift/swift-docc/default.nix +++ /dev/null @@ -1,73 +0,0 @@ -{ - lib, - stdenv, - callPackage, - swift, - swiftpm, - swiftpm2nix, - Foundation, - XCTest, -}: -let - sources = callPackage ../sources.nix { }; - generated = swiftpm2nix.helpers ./generated; -in -stdenv.mkDerivation { - pname = "swift-docc"; - - inherit (sources) version; - src = sources.swift-docc; - # TODO: We could build this from `apple/swift-docc-render` source, but that - # repository is not tagged. - renderArtifact = sources.swift-docc-render-artifact; - - nativeBuildInputs = [ - swift - swiftpm - ]; - buildInputs = [ - Foundation - XCTest - ]; - - configurePhase = - generated.configure - # Fix the build with modern Clang. - # - # Based on the upstream fix for Musl: - # - + '' - swiftpmMakeMutable swift-nio - patch -p1 -d .build/checkouts/swift-nio -i ${./fix-swift-nio.patch} - ''; - - # We only install the docc binary, so don't need the other products. - # This works around a failure building generate-symbol-graph: - # Sources/generate-symbol-graph/main.swift:13:18: error: module 'SwiftDocC' was not compiled for testing - # TODO: Figure out the cause. It doesn't seem to happen outside Nixpkgs. - swiftpmFlags = [ "--product docc" ]; - - # TODO: Tests depend on indexstore-db being provided by an existing Swift - # toolchain. (ie. looks for `../lib/libIndexStore.so` relative to swiftc. - #doCheck = true; - - installPhase = '' - binPath="$(swiftpmBinPath)" - mkdir -p $out/bin $out/share/docc - cp $binPath/docc $out/bin/ - ln -s $renderArtifact/dist $out/share/docc/render - ''; - - # Canary to verify output of our Swift toolchain does not depend on the Swift - # compiler itself. (Only its 'lib' output.) - disallowedRequisites = [ swift.swift ]; - - meta = { - description = "Documentation compiler for Swift"; - mainProgram = "docc"; - homepage = "https://github.com/apple/swift-docc"; - platforms = with lib.platforms; linux ++ darwin; - license = lib.licenses.asl20; - teams = [ lib.teams.swift ]; - }; -} diff --git a/pkgs/development/compilers/swift/swift-docc/fix-swift-nio.patch b/pkgs/development/compilers/swift/swift-docc/fix-swift-nio.patch deleted file mode 100644 index ccab988906fa..000000000000 --- a/pkgs/development/compilers/swift/swift-docc/fix-swift-nio.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/Package.swift b/Package.swift -index 39c6fb4b2f..02c08b898d 100644 ---- a/Package.swift -+++ b/Package.swift -@@ -26,7 +26,7 @@ - .target(name: "NIOFoundationCompat", dependencies: ["NIO"]), - .target(name: "CNIOAtomics", dependencies: []), - .target(name: "CNIOSHA1", dependencies: []), -- .target(name: "CNIOLinux", dependencies: []), -+ .target(name: "CNIOLinux", dependencies: [], cSettings: [.define("_GNU_SOURCE")]), - .target(name: "CNIODarwin", dependencies: [], cSettings: [.define("__APPLE_USE_RFC_3542")]), - .target(name: "CNIOWindows", dependencies: []), - .target(name: "NIOConcurrencyHelpers", diff --git a/pkgs/development/compilers/swift/swift-docc/generated/default.nix b/pkgs/development/compilers/swift/swift-docc/generated/default.nix deleted file mode 100644 index 22bec28c102f..000000000000 --- a/pkgs/development/compilers/swift/swift-docc/generated/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -# This file was generated by swiftpm2nix. -{ - workspaceStateFile = ./workspace-state.json; - hashes = { - "swift-argument-parser" = "sha256-G4Tz/AdL5WbRq93aJnQhMjHLH7dEuhmXL3PPn+0H6vM="; - "swift-atomics" = "sha256-fjRGySMI7Mv52sCYejWI5YA+IcehOdz5XxK3p+hxwmU="; - "swift-cmark" = "sha256-1/LnvAggPkpfJZo9evfP+fCj6NXY9SMxwo7WJA2kXOM="; - "swift-collections" = "sha256-VtnHFWd5OUmRBnmIeOF8xn8PASLrHG/pfONWnEuX2sw="; - "swift-crypto" = "sha256-vBDjXtynl3HMq1RK/hMOu36b+0hX2SRRnwhPNjPUOsU="; - "swift-docc-plugin" = "sha256-r+cFtDTK6rRWDOOsgJNF6J2mfm/oKxoK7HIv6fpFW4o="; - "swift-docc-symbolkit" = "sha256-hAcoe57wE9gkPc1E/lXY41W+Eh3a7cUWfRv3Xi4rO2M="; - "swift-lmdb" = "sha256-dZDN2pBOE0ZPtneQvEjF+AE4PDwbcaTausR2W4lg9Ss="; - "swift-markdown" = "sha256-qb+mSS1A3WzLQdCB9lIz+UhSG9tf0hknitTfh6VIrHs="; - "swift-nio" = "sha256-KOvnE5VF6lw9hfTLHIlG+6EV/7kl8hL4IOIVoP2om3Q="; - }; -} diff --git a/pkgs/development/compilers/swift/swift-docc/generated/workspace-state.json b/pkgs/development/compilers/swift/swift-docc/generated/workspace-state.json deleted file mode 100644 index 76f5f228b274..000000000000 --- a/pkgs/development/compilers/swift/swift-docc/generated/workspace-state.json +++ /dev/null @@ -1,178 +0,0 @@ -{ - "object": { - "artifacts": [], - "dependencies": [ - { - "basedOn": null, - "packageRef": { - "identity": "swift-argument-parser", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-argument-parser", - "name": "swift-argument-parser" - }, - "state": { - "checkoutState": { - "revision": "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a", - "version": "1.2.2" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-argument-parser" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-atomics", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-atomics.git", - "name": "swift-atomics" - }, - "state": { - "checkoutState": { - "revision": "6c89474e62719ddcc1e9614989fff2f68208fe10", - "version": "1.1.0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-atomics" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-cmark", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-cmark.git", - "name": "cmark-gfm" - }, - "state": { - "checkoutState": { - "branch": "gfm", - "revision": "eb9a6a357b6816c68f4b194eaa5b67f3cd1fa5c3" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-cmark" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-collections", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-collections.git", - "name": "swift-collections" - }, - "state": { - "checkoutState": { - "revision": "937e904258d22af6e447a0b72c0bc67583ef64a2", - "version": "1.0.4" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-collections" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-crypto", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-crypto.git", - "name": "swift-crypto" - }, - "state": { - "checkoutState": { - "revision": "33a20e650c33f6d72d822d558333f2085effa3dc", - "version": "2.5.0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-crypto" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-docc-plugin", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-docc-plugin", - "name": "SwiftDocCPlugin" - }, - "state": { - "checkoutState": { - "revision": "9b1258905c21fc1b97bf03d1b4ca12c4ec4e5fda", - "version": "1.2.0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-docc-plugin" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-docc-symbolkit", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-docc-symbolkit", - "name": "SymbolKit" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "1d5aba8186fc648e17b30631b34043110ca8dd19" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-docc-symbolkit" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-lmdb", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-lmdb.git", - "name": "CLMDB" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "584941b1236b15bad74d8163785d389c028b1ad8" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-lmdb" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-markdown", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-markdown.git", - "name": "swift-markdown" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "636291555b65bd59b2b3279abc7d03a622aa7c55" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-markdown" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-nio", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-nio.git", - "name": "swift-nio" - }, - "state": { - "checkoutState": { - "revision": "2d8e6ca36fe3e8ed74b0883f593757a45463c34d", - "version": "2.53.0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-nio" - } - ] - }, - "version": 6 -} diff --git a/pkgs/development/compilers/swift/swift-driver/default.nix b/pkgs/development/compilers/swift/swift-driver/default.nix deleted file mode 100644 index 04d41a663cd7..000000000000 --- a/pkgs/development/compilers/swift/swift-driver/default.nix +++ /dev/null @@ -1,82 +0,0 @@ -{ - lib, - stdenv, - callPackage, - fetchpatch, - swift, - swiftpm, - swiftpm2nix, - Foundation, - XCTest, - sqlite, - ncurses, - clang, - replaceVars, -}: -let - sources = callPackage ../sources.nix { }; - generated = swiftpm2nix.helpers ./generated; - - # On Darwin, we only want ncurses in the linker search path, because headers - # are part of libsystem. Adding its headers to the search path causes strange - # mixing and errors. - # TODO: Find a better way to prevent this conflict. - ncursesInput = if stdenv.hostPlatform.isDarwin then ncurses.out else ncurses; -in -stdenv.mkDerivation { - pname = "swift-driver"; - - inherit (sources) version; - src = sources.swift-driver; - - nativeBuildInputs = [ - swift - swiftpm - ]; - buildInputs = [ - Foundation - XCTest - sqlite - ncursesInput - ]; - - patches = [ - ./patches/disable-catalyst.patch - (replaceVars ./patches/linux-fix-linking.patch { - inherit clang; - }) - # TODO: Replace with branch patch once merged: - # https://github.com/apple/swift-driver/pull/1197 - (fetchpatch { - url = "https://github.com/apple/swift-driver/commit/d3ef9cdf4871a58eddec7ff0e28fe611130da3f9.patch"; - hash = "sha256-eVBaKN6uzj48ZnHtwGV0k5ChKjak1tDCyE+wTdyGq2c="; - }) - # Prevent a warning about SDK directories we don't have. - (replaceVars ./patches/prevent-sdk-dirs-warnings.patch { - inherit (builtins) storeDir; - }) - ]; - - configurePhase = generated.configure; - - # TODO: Tests depend on indexstore-db being provided by an existing Swift - # toolchain. (ie. looks for `../lib/libIndexStore.so` relative to swiftc. - #doCheck = true; - - # TODO: Darwin-specific installation includes more, but not sure why. - installPhase = '' - binPath="$(swiftpmBinPath)" - mkdir -p $out/bin - for executable in swift-driver swift-help swift-build-sdk-interfaces; do - cp $binPath/$executable $out/bin/ - done - ''; - - meta = { - description = "Swift compiler driver"; - homepage = "https://github.com/apple/swift-driver"; - platforms = with lib.platforms; linux ++ darwin; - license = lib.licenses.asl20; - teams = [ lib.teams.swift ]; - }; -} diff --git a/pkgs/development/compilers/swift/swift-driver/generated/default.nix b/pkgs/development/compilers/swift/swift-driver/generated/default.nix deleted file mode 100644 index 3651538c1a01..000000000000 --- a/pkgs/development/compilers/swift/swift-driver/generated/default.nix +++ /dev/null @@ -1,11 +0,0 @@ -# This file was generated by swiftpm2nix. -{ - workspaceStateFile = ./workspace-state.json; - hashes = { - "swift-argument-parser" = "sha256-G4Tz/AdL5WbRq93aJnQhMjHLH7dEuhmXL3PPn+0H6vM="; - "swift-llbuild" = "sha256-kUm8/+DWDBhuqU/kJBleqSl8/Vz478pMhx5QK2g7k0o="; - "swift-system" = "sha256-p18QHzO+NtoY/WQzOD+PfD+bjqrIWsbeEbsJLPqEAhA="; - "swift-tools-support-core" = "sha256-Pqy01AyDg7ZTyDM6lV69e6nhfhxwFTOhGFTfhcA1e9E="; - "Yams" = "sha256-5qxuCkmopm3uFcoYJKQA8ofW98f53H1gZaPiOh2DS4U="; - }; -} diff --git a/pkgs/development/compilers/swift/swift-driver/generated/workspace-state.json b/pkgs/development/compilers/swift/swift-driver/generated/workspace-state.json deleted file mode 100644 index 55bd4ea5fad1..000000000000 --- a/pkgs/development/compilers/swift/swift-driver/generated/workspace-state.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "object": { - "artifacts": [], - "dependencies": [ - { - "basedOn": null, - "packageRef": { - "identity": "swift-argument-parser", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-argument-parser.git", - "name": "swift-argument-parser" - }, - "state": { - "checkoutState": { - "revision": "fee6933f37fde9a5e12a1e4aeaa93fe60116ff2a", - "version": "1.2.2" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-argument-parser" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-llbuild", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-llbuild.git", - "name": "llbuild" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "fd7c2e0d9279edd023ced6b0a590f8407f5472f9" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-llbuild" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-system", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-system.git", - "name": "swift-system" - }, - "state": { - "checkoutState": { - "revision": "836bc4557b74fe6d2660218d56e3ce96aff76574", - "version": "1.1.1" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-system" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-tools-support-core", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-tools-support-core.git", - "name": "swift-tools-support-core" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "90bdc2a157ebacc5d3de0c83e085d05d22ca5fa0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-tools-support-core" - }, - { - "basedOn": null, - "packageRef": { - "identity": "yams", - "kind": "remoteSourceControl", - "location": "https://github.com/jpsim/Yams.git", - "name": "Yams" - }, - "state": { - "checkoutState": { - "revision": "01835dc202670b5bb90d07f3eae41867e9ed29f6", - "version": "5.0.1" - }, - "name": "sourceControlCheckout" - }, - "subpath": "Yams" - } - ] - }, - "version": 6 -} diff --git a/pkgs/development/compilers/swift/swift-driver/patches/disable-catalyst.patch b/pkgs/development/compilers/swift/swift-driver/patches/disable-catalyst.patch deleted file mode 100644 index b9eb23f21061..000000000000 --- a/pkgs/development/compilers/swift/swift-driver/patches/disable-catalyst.patch +++ /dev/null @@ -1,17 +0,0 @@ -Tries to parse SDKSettings.plist looking for a Catalyst version map, but we -don't currently support this. - ---- a/Sources/SwiftDriver/Toolchains/DarwinToolchain.swift -+++ b/Sources/SwiftDriver/Toolchains/DarwinToolchain.swift -@@ -297,11 +297,7 @@ public final class DarwinToolchain: Toolchain { - debugDescription: "Malformed version string") - } - self.version = version -- if self.canonicalName.hasPrefix("macosx") { -- self.versionMap = try keyedContainer.decode(VersionMap.self, forKey: .versionMap) -- } else { - self.versionMap = VersionMap() -- } - } - - diff --git a/pkgs/development/compilers/swift/swift-driver/patches/linux-fix-linking.patch b/pkgs/development/compilers/swift/swift-driver/patches/linux-fix-linking.patch deleted file mode 100644 index dcdb5292687d..000000000000 --- a/pkgs/development/compilers/swift/swift-driver/patches/linux-fix-linking.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift -index a4a735f498..381522cc1f 100644 ---- a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift -+++ b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift -@@ -10,6 +10,7 @@ - // - //===----------------------------------------------------------------------===// - -+import Foundation - import SwiftOptions - - import func TSCBasic.lookupExecutablePath -@@ -130,7 +131,18 @@ - } - - let clangTool: Tool = cxxCompatEnabled ? .clangxx : .clang -- var clangPath = try getToolPath(clangTool) -+ -+ // For Nix, prefer linking using the wrapped Nixpkgs clang, instead of using -+ // the unwrapped clang packaged with swift. The latter is unable to link, but -+ // we still want to use it for other purposes (clang importer). -+ var clangPath: AbsolutePath -+ if let binPath = try? AbsolutePath(validating: "@clang@/bin"), -+ let tool = lookupExecutablePath(filename: cxxCompatEnabled -+ ? "clang++" : "clang", -+ searchPaths: [binPath]) { -+ clangPath = tool -+ } else { -+ clangPath = try getToolPath(clangTool) - if let toolsDirPath = parsedOptions.getLastArgument(.toolsDirectory) { - // FIXME: What if this isn't an absolute path? - let toolsDir = try AbsolutePath(validating: toolsDirPath.asSingle) -@@ -146,6 +158,7 @@ - commandLine.appendFlag("-B") - commandLine.appendPath(toolsDir) - } -+ } // Nix - - // Executables on Linux get -pie - if targetTriple.os == .linux && linkerOutputType == .executable { diff --git a/pkgs/development/compilers/swift/swift-driver/patches/prevent-sdk-dirs-warnings.patch b/pkgs/development/compilers/swift/swift-driver/patches/prevent-sdk-dirs-warnings.patch deleted file mode 100644 index 6080865ebe37..000000000000 --- a/pkgs/development/compilers/swift/swift-driver/patches/prevent-sdk-dirs-warnings.patch +++ /dev/null @@ -1,16 +0,0 @@ -Prevents a user-visible warning on every compilation: - - ld: warning: directory not found for option '-L.../MacOSX11.0.sdk/usr/lib/swift' - ---- a/Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift -+++ b/Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift -@@ -50,7 +50,9 @@ extension Toolchain { - result.append(sdkPath.appending(components: "System", "iOSSupport", "usr", "lib", "swift")) - } - -+ if sdkPath.absolutePath?.pathString.starts(with: "@storeDir@") == false { - result.append(sdkPath.appending(components: "usr", "lib", "swift")) -+ } - } - - return result diff --git a/pkgs/development/compilers/swift/swift-format/default.nix b/pkgs/development/compilers/swift/swift-format/default.nix deleted file mode 100644 index 9f265bc4d6f1..000000000000 --- a/pkgs/development/compilers/swift/swift-format/default.nix +++ /dev/null @@ -1,62 +0,0 @@ -{ - lib, - stdenv, - callPackage, - swift, - swiftpm, - swiftpm2nix, - installShellFiles, - Dispatch, - Foundation, -}: -let - sources = callPackage ../sources.nix { }; - generated = swiftpm2nix.helpers ./generated; -in -stdenv.mkDerivation { - pname = "swift-format"; - - inherit (sources) version; - src = sources.swift-format; - - nativeBuildInputs = [ - swift - swiftpm - installShellFiles - ]; - buildInputs = [ Foundation ]; - - env.LD_LIBRARY_PATH = lib.optionalString stdenv.hostPlatform.isLinux ( - lib.makeLibraryPath [ Dispatch ] - ); - - configurePhase = generated.configure; - - # We only install the swift-format binary, so don't need the other products. - swiftpmFlags = [ "--product swift-format" ]; - - installPhase = '' - binPath="$(swiftpmBinPath)" - mkdir -p $out/bin - cp $binPath/swift-format $out/bin/ - - # Generate shell completions - for shell in bash zsh fish; do - $out/bin/swift-format --generate-completion-script $shell > swift-format.$shell - done - - installShellCompletion --cmd swift-format \ - --bash swift-format.bash \ - --zsh swift-format.zsh \ - --fish swift-format.fish - ''; - - meta = { - description = "Formatting technology for Swift source code"; - homepage = "https://github.com/swiftlang/swift-format"; - platforms = with lib.platforms; linux ++ darwin; - license = lib.licenses.asl20; - teams = [ lib.teams.swift ]; - mainProgram = "swift-format"; - }; -} diff --git a/pkgs/development/compilers/swift/swift-format/generated/default.nix b/pkgs/development/compilers/swift/swift-format/generated/default.nix deleted file mode 100644 index b01e3c6abf2d..000000000000 --- a/pkgs/development/compilers/swift/swift-format/generated/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -# This file was generated by swiftpm2nix. -{ - workspaceStateFile = ./workspace-state.json; - hashes = { - "swift-argument-parser" = "sha256-JXNjFpLNaqzOGXlIgQtwzG2Yq1daOl4tmTAUcZL4thM="; - "swift-cmark" = "sha256-npLzvHtMmWZlqNIYOMAZfqyX2TOkICZNHCN1+laOBZA="; - "swift-markdown" = "sha256-F8xJYp8kf9IzLAe+HuKLFWJe3fdC2yewb+zaJgyeJ1U="; - "swift-syntax" = "sha256-8XV2dlB3Vio5O+wFnS5EQeHyPCIgFyCjEYFGCWzOPwE="; - }; -} diff --git a/pkgs/development/compilers/swift/swift-format/generated/workspace-state.json b/pkgs/development/compilers/swift/swift-format/generated/workspace-state.json deleted file mode 100644 index 388535f3770f..000000000000 --- a/pkgs/development/compilers/swift/swift-format/generated/workspace-state.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "object": { - "artifacts": [], - "dependencies": [ - { - "basedOn": null, - "packageRef": { - "identity": "swift-argument-parser", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-argument-parser.git", - "name": "swift-argument-parser" - }, - "state": { - "checkoutState": { - "revision": "309a47b2b1d9b5e991f36961c983ecec72275be3", - "version": "1.6.1" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-argument-parser" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-cmark", - "kind": "remoteSourceControl", - "location": "https://github.com/swiftlang/swift-cmark.git", - "name": "cmark-gfm" - }, - "state": { - "checkoutState": { - "revision": "b97d09472e847a416629f026eceae0e2afcfad65", - "version": "0.7.0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-cmark" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-markdown", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-markdown.git", - "name": "swift-markdown" - }, - "state": { - "checkoutState": { - "revision": "d8cf111c276ed18cff82d3cad563d2ca5903b982", - "version": "0.7.1" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-markdown" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-syntax", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-syntax.git", - "name": "swift-syntax" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "cdd571f366a4298bb863a9dcfe1295bb595041d5" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-syntax" - } - ] - }, - "version": 6 -} diff --git a/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix b/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix deleted file mode 100644 index 70af831142a9..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/cmake-glue.nix +++ /dev/null @@ -1,107 +0,0 @@ -# SwiftPM dependencies are normally not installed using CMake, and only provide -# CMake modules to link them together in a build tree. We have separate -# derivations, so need a real install step. Here we provide our own minimal -# CMake modules to install along with the build products. -{ - lib, - stdenv, - swift, -}: -let - - inherit (stdenv.hostPlatform) extensions; - - # This file exports shell snippets for use in postInstall. - mkInstallScript = module: template: '' - mkdir -p $out/lib/cmake/${module} - ( - export staticLibExt="${extensions.staticLibrary}" - export sharedLibExt="${extensions.sharedLibrary}" - export swiftOs="${swift.swiftOs}" - substituteAll \ - ${builtins.toFile "${module}Config.cmake" template} \ - $out/lib/cmake/${module}/${module}Config.cmake - ) - ''; - -in -lib.mapAttrs mkInstallScript { - SwiftSystem = '' - add_library(SwiftSystem::SystemPackage STATIC IMPORTED) - set_property(TARGET SwiftSystem::SystemPackage PROPERTY IMPORTED_LOCATION "@out@/lib/swift_static/@swiftOs@/libSystemPackage@staticLibExt@") - ''; - - SwiftCollections = '' - add_library(SwiftCollections::Collections STATIC IMPORTED) - set_property(TARGET SwiftCollections::Collections PROPERTY IMPORTED_LOCATION "@out@/lib/swift_static/@swiftOs@/libCollections@staticLibExt@") - - add_library(SwiftCollections::DequeModule STATIC IMPORTED) - set_property(TARGET SwiftCollections::DequeModule PROPERTY IMPORTED_LOCATION "@out@/lib/swift_static/@swiftOs@/libDequeModule@staticLibExt@") - - add_library(SwiftCollections::OrderedCollections STATIC IMPORTED) - set_property(TARGET SwiftCollections::OrderedCollections PROPERTY IMPORTED_LOCATION "@out@/lib/swift_static/@swiftOs@/libOrderedCollections@staticLibExt@") - ''; - - TSC = '' - add_library(TSCLibc SHARED IMPORTED) - set_property(TARGET TSCLibc PROPERTY IMPORTED_LOCATION "@out@/lib/libTSCLibc@sharedLibExt@") - - add_library(TSCBasic SHARED IMPORTED) - set_property(TARGET TSCBasic PROPERTY IMPORTED_LOCATION "@out@/lib/libTSCBasic@sharedLibExt@") - - add_library(TSCUtility SHARED IMPORTED) - set_property(TARGET TSCUtility PROPERTY IMPORTED_LOCATION "@out@/lib/libTSCUtility@sharedLibExt@") - ''; - - ArgumentParser = '' - add_library(ArgumentParser SHARED IMPORTED) - set_property(TARGET ArgumentParser PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libArgumentParser@sharedLibExt@") - - add_library(ArgumentParserToolInfo SHARED IMPORTED) - set_property(TARGET ArgumentParserToolInfo PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libArgumentParserToolInfo@sharedLibExt@") - ''; - - Yams = '' - add_library(Yams SHARED IMPORTED) - set_property(TARGET Yams PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libYams@sharedLibExt@") - ''; - - LLBuild = '' - add_library(libllbuild SHARED IMPORTED) - set_property(TARGET libllbuild PROPERTY IMPORTED_LOCATION "@out@/lib/libllbuild@sharedLibExt@") - - add_library(llbuildSwift SHARED IMPORTED) - set_property(TARGET llbuildSwift PROPERTY IMPORTED_LOCATION "@out@/lib/swift/pm/llbuild/libllbuildSwift@sharedLibExt@") - ''; - - SwiftDriver = '' - add_library(SwiftDriver SHARED IMPORTED) - set_property(TARGET SwiftDriver PROPERTY IMPORTED_LOCATION "@out@/lib/libSwiftDriver@sharedLibExt@") - - add_library(SwiftDriverExecution SHARED IMPORTED) - set_property(TARGET SwiftDriverExecution PROPERTY IMPORTED_LOCATION "@out@/lib/libSwiftDriverExecution@sharedLibExt@") - - add_library(SwiftOptions SHARED IMPORTED) - set_property(TARGET SwiftOptions PROPERTY IMPORTED_LOCATION "@out@/lib/libSwiftOptions@sharedLibExt@") - ''; - - SwiftCrypto = '' - add_library(Crypto SHARED IMPORTED) - set_property(TARGET Crypto PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libCrypto@sharedLibExt@") - - add_library(_CryptoExtras SHARED IMPORTED) - # this can't possibly be right... I really think it should be `libCryptoExtras` - # swift-certificates did build with this though..... - set_property(TARGET _CryptoExtras PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libCrypto@sharedLibExt@") - ''; - - SwiftASN1 = '' - add_library(SwiftASN1 SHARED IMPORTED) - set_property(TARGET SwiftASN1 PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libSwiftASN1@sharedLibExt@") - ''; - - SwiftCertificates = '' - add_library(SwiftCertificates SHARED IMPORTED) - set_property(TARGET SwiftCertificates PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libCertificates@sharedLibExt@") - ''; -} diff --git a/pkgs/development/compilers/swift/swiftpm/default.nix b/pkgs/development/compilers/swift/swiftpm/default.nix deleted file mode 100644 index e6858f08cf18..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/default.nix +++ /dev/null @@ -1,501 +0,0 @@ -{ - lib, - stdenv, - callPackage, - fetchFromGitHub, - cmake, - ninja, - git, - swift, - swiftpm2nix, - Foundation, - XCTest, - pkg-config, - sqlite, - ncurses, - replaceVars, - runCommandLocal, - makeWrapper, - DarwinTools, # sw_vers - cctools, # vtool - xcbuild, -}: - -let - - inherit (swift) - swiftOs - swiftModuleSubdir - swiftStaticModuleSubdir - ; - sharedLibraryExt = stdenv.hostPlatform.extensions.sharedLibrary; - - sources = callPackage ../sources.nix { }; - generated = swiftpm2nix.helpers ./generated; - cmakeGlue = callPackage ./cmake-glue.nix { }; - - # Common attributes for the bootstrap swiftpm and the final swiftpm. - commonAttrs = { - inherit (sources) version; - src = sources.swift-package-manager; - nativeBuildInputs = [ makeWrapper ]; - # Required at run-time for the host platform to build package manifests. - propagatedBuildInputs = [ Foundation ]; - patches = [ - ./patches/cmake-disable-rpath.patch - ./patches/disable-index-store.patch - ./patches/disable-sandbox.patch - ./patches/disable-xctest.patch - ./patches/fix-clang-cxx.patch - ./patches/nix-pkgconfig-vars.patch - (replaceVars ./patches/fix-stdlib-path.patch { - inherit (builtins) storeDir; - swiftLib = swift.swift.lib; - }) - ]; - postPatch = '' - # The location of xcrun is hardcoded. We need PATH lookup instead. - find Sources -name '*.swift' | xargs sed -i -e 's|/usr/bin/xcrun|xcrun|g' - - # Patch the location where swiftpm looks for its API modules. - substituteInPlace Sources/PackageModel/UserToolchain.swift \ - --replace-fail \ - 'librariesPath = applicationPath.parentDirectory' \ - "librariesPath = try AbsolutePath(validating: \"$out\")" - ''; - }; - - # Tools invoked by swiftpm at run-time. - runtimeDeps = [ - git - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ - xcbuild.xcrun - # These tools are part of cctools, but adding that as a build input puts - # an unwrapped linker in PATH, and breaks builds. This small derivation - # exposes just the tools we need: - # - vtool is used to determine a minimum deployment target. - # - libtool is used to build static libraries. - (runCommandLocal "swiftpm-cctools" { } '' - mkdir -p $out/bin - ln -s ${cctools}/bin/vtool $out/bin/vtool - ln -s ${cctools}/bin/libtool $out/bin/libtool - '') - ]; - - # Common attributes for the bootstrap derivations. - mkBootstrapDerivation = - attrs: - stdenv.mkDerivation ( - attrs - // { - nativeBuildInputs = - (attrs.nativeBuildInputs or [ ]) - ++ [ - cmake - ninja - swift - ] - ++ lib.optionals stdenv.hostPlatform.isDarwin [ DarwinTools ]; - - buildInputs = (attrs.buildInputs or [ ]) ++ [ Foundation ]; - - postPatch = - (attrs.postPatch or "") - + lib.optionalString stdenv.hostPlatform.isDarwin '' - # On Darwin only, Swift uses arm64 as cpu arch. - if [ -e cmake/modules/SwiftSupport.cmake ]; then - # At least in swift-asn1, this has been removed and the module uses the full target triple as the name - # (https://github.com/apple/swift-asn1/pull/103) - substituteInPlace cmake/modules/SwiftSupport.cmake \ - --replace '"aarch64" PARENT_SCOPE' '"arm64" PARENT_SCOPE' - fi - ''; - - postInstall = - (attrs.postInstall or "") - + lib.optionalString stdenv.hostPlatform.isDarwin '' - # The install name of libraries is incorrectly set to lib/ (via our - # CMake setup hook) instead of lib/swift/. This'd be easily fixed by - # fixDarwinDylibNames, but some builds create libraries that reference - # eachother, and we also have to fix those references. - dylibs="$(find $out/lib/swift* -name '*.dylib')" - changes="" - for dylib in $dylibs; do - changes+=" -change $(otool -D $dylib | tail -n 1) $dylib" - done - for dylib in $dylibs; do - install_name_tool -id $dylib $changes $dylib - done - ''; - - cmakeFlags = (attrs.cmakeFlags or [ ]) ++ [ - # Some builds link to libraries within the same build. Make sure these - # create references to $out. None of our builds run their own products, - # so we don't have to account for that scenario. - "-DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON" - ]; - } - ); - - # On Darwin, we only want ncurses in the linker search path, because headers - # are part of libsystem. Adding its headers to the search path causes strange - # mixing and errors. - # TODO: Find a better way to prevent this conflict. - ncursesInput = if stdenv.hostPlatform.isDarwin then ncurses.out else ncurses; - - # Derivations for bootstrapping dependencies using CMake. - # This is based on the `swiftpm/Utilities/bootstrap` script. - # - # Some of the installation steps here are a bit hacky, because it seems like - # these packages were not really meant to be installed using CMake. The - # regular swiftpm bootstrap simply refers to the source and build - # directories. The advantage of separate builds is that we can more easily - # link libs together using existing Nixpkgs infra. - # - # In the end, we don't expose these derivations, and they only exist during - # the bootstrap phase. The final swiftpm derivation does not depend on them. - - swift-system = mkBootstrapDerivation { - name = "swift-system"; - src = generated.sources.swift-system; - - postInstall = - cmakeGlue.SwiftSystem - + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' - # The cmake rules apparently only use the Darwin install convention. - # Fix up the installation so the module can be found on non-Darwin. - mkdir -p $out/${swiftStaticModuleSubdir} - mv $out/lib/swift_static/${swiftOs}/*.swiftmodule $out/${swiftStaticModuleSubdir}/ - ''; - }; - - swift-collections = mkBootstrapDerivation { - name = "swift-collections"; - src = generated.sources.swift-collections; - - postPatch = '' - # Only builds static libs on Linux, but this installation difference is a - # hassle. Because this installation is temporary for the bootstrap, may - # as well build static libs everywhere. - sed -i -e '/BUILD_SHARED_LIBS/d' CMakeLists.txt - ''; - - postInstall = - cmakeGlue.SwiftCollections - + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' - # The cmake rules apparently only use the Darwin install convention. - # Fix up the installation so the module can be found on non-Darwin. - mkdir -p $out/${swiftStaticModuleSubdir} - mv $out/lib/swift_static/${swiftOs}/*.swiftmodule $out/${swiftStaticModuleSubdir}/ - ''; - }; - - swift-tools-support-core = mkBootstrapDerivation { - name = "swift-tools-support-core"; - src = generated.sources.swift-tools-support-core; - - buildInputs = [ - swift-system - sqlite - ]; - - postInstall = cmakeGlue.TSC + '' - # Swift modules are not installed. - mkdir -p $out/${swiftModuleSubdir} - cp swift/*.swift{module,doc} $out/${swiftModuleSubdir}/ - - # Static libs are not installed. - cp lib/*.a $out/lib/ - - # Headers are not installed. - mkdir -p $out/include - cp -r ../Sources/TSCclibc/include $out/include/TSC - ''; - }; - - swift-argument-parser = mkBootstrapDerivation { - name = "swift-argument-parser"; - src = generated.sources.swift-argument-parser; - - buildInputs = [ - ncursesInput - sqlite - ]; - - cmakeFlags = [ - "-DBUILD_TESTING=NO" - "-DBUILD_EXAMPLES=NO" - ]; - - postInstall = - cmakeGlue.ArgumentParser - + lib.optionalString stdenv.hostPlatform.isLinux '' - # Fix rpath so ArgumentParserToolInfo can be found. - patchelf --add-rpath "$out/lib/swift/${swiftOs}" \ - $out/lib/swift/${swiftOs}/libArgumentParser.so - ''; - }; - - Yams = mkBootstrapDerivation { - name = "Yams"; - src = generated.sources.Yams; - - # Conflicts with BUILD file on case-insensitive filesystems. - cmakeBuildDir = "_build"; - - postInstall = cmakeGlue.Yams; - }; - - llbuild = mkBootstrapDerivation { - name = "llbuild"; - src = generated.sources.swift-llbuild; - - nativeBuildInputs = lib.optional stdenv.hostPlatform.isDarwin xcbuild; - buildInputs = [ - ncursesInput - sqlite - ]; - - patches = [ - ./patches/llbuild-cmake-disable-rpath.patch - ./patches/llbuild-fix-missing-cstdint.patch - ]; - - postPatch = '' - # Substitute ncurses for curses. - find . -name CMakeLists.txt | xargs sed -i -e 's/curses/ncurses/' - - # Use absolute install names instead of rpath. - substituteInPlace \ - products/libllbuild/CMakeLists.txt \ - products/llbuildSwift/CMakeLists.txt \ - --replace-fail '@rpath' "$out/lib" - - # This subdirectory is enabled for Darwin only, but requires ObjC XCTest - # (and only Swift XCTest is open source). - substituteInPlace perftests/CMakeLists.txt \ - --replace-fail 'add_subdirectory(Xcode/' '#add_subdirectory(Xcode/' - ''; - - cmakeFlags = [ - "-DLLBUILD_SUPPORT_BINDINGS=Swift" - ]; - - postInstall = cmakeGlue.LLBuild + '' - # Install module map. - cp ../products/libllbuild/include/module.modulemap $out/include - - # Swift modules are not installed. - mkdir -p $out/${swiftModuleSubdir} - cp products/llbuildSwift/*.swift{module,doc} $out/${swiftModuleSubdir}/ - ''; - }; - - swift-driver = mkBootstrapDerivation { - name = "swift-driver"; - src = generated.sources.swift-driver; - - buildInputs = [ - Yams - llbuild - swift-system - swift-argument-parser - swift-tools-support-core - ]; - - postPatch = '' - # Tries to link against CYaml, but that's private. - substituteInPlace Sources/SwiftDriver/CMakeLists.txt \ - --replace-fail CYaml "" - ''; - - postInstall = cmakeGlue.SwiftDriver + '' - # Swift modules are not installed. - mkdir -p $out/${swiftModuleSubdir} - cp swift/*.swift{module,doc} $out/${swiftModuleSubdir}/ - ''; - }; - - swift-crypto = mkBootstrapDerivation { - name = "swift-crypto"; - src = fetchFromGitHub { - owner = "swiftlang"; - repo = "swift-crypto"; - rev = "95ba0316a9b733e92bb6b071255ff46263bbe7dc"; # 3.15.1, as opposed to the pinned version of 3.0.0 - sha256 = "sha256-RzoUBx4l12v0ZamSIAEpHHCRQXxJkXJCwVBEj7Qwg9I="; - fetchSubmodules = true; - }; - - buildInputs = [ - swift-asn1 - ]; - - patches = [ - ./patches/install-crypto-extras.patch - ]; - - postPatch = '' - # Fix use of hardcoded tool paths on Darwin. - substituteInPlace CMakeLists.txt \ - --replace-fail /usr/bin/ar $NIX_CC/bin/ar - substituteInPlace CMakeLists.txt \ - --replace-fail /usr/bin/ranlib $NIX_CC/bin/ranlib - ''; - - postInstall = cmakeGlue.SwiftCrypto + '' - # Static libs are not installed. - cp lib/*.a $out/lib/ - - # Headers are not installed. - cp -r ../Sources/CCryptoBoringSSL/include $out/include - - # Swift modules are put in the wrong place by default (and not all are linked) - mkdir -p $out/${swiftModuleSubdir} - rm -rf $out/${swiftModuleSubdir}/*.swift{module,doc} - # I assume we don't care about .swiftsourceinfo - cp swift/*.swift{module,doc} $out/${swiftModuleSubdir}/ - ''; - }; - - swift-asn1 = mkBootstrapDerivation { - name = "swift-asn1"; - src = generated.sources.swift-asn1; - - postInstall = - cmakeGlue.SwiftASN1 - + lib.optionalString (!stdenv.hostPlatform.isDarwin) '' - # SwiftASN1 uses the full target triple as the name of the swiftmodule - # (https://github.com/apple/swift-asn1/pull/103) - mkdir -p $out/${swiftModuleSubdir} - cp swift/*.swift{module,doc} $out/${swiftModuleSubdir}/ - ''; - }; - - swift-certificates = mkBootstrapDerivation { - name = "swift-certificates"; - src = generated.sources.swift-certificates; - - buildInputs = [ - swift-asn1 - swift-crypto - ]; - - postInstall = cmakeGlue.SwiftCertificates; - }; - - # Build a bootstrapping swiftpm using CMake. - swiftpm-bootstrap = mkBootstrapDerivation ( - commonAttrs - // { - pname = "swiftpm-bootstrap"; - - buildInputs = [ - llbuild - sqlite - swift-argument-parser - swift-asn1 - swift-certificates - swift-collections - swift-crypto - swift-driver - swift-system - swift-tools-support-core - ]; - - cmakeFlags = [ - "-DUSE_CMAKE_INSTALL=ON" - ]; - - postInstall = '' - for program in $out/bin/swift-*; do - wrapProgram $program --prefix PATH : ${lib.makeBinPath runtimeDeps} - done - ''; - } - ); - -in -# Build the final swiftpm with the bootstrapping swiftpm. -stdenv.mkDerivation ( - commonAttrs - // { - pname = "swiftpm"; - - nativeBuildInputs = commonAttrs.nativeBuildInputs ++ [ - pkg-config - swift - swiftpm-bootstrap - ]; - buildInputs = [ - ncursesInput - sqlite - XCTest - ]; - - configurePhase = generated.configure + '' - # Functionality provided by Xcode XCTest, but not available in - # swift-corelibs-xctest. - swiftpmMakeMutable swift-tools-support-core - substituteInPlace .build/checkouts/swift-tools-support-core/Sources/TSCTestSupport/XCTestCasePerf.swift \ - --replace-fail 'canImport(Darwin)' 'false' - - # Prevent a warning about SDK directories we don't have. - swiftpmMakeMutable swift-driver - patch -p1 -d .build/checkouts/swift-driver -i ${ - replaceVars ../swift-driver/patches/prevent-sdk-dirs-warnings.patch { - inherit (builtins) storeDir; - } - } - ''; - - buildPhase = '' - TERM=dumb swift-build -c release - ''; - - # TODO: Tests depend on indexstore-db being provided by an existing Swift - # toolchain. (ie. looks for `../lib/libIndexStore.so` relative to swiftc. - #doCheck = true; - #checkPhase = '' - # TERM=dumb swift-test -c release - #''; - - # The following is derived from Utilities/bootstrap, see install_swiftpm. - installPhase = '' - binPath="$(swift-build --show-bin-path -c release)" - - mkdir -p $out/bin $out/lib/swift - - cp $binPath/swift-package-manager $out/bin/swift-package - wrapProgram $out/bin/swift-package \ - --prefix PATH : ${lib.makeBinPath runtimeDeps} - for tool in swift-build swift-test swift-run swift-package-collection swift-experimental-destination; do - ln -s $out/bin/swift-package $out/bin/$tool - done - - installSwiftpmModule() { - mkdir -p $out/lib/swift/pm/$2 - cp $binPath/lib$1${sharedLibraryExt} $out/lib/swift/pm/$2/ - - if [[ -f $binPath/$1.swiftinterface ]]; then - cp $binPath/$1.swiftinterface $out/lib/swift/pm/$2/ - else - cp -r $binPath/$1.swiftmodule $out/lib/swift/pm/$2/ - fi - cp $binPath/$1.swiftdoc $out/lib/swift/pm/$2/ - } - installSwiftpmModule PackageDescription ManifestAPI - installSwiftpmModule PackagePlugin PluginAPI - ''; - - setupHook = ./setup-hook.sh; - - meta = { - description = "Package Manager for the Swift Programming Language"; - homepage = "https://github.com/swiftlang/swift-package-manager"; - platforms = with lib.platforms; linux ++ darwin; - license = lib.licenses.asl20; - teams = [ lib.teams.swift ]; - }; - } -) diff --git a/pkgs/development/compilers/swift/swiftpm/generated/default.nix b/pkgs/development/compilers/swift/swiftpm/generated/default.nix deleted file mode 100644 index 68e3f885d542..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/generated/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -# This file was generated by swiftpm2nix. -{ - workspaceStateFile = ./workspace-state.json; - hashes = { - "swift-argument-parser" = "sha256-qEJ329hqQyQVxtHScD7qPmWW9ZDf9bX+4xgpDlX0w5A="; - "swift-asn1" = "sha256-6NqPGUuM55YOXCMqNsqPm/3smKhSC2UIYHJSwtIiuoc="; - "swift-certificates" = "sha256-n5dE5J8f7PAVoJkIpiKrrDvB0xIil5VwtzC2mx6vz80="; - "swift-collections" = "sha256-WNj19mRvDSZNcDzZvmtS+jZxngBooiHekh3IsPZnKUQ="; - "swift-crypto" = "sha256-lcB497b/T1bHShPrjNjHthrs76pDFpU+4uN0uW4tz+4="; - "swift-driver" = "sha256-Xaz9gZuOspDb+PB67d6tXfpcs+kkDCPSkhu+eIfrb0A="; - "swift-llbuild" = "sha256-kUm8/+DWDBhuqU/kJBleqSl8/Vz478pMhx5QK2g7k0o="; - "swift-system" = "sha256-p18QHzO+NtoY/WQzOD+PfD+bjqrIWsbeEbsJLPqEAhA="; - "swift-tools-support-core" = "sha256-Pqy01AyDg7ZTyDM6lV69e6nhfhxwFTOhGFTfhcA1e9E="; - "Yams" = "sha256-AY/fIvB7THrl9GWzGJL8eDBbkcLw27tSRTGtUqmYw8k="; - }; -} diff --git a/pkgs/development/compilers/swift/swiftpm/generated/workspace-state.json b/pkgs/development/compilers/swift/swiftpm/generated/workspace-state.json deleted file mode 100644 index 4b9689d8ab30..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/generated/workspace-state.json +++ /dev/null @@ -1,178 +0,0 @@ -{ - "object": { - "artifacts": [], - "dependencies": [ - { - "basedOn": null, - "packageRef": { - "identity": "swift-argument-parser", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-argument-parser.git", - "name": "swift-argument-parser" - }, - "state": { - "checkoutState": { - "revision": "8f4d2753f0e4778c76d5f05ad16c74f707390531", - "version": "1.2.3" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-argument-parser" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-asn1", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-asn1.git", - "name": "swift-asn1" - }, - "state": { - "checkoutState": { - "revision": "f70225981241859eb4aa1a18a75531d26637c8cc", - "version": "1.4.0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-asn1" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-certificates", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-certificates.git", - "name": "swift-certificates" - }, - "state": { - "checkoutState": { - "revision": "01d7664523af5c169f26038f1e5d444ce47ae5ff", - "version": "1.0.1" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-certificates" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-collections", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-collections.git", - "name": "swift-collections" - }, - "state": { - "checkoutState": { - "revision": "d029d9d39c87bed85b1c50adee7c41795261a192", - "version": "1.0.6" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-collections" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-crypto", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-crypto.git", - "name": "swift-crypto" - }, - "state": { - "checkoutState": { - "revision": "629f0b679d0fd0a6ae823d7f750b9ab032c00b80", - "version": "3.0.0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-crypto" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-driver", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-driver.git", - "name": "swift-driver" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "b461fd4fc51be8e1f2a3f4a2184b664b8846b46f" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-driver" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-llbuild", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-llbuild.git", - "name": "llbuild" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "fd7c2e0d9279edd023ced6b0a590f8407f5472f9" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-llbuild" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-system", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-system.git", - "name": "swift-system" - }, - "state": { - "checkoutState": { - "revision": "836bc4557b74fe6d2660218d56e3ce96aff76574", - "version": "1.1.1" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-system" - }, - { - "basedOn": null, - "packageRef": { - "identity": "swift-tools-support-core", - "kind": "remoteSourceControl", - "location": "https://github.com/apple/swift-tools-support-core.git", - "name": "swift-tools-support-core" - }, - "state": { - "checkoutState": { - "branch": "release/5.10", - "revision": "90bdc2a157ebacc5d3de0c83e085d05d22ca5fa0" - }, - "name": "sourceControlCheckout" - }, - "subpath": "swift-tools-support-core" - }, - { - "basedOn": null, - "packageRef": { - "identity": "yams", - "kind": "remoteSourceControl", - "location": "https://github.com/jpsim/Yams.git", - "name": "Yams" - }, - "state": { - "checkoutState": { - "revision": "0d9ee7ea8c4ebd4a489ad7a73d5c6cad55d6fed3", - "version": "5.0.6" - }, - "name": "sourceControlCheckout" - }, - "subpath": "Yams" - } - ] - }, - "version": 6 -} diff --git a/pkgs/development/compilers/swift/swiftpm/patches/cmake-disable-rpath.patch b/pkgs/development/compilers/swift/swiftpm/patches/cmake-disable-rpath.patch deleted file mode 100644 index f5997fa7ce5b..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/patches/cmake-disable-rpath.patch +++ /dev/null @@ -1,36 +0,0 @@ -Disable rpath for the bootstrap build with CMake. - ---- a/Sources/PackageDescription/CMakeLists.txt -+++ b/Sources/PackageDescription/CMakeLists.txt -@@ -27,14 +27,11 @@ - $<$:-package-description-version$999.0>) - - if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin) -- target_link_options(PackageDescription PRIVATE -- "SHELL:-Xlinker -install_name -Xlinker @rpath/libPackageDescription.dylib") - endif() - - set_target_properties(PackageDescription PROPERTIES - Swift_MODULE_NAME PackageDescription - Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI -- INSTALL_NAME_DIR \\@rpath - OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI - OUTPUT_NAME PackageDescription - ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/ManifestAPI ---- a/Sources/PackagePlugin/CMakeLists.txt -+++ b/Sources/PackagePlugin/CMakeLists.txt -@@ -29,14 +29,11 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin) - set(SWIFT_INTERFACE_PATH ${CMAKE_BINARY_DIR}/pm/PluginAPI/PackagePlugin.swiftinterface) - target_compile_options(PackagePlugin PUBLIC - $<$:-emit-module-interface-path$${SWIFT_INTERFACE_PATH}>) -- target_link_options(PackagePlugin PRIVATE -- "SHELL:-Xlinker -install_name -Xlinker @rpath/libPackagePlugin.dylib") - endif() - - set_target_properties(PackagePlugin PROPERTIES - Swift_MODULE_NAME PackagePlugin - Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI -- INSTALL_NAME_DIR \\@rpath - OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI - OUTPUT_NAME PackagePlugin - ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/pm/PluginAPI diff --git a/pkgs/development/compilers/swift/swiftpm/patches/disable-index-store.patch b/pkgs/development/compilers/swift/swiftpm/patches/disable-index-store.patch deleted file mode 100644 index ca701ae32543..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/patches/disable-index-store.patch +++ /dev/null @@ -1,23 +0,0 @@ -The `-index-store-path` option is an Apple extension not available in our -Clang. Make it opt-in by default. - -(It is assumed the `target.type == test` check is for Xcode support, because -there is no evidence of it in swift-corelibs-xctest.) - ---- a/Sources/Build/BuildPlan/BuildPlan.swift -+++ b/Sources/Build/BuildPlan/BuildPlan.swift -@@ -111,14 +111,7 @@ - case .off: - addIndexStoreArguments = false - case .auto: -- if configuration == .debug { -- addIndexStoreArguments = true -- } else if target.type == .test { -- // Test discovery requires an index store for the test target to discover the tests -- addIndexStoreArguments = true -- } else { - addIndexStoreArguments = false -- } - } - - if addIndexStoreArguments { diff --git a/pkgs/development/compilers/swift/swiftpm/patches/disable-sandbox.patch b/pkgs/development/compilers/swift/swiftpm/patches/disable-sandbox.patch deleted file mode 100644 index b83e16e3c78f..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/patches/disable-sandbox.patch +++ /dev/null @@ -1,27 +0,0 @@ -Nix may already sandbox the build, in which case sandbox_apply will fail. - ---- a/Sources/Basics/Sandbox.swift -+++ b/Sources/Basics/Sandbox.swift -@@ -57,6 +57,8 @@ - allowNetworkConnections: [SandboxNetworkPermission] = [] - ) throws -> [String] { - #if os(macOS) -+ let env = ProcessInfo.processInfo.environment -+ if env["NIX_BUILD_TOP"] == nil || env["IN_NIX_SHELL"] != nil { - let profile = try macOSSandboxProfile( - fileSystem: fileSystem, - strictness: strictness, -@@ -65,10 +67,10 @@ - allowNetworkConnections: allowNetworkConnections - ) - return ["/usr/bin/sandbox-exec", "-p", profile] + command -- #else -+ } -+ #endif - // rdar://40235432, rdar://75636874 tracks implementing sandboxes for other platforms. - return command -- #endif - } - - /// Basic strictness level of a sandbox applied to a command line. - diff --git a/pkgs/development/compilers/swift/swiftpm/patches/disable-xctest.patch b/pkgs/development/compilers/swift/swiftpm/patches/disable-xctest.patch deleted file mode 100644 index 71aca0071e83..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/patches/disable-xctest.patch +++ /dev/null @@ -1,14 +0,0 @@ -XCTest is not fully open-source, only the Swift library parts. We don't have a -command-line runner available, so disable support. - ---- a/Sources/Commands/Utilities/TestingSupport.swift -+++ b/Sources/Commands/Utilities/TestingSupport.swift -@@ -105,7 +105,7 @@ - ) throws -> [TestSuite] { - // Run the correct tool. - var args = [String]() -- #if os(macOS) -+ #if false - let data: String = try withTemporaryFile { tempFile in - args = [try Self.xctestHelperPath(swiftTool: swiftTool).pathString, path.pathString, tempFile.path.pathString] - var env = try Self.constructTestEnvironment( diff --git a/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch b/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch deleted file mode 100644 index 877337924bbe..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/patches/fix-clang-cxx.patch +++ /dev/null @@ -1,126 +0,0 @@ -Swiftpm may invoke clang, not clang++, to compile C++. Our cc-wrapper also -doesn't pick up the arguments that enable C++ compilation in this case. Patch -swiftpm to properly invoke clang++. - ---- a/Sources/Build/BuildPlan/BuildPlan+Product.swift -+++ b/Sources/Build/BuildPlan/BuildPlan+Product.swift -@@ -53,7 +53,7 @@ - for target in dependencies.staticTargets { - if case let target as ClangTarget = target.underlyingTarget, target.isCXX { - if buildParameters.targetTriple.isDarwin() { -- buildProduct.additionalFlags += ["-lc++"] -+ buildProduct.additionalFlags += ["-lc++", "-lc++abi"] - } else if buildParameters.targetTriple.isWindows() { - // Don't link any C++ library. - } else { ---- a/Sources/Build/BuildManifest/LLBuildManifestBuilder+Clang.swift -+++ b/Sources/Build/BuildManifest/LLBuildManifestBuilder+Clang.swift -@@ -97,7 +97,7 @@ - - args += ["-c", path.source.pathString, "-o", path.object.pathString] - -- let clangCompiler = try buildParameters.toolchain.getClangCompiler().pathString -+ let clangCompiler = try buildParameters.toolchain.getClangCompiler(isCXX: isCXX).pathString - args.insert(clangCompiler, at: 0) - - let objectFileNode: Node = .file(path.object) ---- a/Sources/PackageModel/Toolchain.swift -+++ b/Sources/PackageModel/Toolchain.swift -@@ -23,7 +23,7 @@ public protocol Toolchain { - var macosSwiftStdlib: AbsolutePath { get throws } - - /// Path of the `clang` compiler. -- func getClangCompiler() throws -> AbsolutePath -+ func getClangCompiler(isCXX: Bool) throws -> AbsolutePath - - // FIXME: This is a temporary API until index store is widely available in - // the OSS clang compiler. This API should not used for any other purpose. ---- a/Sources/PackageModel/UserToolchain.swift -+++ b/Sources/PackageModel/UserToolchain.swift -@@ -57,7 +57,7 @@ public final class UserToolchain: Toolchain { - /// Only use search paths, do not fall back to `xcrun`. - let useXcrun: Bool - -- private var _clangCompiler: AbsolutePath? -+ private var _clangCompiler: [Bool: AbsolutePath] = [:] - - private let environment: EnvironmentVariables - -@@ -262,33 +262,35 @@ - } - - /// Returns the path to clang compiler tool. -- public func getClangCompiler() throws -> AbsolutePath { -+ public func getClangCompiler(isCXX: Bool) throws -> AbsolutePath { - // Check if we already computed. -- if let clang = self._clangCompiler { -+ if let clang = self._clangCompiler[isCXX] { - return clang - } - - // Check in the environment variable first. -+ let envVar = isCXX ? "CXX" : "CC" - if let toolPath = UserToolchain.lookup( -- variable: "CC", -+ variable: envVar, - searchPaths: self.envSearchPaths, - environment: environment - ) { -- self._clangCompiler = toolPath -+ self._clangCompiler[isCXX] = toolPath - return toolPath - } - - // Then, check the toolchain. -+ let tool = isCXX ? "clang++" : "clang" - do { -- if let toolPath = try? UserToolchain.getTool("clang", binDirectories: self.swiftSDK.toolset.rootPaths) { -- self._clangCompiler = toolPath -+ if let toolPath = try? UserToolchain.getTool(tool, binDirectories: self.swiftSDK.toolset.rootPaths) { -+ self._clangCompiler[isCXX] = toolPath - return toolPath - } - } - - // Otherwise, lookup it up on the system. -- let toolPath = try UserToolchain.findTool("clang", envSearchPaths: self.envSearchPaths, useXcrun: useXcrun) -- self._clangCompiler = toolPath -+ let toolPath = try UserToolchain.findTool(tool, envSearchPaths: self.envSearchPaths, useXcrun: useXcrun) -+ self._clangCompiler[isCXX] = toolPath - return toolPath - } - - ---- a/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift -+++ b/Sources/SPMBuildCore/BuildParameters/BuildParameters.swift -@@ -394,7 +394,7 @@ private struct _Toolchain: Encodable { - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(toolchain.swiftCompilerPath, forKey: .swiftCompiler) -- try container.encode(toolchain.getClangCompiler(), forKey: .clangCompiler) -+ try container.encode(toolchain.getClangCompiler(isCXX: false), forKey: .clangCompiler) - - try container.encode(toolchain.extraFlags.cCompilerFlags, forKey: .extraCCFlags) - // Maintaining `extraCPPFlags` key for compatibility with older encoding. ---- a/Sources/XCBuildSupport/XcodeBuildSystem.swift -+++ b/Sources/XCBuildSupport/XcodeBuildSystem.swift -@@ -182,7 +182,7 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem { - // Generate a table of any overriding build settings. - var settings: [String: String] = [:] - // An error with determining the override should not be fatal here. -- settings["CC"] = try? buildParameters.toolchain.getClangCompiler().pathString -+ settings["CC"] = try? buildParameters.toolchain.getClangCompiler(isCXX: false).pathString - // Always specify the path of the effective Swift compiler, which was determined in the same way as for the native build system. - settings["SWIFT_EXEC"] = buildParameters.toolchain.swiftCompilerPath.pathString - settings["LIBRARY_SEARCH_PATHS"] = "$(inherited) \(try buildParameters.toolchain.toolchainLibDir.pathString)" ---- a/Tests/BuildTests/MockBuildTestHelper.swift -+++ b/Tests/BuildTests/MockBuildTestHelper.swift -@@ -36,7 +36,7 @@ - let extraFlags = PackageModel.BuildFlags() - let installedSwiftPMConfiguration = InstalledSwiftPMConfiguration.default - -- func getClangCompiler() throws -> AbsolutePath { -+ func getClangCompiler(isCXX: Bool) throws -> AbsolutePath { - return "/fake/path/to/clang" - } - diff --git a/pkgs/development/compilers/swift/swiftpm/patches/fix-stdlib-path.patch b/pkgs/development/compilers/swift/swiftpm/patches/fix-stdlib-path.patch deleted file mode 100644 index 68698cafcdf6..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/patches/fix-stdlib-path.patch +++ /dev/null @@ -1,25 +0,0 @@ -Swiftpm looks for the Swift stdlib relative to the swift compiler, but that's a -wrapper in our case. It wants to add the stdlib to the rpath, which is -necessary for back-deployment of some features. - ---- a/Sources/PackageModel/Toolchain.swift -+++ b/Sources/PackageModel/Toolchain.swift -@@ -53,12 +53,18 @@ extension Toolchain { - - public var macosSwiftStdlib: AbsolutePath { - get throws { -+ if swiftCompilerPath.pathString.starts(with: "@storeDir@") { -+ return try AbsolutePath(validating: "@swiftLib@/lib/swift/macosx") -+ } - return try AbsolutePath(validating: "../../lib/swift/macosx", relativeTo: resolveSymlinks(swiftCompilerPath)) - } - } - - public var toolchainLibDir: AbsolutePath { - get throws { -+ if swiftCompilerPath.pathString.starts(with: "@storeDir@") { -+ return try AbsolutePath(validating: "@swiftLib@/lib") -+ } - // FIXME: Not sure if it's better to base this off of Swift compiler or our own binary. - return try AbsolutePath(validating: "../../lib", relativeTo: resolveSymlinks(swiftCompilerPath)) - } diff --git a/pkgs/development/compilers/swift/swiftpm/patches/install-crypto-extras.patch b/pkgs/development/compilers/swift/swiftpm/patches/install-crypto-extras.patch deleted file mode 100644 index bdbd1c4d596e..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/patches/install-crypto-extras.patch +++ /dev/null @@ -1,10 +0,0 @@ -Install _CryptoExtras target when building with CMake - ---- a/Sources/_CryptoExtras/CMakeLists.txt -+++ b/Sources/_CryptoExtras/CMakeLists.txt -@@ -42,4 +42,5 @@ target_link_options(_CryptoExtras PRIVATE - set_target_properties(_CryptoExtras PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) - -+_install_target(_CryptoExtras) - set_property(GLOBAL APPEND PROPERTY SWIFT_CRYPTO_EXPORTS _CryptoExtras) diff --git a/pkgs/development/compilers/swift/swiftpm/patches/llbuild-cmake-disable-rpath.patch b/pkgs/development/compilers/swift/swiftpm/patches/llbuild-cmake-disable-rpath.patch deleted file mode 100644 index 785e82cc34b6..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/patches/llbuild-cmake-disable-rpath.patch +++ /dev/null @@ -1,14 +0,0 @@ -Specifying `-platform_version` targeting macos before 10.15 causes cctools ld -to link with `@rpath`. This may have something to do with Swift ABI stability. - ---- a/products/llbuildSwift/CMakeLists.txt -+++ b/products/llbuildSwift/CMakeLists.txt -@@ -22,7 +17,7 @@ endif() - - # TODO(compnerd) move both of these outside of the CMake into the invocation - if(CMAKE_SYSTEM_NAME STREQUAL Darwin) -- add_compile_options(-target ${CMAKE_OSX_ARCHITECTURES}-apple-macosx10.10) -+ add_compile_options(-target ${CMAKE_OSX_ARCHITECTURES}-apple-macosx10.15) - if(NOT CMAKE_OSX_SYSROOT STREQUAL "") - add_compile_options(-sdk ${CMAKE_OSX_SYSROOT}) - endif() diff --git a/pkgs/development/compilers/swift/swiftpm/patches/llbuild-fix-missing-cstdint.patch b/pkgs/development/compilers/swift/swiftpm/patches/llbuild-fix-missing-cstdint.patch deleted file mode 100644 index 9dcbe6502356..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/patches/llbuild-fix-missing-cstdint.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/utils/unittest/googletest/src/gtest-death-test.cc b/utils/unittest/googletest/src/gtest-death-test.cc -index ede8378..bdef225 100644 ---- a/utils/unittest/googletest/src/gtest-death-test.cc -+++ b/utils/unittest/googletest/src/gtest-death-test.cc -@@ -33,6 +33,7 @@ - #include "gtest/gtest-death-test.h" - - #include -+#include - - #include "gtest/internal/gtest-port.h" - #include "gtest/internal/custom/gtest.h" diff --git a/pkgs/development/compilers/swift/swiftpm/patches/nix-pkgconfig-vars.patch b/pkgs/development/compilers/swift/swiftpm/patches/nix-pkgconfig-vars.patch deleted file mode 100644 index e032ce80bf90..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/patches/nix-pkgconfig-vars.patch +++ /dev/null @@ -1,28 +0,0 @@ -Swift parses .pc files manually, but this means it bypasses our pkg-config -wrapper. That wrapper normally takes care of introducing the correct -PKG_CONFIG_PATH for cross compiling. - ---- a/Sources/PackageLoading/PkgConfig.swift -+++ b/Sources/PackageLoading/PkgConfig.swift -@@ -123,14 +123,17 @@ public struct PkgConfig { - - private static var envSearchPaths: [AbsolutePath] { - get throws { -- if let configPath = ProcessEnv.vars["PKG_CONFIG_PATH"] { -+ var result: [AbsolutePath] = [] -+ for envVar in ["PKG_CONFIG_PATH", "PKG_CONFIG_PATH_FOR_TARGET"] { -+ if let configPath = ProcessEnv.vars[envVar] { - #if os(Windows) -- return try configPath.split(separator: ";").map({ try AbsolutePath(validating: String($0)) }) -+ result += try configPath.split(separator: ";").map({ try AbsolutePath(validating: String($0)) }) - #else -- return try configPath.split(separator: ":").map({ try AbsolutePath(validating: String($0)) }) -+ result += try configPath.split(separator: ":").map({ try AbsolutePath(validating: String($0)) }) - #endif - } -- return [] -+ } -+ return result - } - } - } diff --git a/pkgs/development/compilers/swift/swiftpm/setup-hook.sh b/pkgs/development/compilers/swift/swiftpm/setup-hook.sh deleted file mode 100644 index 260d874ebfd7..000000000000 --- a/pkgs/development/compilers/swift/swiftpm/setup-hook.sh +++ /dev/null @@ -1,62 +0,0 @@ -# shellcheck shell=bash - -# Build using 'swift-build'. -swiftpmBuildPhase() { - runHook preBuild - - local buildCores=1 - if [ "${enableParallelBuilding-1}" ]; then - buildCores="$NIX_BUILD_CORES" - fi - - local flagsArray=( - -j "$buildCores" - -c "${swiftpmBuildConfig-release}" - ) - concatTo flagsArray swiftpmFlags swiftpmFlagsArray - - echoCmd 'build flags' "${flagsArray[@]}" - TERM=dumb swift-build "${flagsArray[@]}" - - runHook postBuild -} - -if [ -z "${dontUseSwiftpmBuild-}" ] && [ -z "${buildPhase-}" ]; then - buildPhase=swiftpmBuildPhase -fi - -# Check using 'swift-test'. -swiftpmCheckPhase() { - runHook preCheck - - local buildCores=1 - if [ "${enableParallelBuilding-1}" ]; then - buildCores="$NIX_BUILD_CORES" - fi - - local flagsArray=( - -j "$buildCores" - -c "${swiftpmBuildConfig-release}" - ) - concatTo flagsArray swiftpmFlags swiftpmFlagsArray - - echoCmd 'check flags' "${flagsArray[@]}" - TERM=dumb swift-test "${flagsArray[@]}" - - runHook postCheck -} - -if [ -z "${dontUseSwiftpmCheck-}" ] && [ -z "${checkPhase-}" ]; then - checkPhase=swiftpmCheckPhase -fi - -# Helper used to find the binary output path. -# Useful for performing the installPhase of swiftpm packages. -swiftpmBinPath() { - local flagsArray=( - -c "${swiftpmBuildConfig-release}" - ) - concatTo flagsArray swiftpmFlags swiftpmFlagsArray - - swift-build --show-bin-path "${flagsArray[@]}" -} diff --git a/pkgs/development/compilers/swift/swiftpm2nix/default.nix b/pkgs/development/compilers/swift/swiftpm2nix/default.nix deleted file mode 100644 index 208067014730..000000000000 --- a/pkgs/development/compilers/swift/swiftpm2nix/default.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ - lib, - stdenv, - callPackage, - makeWrapper, - jq, - nurl, -}: - -stdenv.mkDerivation { - name = "swiftpm2nix"; - - nativeBuildInputs = [ makeWrapper ]; - - dontUnpack = true; - - installPhase = '' - install -vD ${./swiftpm2nix.sh} $out/bin/swiftpm2nix - wrapProgram $out/bin/$name \ - --prefix PATH : ${ - lib.makeBinPath [ - jq - nurl - ] - } - ''; - - preferLocalBuild = true; - - passthru = callPackage ./support.nix { }; - - meta = { - description = "Generate a Nix expression to fetch swiftpm dependencies"; - mainProgram = "swiftpm2nix"; - teams = [ lib.teams.swift ]; - platforms = lib.platforms.all; - }; -} diff --git a/pkgs/development/compilers/swift/swiftpm2nix/support.nix b/pkgs/development/compilers/swift/swiftpm2nix/support.nix deleted file mode 100644 index 0ddab549b98d..000000000000 --- a/pkgs/development/compilers/swift/swiftpm2nix/support.nix +++ /dev/null @@ -1,77 +0,0 @@ -{ - lib, - fetchgit, - formats, -}: -let - inherit (lib) - concatStrings - listToAttrs - makeOverridable - mapAttrsToList - nameValuePair - ; - json = formats.json { }; -in -rec { - - # Derive a pin file from workspace state. - mkPinFile = - workspaceState: - assert workspaceState.version >= 5 && workspaceState.version <= 6; - json.generate "Package.resolved" { - version = 1; - object.pins = map (dep: { - package = dep.packageRef.name; - repositoryURL = dep.packageRef.location; - state = dep.state.checkoutState; - }) workspaceState.object.dependencies; - }; - - # Make packaging helpers from swiftpm2nix generated output. - helpers = - generated: - let - inherit (import generated) workspaceStateFile hashes; - workspaceState = lib.importJSON workspaceStateFile; - pinFile = mkPinFile workspaceState; - in - rec { - - # Create fetch expressions for dependencies. - sources = listToAttrs ( - map ( - dep: - nameValuePair dep.subpath (fetchgit { - url = dep.packageRef.location; - rev = dep.state.checkoutState.revision; - sha256 = hashes.${dep.subpath}; - fetchSubmodules = true; - }) - ) workspaceState.object.dependencies - ); - - # Configure phase snippet for use in packaging. - configure = '' - mkdir -p .build/checkouts - ln -sf ${pinFile} ./Package.resolved - install -m 0600 ${workspaceStateFile} ./.build/workspace-state.json - '' - + concatStrings ( - mapAttrsToList (name: src: '' - ln -s '${src}' '.build/checkouts/${name}' - '') sources - ) - + '' - # Helper that makes a swiftpm dependency mutable by copying the source. - swiftpmMakeMutable() { - local orig="$(readlink .build/checkouts/$1)" - rm .build/checkouts/$1 - cp -r "$orig" .build/checkouts/$1 - chmod -R u+w .build/checkouts/$1 - } - ''; - - }; - -} diff --git a/pkgs/development/compilers/swift/swiftpm2nix/swiftpm2nix.sh b/pkgs/development/compilers/swift/swiftpm2nix/swiftpm2nix.sh deleted file mode 100755 index f5f9780aa95d..000000000000 --- a/pkgs/development/compilers/swift/swiftpm2nix/swiftpm2nix.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash - -# Generates a Nix expression to fetch swiftpm dependencies, and a -# configurePhase snippet to prepare a working directory for swift-build. - -set -eu -o pipefail -shopt -s lastpipe - -stateFile=".build/workspace-state.json" -if [[ ! -f "$stateFile" ]]; then - echo >&2 "Missing $stateFile. Run 'swift package resolve' first." - exit 1 -fi - -stateVersion="$(jq .version $stateFile)" -if [[ $stateVersion -lt 5 || $stateVersion -gt 6 ]]; then - echo >&2 "Unsupported $stateFile version" - exit 1 -fi - -# Iterate dependencies and prefetch. -hashes="" -jq -r '.object.dependencies[] | "\(.subpath) \(.packageRef.location) \(.state.checkoutState.revision)"' $stateFile \ -| while read -r name url rev; do - echo >&2 "-- Fetching $name" - hash="$(nurl "$url" "$rev" --json --submodules=true --fetcher=fetchgit | jq -r .args.hash)" -hashes+=" - \"$name\" = \"$hash\";" - echo >&2 -done -hashes+=$'\n'" " - -# Generate output. -mkdir -p nix -# Copy the workspace state, but clear 'artifacts'. -jq '.object.artifacts = []' < $stateFile > nix/workspace-state.json -# Build an expression for fetching sources, and preparing the working directory. -cat > nix/default.nix << EOF -# This file was generated by swiftpm2nix. -{ - workspaceStateFile = ./workspace-state.json; - hashes = {$hashes}; -} -EOF -echo >&2 "-- Generated ./nix" diff --git a/pkgs/development/compilers/swift/wrapper/default.nix b/pkgs/development/compilers/swift/wrapper/default.nix deleted file mode 100644 index 9cd9cb347a23..000000000000 --- a/pkgs/development/compilers/swift/wrapper/default.nix +++ /dev/null @@ -1,119 +0,0 @@ -{ - lib, - stdenv, - swift, - useSwiftDriver ? true, - swift-driver, - clang, -}: - -stdenv.mkDerivation ( - swift._wrapperParams - // { - pname = "swift-wrapper"; - inherit (swift) version meta; - - outputs = [ - "out" - "man" - ]; - - # Wrapper and setup hook variables. - inherit swift; - inherit (swift) - swiftOs - swiftArch - swiftModuleSubdir - swiftLibSubdir - swiftStaticModuleSubdir - swiftStaticLibSubdir - ; - swiftDriver = lib.optionalString useSwiftDriver "${swift-driver}/bin/swift-driver"; - cc_wrapper = clang.override (prev: { - extraBuildCommands = - prev.extraBuildCommands - # We need to use the resource directory corresponding to Swift’s - # version of Clang instead of passing along the one from the - # `cc-wrapper` flags. - + '' - rm -r $out/resource-root - substituteInPlace $out/nix-support/cc-cflags \ - --replace-fail \ - "-resource-dir=$out/resource-root" \ - "-resource-dir=${lib.getLib swift}/lib/swift/clang" - '' - + - lib.optionalString - ( - stdenv.targetPlatform.isLinux - && stdenv.targetPlatform.isx86 - && lib.versionAtLeast (lib.getVersion clang) "19.1" - ) - '' - # Swift bundles Clang 16, which predates -mtls-dialect=gnu2 - # support (added in Clang 19.1). The cc-wrapper adds it based - # on the system Clang version, so strip it here. - substituteInPlace $out/nix-support/add-local-cc-cflags-before.sh \ - --replace-fail "'-mtls-dialect=gnu2'" "" - '' - # We need the libc++ headers corresponding to the LLVM version of - # Swift’s Clang. - + lib.optionalString (clang.libcxx != null) '' - include -isystem "${lib.getDev swift}/include/c++/v1" > $out/nix-support/libcxx-cxxflags - ''; - }); - - env.darwinMinVersion = lib.optionalString stdenv.targetPlatform.isDarwin ( - stdenv.targetPlatform.darwinMinVersion - ); - - buildCommand = '' - mkdir -p $out/bin $out/nix-support - - # Symlink all Swift binaries first. - # NOTE: This specifically omits clang binaries. We want to hide these for - # private use by Swift only. - ln -s -t $out/bin/ $swift/bin/swift* - - # Replace specific binaries with wrappers. - for executable in swift swiftc swift-frontend; do - export prog=$swift/bin/$executable - rm $out/bin/$executable - substituteAll '${./wrapper.sh}' $out/bin/$executable - chmod a+x $out/bin/$executable - done - - ${lib.optionalString useSwiftDriver '' - # Symlink swift-driver executables. - ln -s -t $out/bin/ ${swift-driver}/bin/* - ''} - - ln -s ${swift.man} $man - - # This link is here because various tools (swiftpm) check for stdlib - # relative to the swift compiler. It's fine if this is for build-time - # stuff, but we should patch all cases were it would end up in an output. - ln -s ${swift.lib}/lib $out/lib - - substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook - - # Propagate any propagated inputs from the unwrapped Swift compiler, if any. - if [ -e "$swift/nix-support" ]; then - for input in "$swift/nix-support/"*propagated*; do - cp "$input" "$out/nix-support/$(basename "$input")" - done - fi - ''; - - passthru = { - inherit swift; - inherit (swift) - swiftOs - swiftArch - swiftModuleSubdir - swiftLibSubdir - tests - ; - }; - } -) diff --git a/pkgs/development/compilers/swift/wrapper/setup-hook.sh b/pkgs/development/compilers/swift/wrapper/setup-hook.sh deleted file mode 100644 index 398f19977f66..000000000000 --- a/pkgs/development/compilers/swift/wrapper/setup-hook.sh +++ /dev/null @@ -1,28 +0,0 @@ -# Add import paths for build inputs. -swiftWrapper_addImports () { - # Include subdirectories following both the Swift platform convention, and - # a simple `lib/swift` for Nix convenience. - for subdir in @swiftModuleSubdir@ @swiftStaticModuleSubdir@ lib/swift; do - if [[ -d "$1/$subdir" ]]; then - export NIX_SWIFTFLAGS_COMPILE+=" -I $1/$subdir" - fi - done - for subdir in @swiftLibSubdir@ @swiftStaticLibSubdir@ lib/swift; do - if [[ -d "$1/$subdir" ]]; then - export NIX_LDFLAGS+=" -L $1/$subdir" - fi - done -} - -addEnvHooks "$targetOffset" swiftWrapper_addImports - -# Use a postHook here because we rely on NIX_CC, which is set by the cc-wrapper -# setup hook, so delay until we're sure it was run. -swiftWrapper_postHook () { - # On Darwin, libc also contains Swift modules. - if [[ -e "$NIX_CC/nix-support/orig-libc" ]]; then - swiftWrapper_addImports "$(<$NIX_CC/nix-support/orig-libc)" - fi -} - -postHooks+=(swiftWrapper_postHook) diff --git a/pkgs/development/compilers/swift/wrapper/wrapper.sh b/pkgs/development/compilers/swift/wrapper/wrapper.sh deleted file mode 100644 index 77f7c31d6812..000000000000 --- a/pkgs/development/compilers/swift/wrapper/wrapper.sh +++ /dev/null @@ -1,313 +0,0 @@ -#! @shell@ -# NOTE: This wrapper is derived from cc-wrapper.sh, and is hopefully somewhat -# diffable with the original, so changes can be merged if necessary. -set -eu -o pipefail +o posix -shopt -s nullglob - -if (( "${NIX_DEBUG:-0}" >= 7 )); then - set -x -fi - -cc_wrapper="@cc_wrapper@" - -source $cc_wrapper/nix-support/utils.bash - -source $cc_wrapper/nix-support/darwin-sdk-setup.bash - -expandResponseParams "$@" - -# Check if we should wrap this Swift invocation at all, and how. Specifically, -# there are some internal tools we don't wrap, plus swift-frontend doesn't link -# and doesn't understand linker flags. This follows logic in -# `lib/DriverTool/driver.cpp`. -prog=@prog@ -progName="$(basename "$prog")" -firstArg="${params[0]:-}" -isFrontend=0 -isRepl=0 - -# These checks follow `shouldRunAsSubcommand`. -if [[ "$progName" == swift ]]; then - case "$firstArg" in - "" | -* | *.* | */* | repl) - ;; - *) - exec "swift-$firstArg" "${params[@]:1}" - ;; - esac -fi - -# These checks follow the first part of `run_driver`. -# -# NOTE: The original function short-circuits, but we can't here, because both -# paths must be wrapped. So we use an 'isFrontend' flag instead. -case "$firstArg" in - -frontend) - isFrontend=1 - # Ensure this stays the first argument. - params=( "${params[@]:1}" ) - extraBefore+=( "-frontend" ) - ;; - -modulewrap) - # Don't wrap this integrated tool. - exec "$prog" "${params[@]}" - ;; - repl) - isRepl=1 - params=( "${params[@]:1}" ) - ;; - --driver-mode=*) - ;; - *) - if [[ "$progName" == swift-frontend ]]; then - isFrontend=1 - fi - ;; -esac - -# For many tasks, Swift reinvokes swift-driver, the new driver implementation -# written in Swift. It needs some help finding the executable, though, and -# reimplementing the logic here is little effort. These checks follow -# `shouldDisallowNewDriver`. -if [[ - $isFrontend = 0 && - -n "@swiftDriver@" && - -z "${SWIFT_USE_OLD_DRIVER:-}" && - ( "$progName" == "swift" || "$progName" == "swiftc" ) -]]; then - prog=@swiftDriver@ - # Driver mode must be the very first argument. - extraBefore+=( "--driver-mode=$progName" ) - if [[ $isRepl = 1 ]]; then - extraBefore+=( "-repl" ) - fi - - # Ensure swift-driver invokes the unwrapped frontend (instead of finding - # the wrapped one via PATH), because we don't have to wrap a second time. - export SWIFT_DRIVER_SWIFT_FRONTEND_EXEC="@swift@/bin/swift-frontend" - - # Ensure swift-driver can find the LLDB with Swift support for the REPL. - export SWIFT_DRIVER_LLDB_EXEC="@swift@/bin/lldb" -fi - -path_backup="$PATH" - -# That @-vars are substituted separately from bash evaluation makes -# shellcheck think this, and others like it, are useless conditionals. -# shellcheck disable=SC2157 -if [[ -n "@coreutils_bin@" && -n "@gnugrep_bin@" ]]; then - PATH="@coreutils_bin@/bin:@gnugrep_bin@/bin" -fi - -# Parse command line options and set several variables. -# For instance, figure out if linker flags should be passed. -# GCC prints annoying warnings when they are not needed. -isCxx=0 -dontLink=$isFrontend - -for p in "${params[@]}"; do - case "$p" in - -cxx-interoperability-mode=default | -enable-cxx-interop | -enable-experimental-cxx-interop) - isCxx=1 ;; - esac -done - -# NOTE: We don't modify these for Swift, but sourced scripts may use them. -cxxInclude=1 -cxxLibrary=1 -cInclude=1 - -linkType=$(checkLinkType "${params[@]}") - -# Optionally filter out paths not refering to the store. -if [[ "${NIX_ENFORCE_PURITY:-}" = 1 && -n "$NIX_STORE" ]]; then - kept=() - nParams=${#params[@]} - declare -i n=0 - while (( "$n" < "$nParams" )); do - p=${params[n]} - p2=${params[n+1]:-} # handle `p` being last one - n+=1 - - skipNext=false - path="" - case "$p" in - -[IL]/*) path=${p:2} ;; - -[IL]) path=$p2 skipNext=true ;; - esac - - if [[ -n $path ]] && badPath "$path"; then - skip "$path" - $skipNext && n+=1 - continue - fi - - kept+=("$p") - done - # Old bash empty array hack - params=(${kept+"${kept[@]}"}) -fi - -# Flirting with a layer violation here. -if [ -z "${NIX_BINTOOLS_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then - source @bintools@/nix-support/add-flags.sh -fi - -# Put this one second so libc ldflags take priority. -if [ -z "${NIX_CC_WRAPPER_FLAGS_SET_@suffixSalt@:-}" ]; then - source $cc_wrapper/nix-support/add-flags.sh -fi - -# Only add darwin min version flag and set up `DEVELOPER_DIR` if a default darwin min version is set, -# which is a signal that we're targeting darwin. (Copied from add-flags in libc but tailored for Swift). -if [ "@darwinMinVersion@" ]; then - # Make sure the wrapped Swift compiler can find the overlays in the SDK. - NIX_SWIFTFLAGS_COMPILE+=" -I $SDKROOT/usr/lib/swift" - NIX_LDFLAGS_@suffixSalt@+=" -L $SDKROOT/usr/lib/swift" -fi - -if [[ "$isCxx" = 1 ]]; then - if [[ "$cxxInclude" = 1 ]]; then - NIX_CFLAGS_COMPILE_@suffixSalt@+=" $NIX_CXXSTDLIB_COMPILE_@suffixSalt@" - fi - if [[ "$cxxLibrary" = 1 ]]; then - NIX_CFLAGS_LINK_@suffixSalt@+=" $NIX_CXXSTDLIB_LINK_@suffixSalt@" - fi -fi - -source $cc_wrapper/nix-support/add-hardening.sh - -# Add the flags for the C compiler proper. -addCFlagsToList() { - declare -n list="$1" - shift - - for ((i = 1; i <= $#; i++)); do - local val="${!i}" - case "$val" in - # Pass through using -Xcc, but also convert to Swift -I. - # These have slightly different meaning for Clang, but Swift - # doesn't have exact equivalents. - -isystem | -cxx-isystem | -idirafter) - i=$((i + 1)) - list+=("-Xcc" "$val" "-Xcc" "${!i}" "-I" "${!i}") - ;; - # Simple rename. - -iframework) - i=$((i + 1)) - list+=("-Fsystem" "${!i}") - ;; - # Pass through verbatim. - -I | -Fsystem) - i=$((i + 1)) - list+=("${val}" "${!i}") - ;; - -I* | -L* | -F*) - list+=("${val}") - ;; - # Pass through using -Xcc. - *) - list+=("-Xcc" "$val") - ;; - esac - done -} -for i in ${NIX_SWIFTFLAGS_COMPILE:-}; do - extraAfter+=("$i") -done -for i in ${NIX_SWIFTFLAGS_COMPILE_BEFORE:-}; do - extraBefore+=("$i") -done -addCFlagsToList extraAfter $NIX_CFLAGS_COMPILE_@suffixSalt@ -addCFlagsToList extraBefore ${hardeningCFlags[@]+"${hardeningCFlags[@]}"} $NIX_CFLAGS_COMPILE_BEFORE_@suffixSalt@ - -if [ "$dontLink" != 1 ]; then - - # Add the flags that should only be passed to the compiler when - # linking. - addCFlagsToList extraAfter $(filterRpathFlags "$linkType" $NIX_CFLAGS_LINK_@suffixSalt@) - - # Add the flags that should be passed to the linker (and prevent - # `ld-wrapper' from adding NIX_LDFLAGS_@suffixSalt@ again). - for i in $(filterRpathFlags "$linkType" $NIX_LDFLAGS_BEFORE_@suffixSalt@); do - extraBefore+=("-Xlinker" "$i") - done - if [[ "$linkType" == dynamic && -n "$NIX_DYNAMIC_LINKER_@suffixSalt@" ]]; then - extraBefore+=("-Xlinker" "-dynamic-linker=$NIX_DYNAMIC_LINKER_@suffixSalt@") - fi - for i in $(filterRpathFlags "$linkType" $NIX_LDFLAGS_@suffixSalt@); do - if [ "${i:0:3}" = -L/ ]; then - extraAfter+=("$i") - else - extraAfter+=("-Xlinker" "$i") - fi - done - export NIX_LINK_TYPE_@suffixSalt@=$linkType -fi - -# TODO: If we ever need to expand functionality of this hook, it may no longer -# be compatible with Swift. Right now, it is only used on Darwin to force -# -target, which also happens to work with Swift. -# As of 369cc5c66b1efdbca2f136aa0055fedca1117304 (#445119), this hook also sets -# the -Werror=unguarded-availability flag, which Swift can't accept. We prefix -# that flag with -Xcc in the for loop below -if [[ -e $cc_wrapper/nix-support/add-local-cc-cflags-before.sh ]]; then - source $cc_wrapper/nix-support/add-local-cc-cflags-before.sh -fi - -for ((i=0; i < ${#extraBefore[@]}; i++));do - case "${extraBefore[i]}" in - -target) - i=$((i + 1)) - # On Darwin only, need to change 'aarch64' to 'arm64'. - extraBefore[i]="${extraBefore[i]/aarch64-apple-/arm64-apple-}" - # On Darwin, Swift requires the triple to be annotated with a version. - # TODO: Assumes macOS. - extraBefore[i]="${extraBefore[i]/-apple-darwin/-apple-macosx${MACOSX_DEPLOYMENT_TARGET:-11.0}}" - ;; - -march=*|-mcpu=*|-mfloat-abi=*|-mfpu=*|-mmode=*|-mthumb|-marm|-mtune=*|-Werror=*) - [[ i -gt 0 && ${extraBefore[i-1]} == -Xcc ]] && continue - extraBefore=( - "${extraBefore[@]:0:i}" - -Xcc - "${extraBefore[@]:i:${#extraBefore[@]}}" - ) - i=$((i + 1)) - ;; - esac -done - -# As a very special hack, if the arguments are just `-v', then don't -# add anything. This is to prevent `gcc -v' (which normally prints -# out the version number and returns exit code 0) from printing out -# `No input files specified' and returning exit code 1. -if [ "$*" = -v ]; then - extraAfter=() - extraBefore=() -fi - -# Optionally print debug info. -if (( "${NIX_DEBUG:-0}" >= 1 )); then - # Old bash workaround, see ld-wrapper for explanation. - echo "extra flags before to $prog:" >&2 - printf " %q\n" ${extraBefore+"${extraBefore[@]}"} >&2 - echo "original flags to $prog:" >&2 - printf " %q\n" ${params+"${params[@]}"} >&2 - echo "extra flags after to $prog:" >&2 - printf " %q\n" ${extraAfter+"${extraAfter[@]}"} >&2 -fi - -PATH="$path_backup" -# Old bash workaround, see above. - -if (( "${NIX_CC_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then - exec "$prog" @<(printf "%q\n" \ - ${extraBefore+"${extraBefore[@]}"} \ - ${params+"${params[@]}"} \ - ${extraAfter+"${extraAfter[@]}"}) -else - exec "$prog" \ - ${extraBefore+"${extraBefore[@]}"} \ - ${params+"${params[@]}"} \ - ${extraAfter+"${extraAfter[@]}"} -fi diff --git a/pkgs/development/compilers/swift/xctest/default.nix b/pkgs/development/compilers/swift/xctest/default.nix deleted file mode 100644 index 8b8128c206a6..000000000000 --- a/pkgs/development/compilers/swift/xctest/default.nix +++ /dev/null @@ -1,61 +0,0 @@ -{ - lib, - stdenv, - callPackage, - cmake, - ninja, - swift, - Foundation, - DarwinTools, -}: - -let - sources = callPackage ../sources.nix { }; -in -stdenv.mkDerivation { - pname = "swift-corelibs-xctest"; - - inherit (sources) version; - src = sources.swift-corelibs-xctest; - - outputs = [ "out" ]; - - nativeBuildInputs = [ - cmake - ninja - swift - ] - ++ lib.optional stdenv.hostPlatform.isDarwin DarwinTools; # sw_vers - buildInputs = [ Foundation ]; - - postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' - # On Darwin only, Swift uses arm64 as cpu arch. - substituteInPlace cmake/modules/SwiftSupport.cmake \ - --replace-fail '"aarch64" PARENT_SCOPE' '"arm64" PARENT_SCOPE' - ''; - - preConfigure = '' - # On aarch64-darwin, our minimum target is 11.0, but we can target lower, - # and some dependants require a lower target. Harmless on non-Darwin. - export MACOSX_DEPLOYMENT_TARGET=10.12 - ''; - - cmakeFlags = lib.optional stdenv.hostPlatform.isDarwin "-DUSE_FOUNDATION_FRAMEWORK=ON"; - - postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' - # Darwin normally uses the Xcode version of XCTest. Installing - # swift-corelibs-xctest is probably not officially supported, but we have - # no alternative. Fix up the installation here. - mv $out/lib/swift/darwin/${swift.swiftArch}/* $out/lib/swift/darwin - rmdir $out/lib/swift/darwin/${swift.swiftArch} - mv $out/lib/swift/darwin $out/lib/swift/${swift.swiftOs} - ''; - - meta = { - description = "Framework for writing unit tests in Swift"; - homepage = "https://github.com/apple/swift-corelibs-xctest"; - platforms = lib.platforms.all; - license = lib.licenses.asl20; - teams = [ lib.teams.swift ]; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 06d11d13177f..701005953e3e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -4102,7 +4102,6 @@ with pkgs; ]; }; - swiftPackages = recurseIntoAttrs (callPackage ../development/compilers/swift { }); swiftPackages_ng = recurseIntoAttrs (callPackage ./swift-packages.nix { }); inherit (swiftPackages_ng) fetchSwiftPMDeps