swift: 5.7.3 -> 5.8

This commit is contained in:
Stéphan Kochen 2023-04-01 21:43:12 +02:00
parent 88be91f08c
commit f85d12198f
29 changed files with 1911 additions and 206 deletions

View file

@ -99,7 +99,6 @@ let
# "clang-builtin-headers"
"stdlib"
"sdk-overlay"
"parser-lib"
"static-mirror-lib"
"editor-integration"
# "tools"
@ -257,6 +256,7 @@ in stdenv.mkDerivation {
${copySource "llvm-project"}
${copySource "swift"}
${copySource "swift-experimental-string-processing"}
${copySource "swift-syntax"}
${lib.optionalString
(!stdenv.isDarwin)
(copySource "swift-corelibs-libdispatch")}
@ -276,9 +276,13 @@ in stdenv.mkDerivation {
-e 's|/bin/cp|${coreutils}/bin/cp|g' \
-e 's|/usr/bin/file|${file}/bin/file|g'
patch -p1 -d swift -i ${./patches/swift-cmake-3.25-compat.patch}
patch -p1 -d swift -i ${./patches/swift-wrap.patch}
patch -p1 -d swift -i ${./patches/swift-nix-resource-root.patch}
patch -p1 -d swift -i ${./patches/swift-linux-fix-libc-paths.patch}
patch -p1 -d swift -i ${./patches/swift-linux-fix-linking.patch}
patch -p1 -d swift -i ${./patches/swift-darwin-libcxx-flags.patch}
patch -p1 -d swift -i ${./patches/swift-darwin-link-cxxabi.patch}
patch -p1 -d swift -i ${substituteAll {
src = ./patches/swift-darwin-plistbuddy-workaround.patch;
inherit swiftArch;
@ -287,8 +291,6 @@ in stdenv.mkDerivation {
src = ./patches/swift-prevent-sdk-dirs-warning.patch;
inherit (builtins) storeDir;
}}
substituteInPlace swift/cmake/modules/SwiftConfigureSDK.cmake \
--replace '/usr/include' "${stdenv.cc.libc_dev}/include"
# This patch needs to know the lib output location, so must be substituted
# in the same derivation as the compiler.
@ -321,8 +323,8 @@ in stdenv.mkDerivation {
''}
# 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
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
@ -342,7 +344,7 @@ in stdenv.mkDerivation {
rm swift/test/Serialization/restrict-swiftmodule-to-revision.swift
# This test was flaky in ofborg, see #186476
rm swift/test/AutoDiff/compiler_crashers_fixed/sr14290-missing-debug-scopes-in-pullback-trampoline.swift
rm swift/test/AutoDiff/compiler_crashers_fixed/issue-56649-missing-debug-scopes-in-pullback-trampoline.swift
patchShebangs .
@ -446,7 +448,8 @@ in stdenv.mkDerivation {
-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
-DEXPERIMENTAL_STRING_PROCESSING_SOURCE_DIR=$SWIFT_SOURCE_ROOT/swift-experimental-string-processing
-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.isDarwin then "ON" else "OFF"}
"
@ -501,6 +504,7 @@ in stdenv.mkDerivation {
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
@ -579,7 +583,7 @@ in stdenv.mkDerivation {
# 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-14{-unwrapped,}
mv llvm/bin/clang-15{-unwrapped,}
mv swift/bin/swift-frontend{-unwrapped,}
mkdir $out $lib

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,63 @@
On Darwin, the SDK is a directory of stubs, and libc++ lives separately. We
need to patch the CMake files in several places to make the build for C++
interop succeed. The required flags can be read from cc-wrapper support files.
--- a/SwiftCompilerSources/CMakeLists.txt
+++ b/SwiftCompilerSources/CMakeLists.txt
@@ -105,18 +105,11 @@ function(add_swift_compiler_modules_library name)
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
set(sdk_option ${sdk_option} "-resource-dir" "${swift_exec_bin_dir}/../bootstrapping0/lib/swift")
endif()
- if(NOT EXISTS "${sdk_path}/usr/include/c++")
- # Darwin SDKs in Xcode 12 or older do not include libc++, which prevents clang from finding libc++ when invoked
- # from ClangImporter. This results in build errors. To workaround this, let's explicitly pass the path to libc++
- # to clang.
- message(WARNING "Building with an outdated Darwin SDK: libc++ missing from the ${SWIFT_HOST_VARIANT_SDK} SDK. Will use libc++ from the toolchain.")
- get_filename_component(absolute_libcxx_path "${CMAKE_C_COMPILER}/../../include/c++/v1" REALPATH)
- if (EXISTS "${absolute_libcxx_path}")
- set(sdk_option ${sdk_option} "-Xcc" "-isystem" "-Xcc" "${absolute_libcxx_path}")
- else()
- message(ERROR "libc++ not found in the toolchain.")
- endif()
- endif()
+ file(READ "$ENV{NIX_CC}/nix-support/libcxx-cxxflags" nix_libcxx_cxxflags)
+ separate_arguments(nix_libcxx_cxxflags)
+ foreach(nix_libcxx_cxxflag ${nix_libcxx_cxxflags})
+ set(sdk_option ${sdk_option} "-Xcc" "${nix_libcxx_cxxflag}")
+ endforeach()
elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE")
set(sdk_option "-sdk" "${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_ARCH_${SWIFT_HOST_VARIANT_ARCH}_PATH}")
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
--- a/cmake/modules/SwiftConfigureSDK.cmake
+++ b/cmake/modules/SwiftConfigureSDK.cmake
@@ -270,6 +270,18 @@ macro(configure_sdk_darwin
# Add this to the list of known SDKs.
list(APPEND SWIFT_CONFIGURED_SDKS "${prefix}")
+ set(cxx_overlay_opt "")
+ if("${prefix}" STREQUAL "OSX")
+ file(READ "$ENV{NIX_CC}/nix-support/libcxx-cxxflags" nix_libcxx_cxxflags)
+ separate_arguments(nix_libcxx_cxxflags)
+ foreach(nix_libcxx_cxxflag ${nix_libcxx_cxxflags})
+ set(cxx_overlay_opt ${cxx_overlay_opt} "-Xcc" "${nix_libcxx_cxxflag}")
+ endforeach()
+ endif()
+ set(SWIFT_SDK_${prefix}_CXX_OVERLAY_SWIFT_COMPILE_FLAGS
+ ${cxx_overlay_opt}
+ CACHE STRING "Extra flags for compiling the C++ overlay")
+
_report_sdk("${prefix}")
endmacro()
--- a/stdlib/public/Cxx/std/CMakeLists.txt
+++ b/stdlib/public/Cxx/std/CMakeLists.txt
@@ -145,6 +145,9 @@ add_swift_target_library(swiftstd STATIC NO_LINK_NAME IS_STDLIB
SWIFT_COMPILE_FLAGS_LINUX
${SWIFT_SDK_LINUX_CXX_OVERLAY_SWIFT_COMPILE_FLAGS}
+ SWIFT_COMPILE_FLAGS_OSX
+ ${SWIFT_SDK_OSX_CXX_OVERLAY_SWIFT_COMPILE_FLAGS}
+
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
TARGET_SDKS ALL_APPLE_PLATFORMS LINUX
INSTALL_IN_COMPONENT compiler

View file

@ -0,0 +1,14 @@
This patches the stdlib backdeploy static lib to have its users link c++abi.
Without this, later steps that try to link this fail looking for global
new/delete operators (__Znwm/__ZdlPv).
--- a/stdlib/toolchain/Compatibility56/Overrides.cpp
+++ b/stdlib/toolchain/Compatibility56/Overrides.cpp
@@ -23,6 +23,7 @@
using namespace swift;
__asm__ (".linker_option \"-lc++\"");
+__asm__ (".linker_option \"-lc++abi\"");
#define OVERRIDE(name, ret, attrs, ccAttrs, namespace, typedArgs, namedArgs) \
Override_ ## name name;

View file

@ -0,0 +1,48 @@
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
@@ -120,6 +120,7 @@ static clang::driver::Driver createClangDriver(const ASTContext &ctx) {
/// \return a path without dots (`../`, './').
static llvm::Optional<Path>
findFirstIncludeDir(const llvm::opt::InputArgList &args,
+ const llvm::opt::ArgList &DriverArgs,
const ArrayRef<const char *> expectedFileNames) {
// C++ stdlib paths are added as `-internal-isystem`.
std::vector<std::string> includeDirs =
@@ -128,6 +129,14 @@ findFirstIncludeDir(const llvm::opt::InputArgList &args,
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 `-isystem`.
+ llvm::append_range(includeDirs,
+ DriverArgs.getAllArgValues(
+ clang::driver::options::OPT_isystem));
for (const auto &includeDir : includeDirs) {
Path dir(includeDir);
@@ -193,7 +202,7 @@ getGlibcFileMapping(ASTContext &ctx) {
// Ideally we would check that all of the headers referenced from the
// modulemap are present.
Path glibcDir;
- if (auto dir = findFirstIncludeDir(parsedIncludeArgs,
+ if (auto dir = findFirstIncludeDir(parsedIncludeArgs, clangDriverArgs,
{"inttypes.h", "unistd.h", "stdint.h"})) {
glibcDir = dir.value();
} else {
@@ -251,7 +260,7 @@ getLibStdCxxFileMapping(ASTContext &ctx) {
auto parsedStdlibArgs = parseClangDriverArgs(clangDriver, stdlibArgStrings);
Path cxxStdlibDir;
- if (auto dir = findFirstIncludeDir(parsedStdlibArgs,
+ if (auto dir = findFirstIncludeDir(parsedStdlibArgs, clangDriverArgs,
{"cstdlib", "string", "vector"})) {
cxxStdlibDir = dir.value();
} else {

View file

@ -7,15 +7,15 @@ second (ToolChains.cpp) happens when Swift is used to link the final product.
--- a/lib/ClangImporter/ClangImporter.cpp
+++ b/lib/ClangImporter/ClangImporter.cpp
@@ -68,6 +68,7 @@
@@ -73,6 +73,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Memory.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/YAMLParser.h"
#include "llvm/Support/YAMLTraits.h"
#include <algorithm>
@@ -809,6 +810,17 @@ importer::addCommonInvocationArguments(
@@ -786,6 +787,17 @@ importer::addCommonInvocationArguments(
const std::string &overrideResourceDir = importerOpts.OverrideResourceDir;
if (overrideResourceDir.empty()) {
@ -33,7 +33,7 @@ second (ToolChains.cpp) happens when Swift is used to link the final product.
llvm::SmallString<128> resourceDir(searchPathOpts.RuntimeResourcePath);
// Adjust the path to refer to our copy of the Clang resource directory
@@ -824,6 +836,7 @@ importer::addCommonInvocationArguments(
@@ -801,6 +813,7 @@ importer::addCommonInvocationArguments(
// Set the Clang resource directory to the path we computed.
invocationArgStrs.push_back("-resource-dir");
invocationArgStrs.push_back(std::string(resourceDir.str()));
@ -43,7 +43,7 @@ second (ToolChains.cpp) happens when Swift is used to link the final product.
invocationArgStrs.push_back(overrideResourceDir);
--- a/lib/Driver/ToolChains.cpp
+++ b/lib/Driver/ToolChains.cpp
@@ -1372,10 +1372,20 @@ void ToolChain::getClangLibraryPath(const ArgList &Args,
@@ -1393,10 +1393,20 @@ void ToolChain::getClangLibraryPath(const ArgList &Args,
SmallString<128> &LibPath) const {
const llvm::Triple &T = getTriple();

View file

@ -2,7 +2,7 @@
, pkgs
, newScope
, darwin
, llvmPackages_latest
, llvmPackages_15
, overrideCC
}:
@ -15,20 +15,21 @@ let
# Re-export this so we can rely on the minimum Swift SDK elsewhere.
apple_sdk = pkgs.darwin.apple_sdk_11_0;
# Our current Clang on Darwin is v11, but we need at least v12. The
# following applies the newer Clang with the same libc overrides as
# `apple_sdk.stdenv`.
# Swift builds its own Clang for internal use. We wrap that clang with a
# cc-wrapper derived from the clang configured below. Because cc-wrapper
# applies a specific resource-root, the two versions are best matched, or
# we'll often run into compilation errors.
#
# If 'latest' becomes an issue, recommend replacing it with v14, which is
# currently closest to the official Swift builds.
# The following selects the correct Clang version, matching the version
# used in Swift, and applies the same libc overrides as `apple_sdk.stdenv`.
clang = if pkgs.stdenv.isDarwin
then
llvmPackages_latest.clang.override rec {
llvmPackages_15.clang.override rec {
libc = apple_sdk.Libsystem;
bintools = pkgs.bintools.override { inherit libc; };
}
else
llvmPackages_latest.clang;
llvmPackages_15.clang;
# Overrides that create a useful environment for swift packages, allowing
# packaging with `swiftPackages.callPackage`. These are similar to

View file

@ -6,6 +6,7 @@
, swiftpm2nix
, Foundation
, XCTest
, pkg-config
, sqlite
, ncurses
, CryptoKit
@ -31,6 +32,7 @@ stdenv.mkDerivation {
buildInputs = [
Foundation
XCTest
pkg-config
sqlite
ncursesInput
]

View file

@ -2,15 +2,16 @@
{
workspaceStateFile = ./workspace-state.json;
hashes = {
"indexstore-db" = "05d7l3fgcvbw8plaky3pgjm03x20a63z9r14njxg5qm2zcp5m6jx";
"indexstore-db" = "0lf96m82s8f6lv67wbcnm9ii01fgw4bsr4vn2xp07ydfj1iqy8il";
"swift-argument-parser" = "1jph9w7lk9nr20fsv2c8p4hisx3dda817fh7pybd0r0j1jwa9nmw";
"swift-collections" = "1k6sjx5rqmp3gklny77b480hyzy6gkhpi23r0s8ljfbrcwawgnan";
"swift-crypto" = "020b8q4ss2k7a65r5dgh59z40i6sn7ij1allxkh8c8a9d0jzn313";
"swift-driver" = "1lcb5wqragc74nd0fjnk47lyph9hs0i9cps1mplvp2i91yzjqk05";
"swift-llbuild" = "07zbp2dyfqd1bnyg7snpr9brn40jf22ivly5v10mql3hrg76a18h";
"swift-package-manager" = "0a3vahdkj35n0dkinwcgybgfb9dnq2lq1nknn874r38xbj3mhlff";
"swift-crypto" = "0kllp7j0hd8k67l9b9zr2c3ddc5bvshldchzivhcz3q31qvq9ag8";
"swift-driver" = "0cbvddj54k3sbw0vzlmzhccs7h43hi5kq6i3n2i0mysz3bf0c6zg";
"swift-llbuild" = "106vnssh6pgy5s9dnq1hi1c9v2wkfydqgncg5dy7c9n23iisjy3s";
"swift-package-manager" = "1d1ngh7da42dm0rwkw7jzxa63a1rpc88wimm85w2j59cm446pk9k";
"swift-syntax" = "05394mzznmcrw246lyzsjsn1fmilj98jgkjyyxr2ynhnbgzp2jl2";
"swift-system" = "0402hkx2q2dv27gccnn8ma79ngvwiwzkhcv4zlcdldmy6cgi0px7";
"swift-tools-support-core" = "134f9x44jnzdy8cwi6hs372dwbyqvr4qmsjzjy25wzpyv6m9rhrz";
"Yams" = "1893y13sis2aimi1a5kgkczbf06z4yig054xb565yg2xm13srb45";
"swift-tools-support-core" = "1qvblyiazv58qwyxgyk2dh5ymbab3y70vm2q81qs6rmv43hs8ciz";
"Yams" = "0b4lprxl4f6yqq0djnp394mxgmsxm2pljr7fh4f6ihdhnpwfsfvl";
};
}

View file

@ -12,8 +12,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "9305648b0a8700434fa2e55eeacf7c7f4402a0d5"
"branch": "release/5.8",
"revision": "6caa12ab3bb6245eee4e09dce7677e64720c6545"
},
"name": "sourceControlCheckout"
},
@ -63,8 +63,8 @@
},
"state": {
"checkoutState": {
"revision": "ddb07e896a2a8af79512543b1c7eb9797f8898a5",
"version": "1.1.7"
"revision": "75ec60b8b4cc0f085c3ac414f3dca5625fa3588e",
"version": "2.2.4"
},
"name": "sourceControlCheckout"
},
@ -80,8 +80,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "82b274af66cfbb8f3131677676517b34d01e30fd"
"branch": "release/5.8",
"revision": "7cfe0c0b6e6297efe88a3ce34e6138ee7eda969e"
},
"name": "sourceControlCheckout"
},
@ -97,8 +97,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "564424db5fdb62dcb5d863bdf7212500ef03a87b"
"branch": "release/5.8",
"revision": "dccfc2e127a34b89a849407594cf2d604b598ba9"
},
"name": "sourceControlCheckout"
},
@ -114,13 +114,30 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "c6e40adbfc78acc60ca464ae482b56442f9f34f4"
"branch": "release/5.8",
"revision": "6651d98a4ce3c6faa82768256ca286412bf4a04d"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-package-manager"
},
{
"basedOn": null,
"packageRef": {
"identity": "swift-syntax",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-syntax.git",
"name": "SwiftSyntax"
},
"state": {
"checkoutState": {
"branch": "release/5.8",
"revision": "cd793adf5680e138bf2bcbaacc292490175d0dcd"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-syntax"
},
{
"basedOn": null,
"packageRef": {
@ -148,8 +165,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "286b48b1d73388e1d49b2bb33aabf995838104e3"
"branch": "release/5.8",
"revision": "ac4871e01ef338cb95b5d28328cab0ec1dfae935"
},
"name": "sourceControlCheckout"
},
@ -165,8 +182,8 @@
},
"state": {
"checkoutState": {
"revision": "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa",
"version": "4.0.6"
"revision": "f47ba4838c30dbd59998a4e4c87ab620ff959e8a",
"version": "5.0.5"
},
"name": "sourceControlCheckout"
},
@ -174,5 +191,5 @@
}
]
},
"version": 5
"version": 6
}

View file

@ -5,20 +5,21 @@ 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.7.3";
version = "5.8";
hashes = {
llvm-project = "sha256-IDtLPe0sXamnmovbFVKvmDMnci4u/A0urAPjWTYwJCo=";
sourcekit-lsp = "sha256-BT6+VCBSupKOg2mXo6HlkvNRc8pVZU772Mj3LKFamsU=";
swift = "sha256-essP2eIp1sLuROqk0OKGBPfJnvnyAW0moMk0cX1IVQQ=";
swift-cmark = "sha256-f0BoTs4HYdx/aJ9HIGCWMalhl8PvClWD6R4QK3qSgAw=";
swift-corelibs-foundation = "sha256-g78zKSq/b/pVFAD2k2SoMpzJQIpkxMvZOaSz5JPaQmA=";
swift-corelibs-libdispatch = "sha256-1qbXiC1k9+T+L6liqXKg6EZXqem6KEEx8OctuL4Kb2o=";
swift-corelibs-xctest = "sha256-qLUO9/3tkJWorDMEHgHd8VC3ovLLq/UWXJWMtb6CMN0=";
swift-docc = "sha256-WlXJMAnrlVPCM+iCIhG0Gyho76BsC2yVBEpX3m/WiIQ=";
swift-docc-render-artifact = "sha256-ttdurN/K7OX+I4577jG3YGeRs+GLUTc7BiiEZGmFD+s=";
swift-driver = "sha256-BUwsvw8pirvprUFfliLQMMHr6SHTSgeaJYc9lTEvi9E=";
swift-experimental-string-processing = "sha256-W0cQBkdR3A0hrV75Wwm0YULUDVg1bjT0O5w5VGBYDJs=";
swift-package-manager = "sha256-zlFYh1wdjUwOsnbagKnAtqXl3vKPcRtnA7YMORtUeyg=";
llvm-project = "sha256-0xwSAwwkzFgYO3mY1rHqV8TCeH2NpM7m3VUkCDqjcdE=";
sourcekit-lsp = "sha256-XDGq64LbpgBrRy3IvZNgsoLUePXECK5p10vQ8cUKeGE=";
swift = "sha256-EY2IImBCVLiUutvDQjNUiInwCNxZsCu1mZzYSjNd4+A=";
swift-cmark = "sha256-6xkO9kN6eXMAigjk+KyIgVhTyC50BxmkZmD4+9z6nz8=";
swift-corelibs-foundation = "sha256-yRjjxJRy1eTM9VG7/Fn60UMghPavsaoueH0V8cjaIyM=";
swift-corelibs-libdispatch = "sha256-XOAWuaGqWJtxhGIPXYT3PIvk5OK0rkY4g1IOybJUlm4=";
swift-corelibs-xctest = "sha256-uwxQhKUQ1xp5ao6kfkdlYOvMr6yAb5IaBIdOfoyf+n8=";
swift-docc = "sha256-k1ygYDZwF4Jo7iOkHxc/3NzfgN+8XNCks5aizxBgPjM=";
swift-docc-render-artifact = "sha256-vdSyICXOjlNSjZXzPRxa/5305pg6PG4xww9GYEV9m10=";
swift-driver = "sha256-7xsG3Bpf+wqisCMaPEuEg8CjGYO/0r8BX3pMUmRrezE=";
swift-experimental-string-processing = "sha256-ioXG6pQKjlAc2oF38Z7TGighyZN8w2ZAAtFUq83Ow6Q=";
swift-package-manager = "sha256-xd6ZpeXfMoHyVrJxz6XcDLPKBvc2nl1lgWXuLrJdq+E=";
swift-syntax = "sha256-gkpx/1sWWi9y917OJ1GSNFYXrJb6e2qI4JlV+38laRQ=";
};
# Create fetch derivations.

View file

@ -28,6 +28,12 @@ stdenv.mkDerivation {
configurePhase = generated.configure;
# 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;

View file

@ -2,14 +2,13 @@
{
workspaceStateFile = ./workspace-state.json;
hashes = {
"swift-argument-parser" = "070gip241dgn3d0nxgwxva4vp6kbnf11g01q5yaq6kmflcmz58f2";
"swift-cmark" = "0xfchdgls3070z16in8ks69y8fpiajmyk7lmp5h7ym7164isa6bb";
"swift-crypto" = "0h054rq14jyg94aiymmp37vqz60a13dlczp5g09pln724j4ypv92";
"swift-argument-parser" = "1jph9w7lk9nr20fsv2c8p4hisx3dda817fh7pybd0r0j1jwa9nmw";
"swift-cmark" = "1qswlh6j9mlfq8qj7xfqspla7w7rrzvplgcs4mgllgi012yfgwnp";
"swift-crypto" = "020b8q4ss2k7a65r5dgh59z40i6sn7ij1allxkh8c8a9d0jzn313";
"swift-docc-plugin" = "11d6nhi139yzk1lxxrixsbgyj1bnvmh40wj30y725q83nqq49ljh";
"swift-docc-symbolkit" = "14hb2wc09hisf2r2yny17z28z0m58cf4lnqaczad2x2hk4s1iayi";
"swift-lmdb" = "1m5y6x2vs1wflcv2c57rx87gh12sy0hkwy5iy9inxmda2mcs8qcb";
"swift-markdown" = "09270bfrwlp904cma29hsbhr1p25v8kwgvhcfi7lg2av7aaknd97";
"swift-docc-symbolkit" = "14w37wzbx1mygfwm4iv0ypj120n1axhk627rg5a7v8j0ln511r7s";
"swift-lmdb" = "0azmc24mnxn4pbda8w8v7hy3h0gqqm4br43pnr7lc4sfj3dcv43m";
"swift-markdown" = "1l4ydc0xyv88gnyc33p61qavdh8cv98c548n1icphrfd6i78yygw";
"swift-nio" = "04bvay94b34ynmlvgyl9a7f431l3cf8k2zr483spv8mvyh1hxiqn";
"swift-nio-ssl" = "1ak4aldilmz0pnfgbwq1x4alr38nfyvx2pz7p2vi2plf82da80g5";
};
}

View file

@ -12,8 +12,8 @@
},
"state": {
"checkoutState": {
"revision": "d2930e8fcf9c33162b9fcc1d522bc975e2d4179b",
"version": "1.0.1"
"revision": "e394bf350e38cb100b6bc4172834770ede1b7232",
"version": "1.0.3"
},
"name": "sourceControlCheckout"
},
@ -29,8 +29,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7-gfm",
"revision": "792c1c3326327515ce9bf64c44196b7f4daab9a6"
"branch": "gfm",
"revision": "eb9a6a357b6816c68f4b194eaa5b67f3cd1fa5c3"
},
"name": "sourceControlCheckout"
},
@ -46,8 +46,8 @@
},
"state": {
"checkoutState": {
"revision": "9680b7251cd2be22caaed8f1468bd9e8915a62fb",
"version": "1.1.2"
"revision": "ddb07e896a2a8af79512543b1c7eb9797f8898a5",
"version": "1.1.7"
},
"name": "sourceControlCheckout"
},
@ -80,8 +80,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "8682202025906dce29a8b04f9263f40ba87b89d8"
"branch": "main",
"revision": "b45d1f2ed151d057b54504d653e0da5552844e34"
},
"name": "sourceControlCheckout"
},
@ -97,8 +97,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "6ea45a7ebf6d8f72bd299dfcc3299e284bbb92ee"
"branch": "main",
"revision": "584941b1236b15bad74d8163785d389c028b1ad8"
},
"name": "sourceControlCheckout"
},
@ -114,8 +114,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "d6cd065a7e4b6c3fad615dcd39890e095a2f63a2"
"branch": "main",
"revision": "d491147940587dbadfb3472354f4d0c6e063e061"
},
"name": "sourceControlCheckout"
},
@ -137,25 +137,8 @@
"name": "sourceControlCheckout"
},
"subpath": "swift-nio"
},
{
"basedOn": null,
"packageRef": {
"identity": "swift-nio-ssl",
"kind": "remoteSourceControl",
"location": "https://github.com/apple/swift-nio-ssl.git",
"name": "swift-nio-ssl"
},
"state": {
"checkoutState": {
"revision": "2e74773972bd6254c41ceeda827f229bccbf1c0f",
"version": "2.15.0"
},
"name": "sourceControlCheckout"
},
"subpath": "swift-nio-ssl"
}
]
},
"version": 5
"version": 6
}

View file

@ -2,10 +2,10 @@
{
workspaceStateFile = ./workspace-state.json;
hashes = {
"swift-argument-parser" = "11did5snqj8chcbdbiyx84mpif940ls2pr1iikwivvfp63i248hm";
"swift-llbuild" = "07zbp2dyfqd1bnyg7snpr9brn40jf22ivly5v10mql3hrg76a18h";
"swift-argument-parser" = "1jph9w7lk9nr20fsv2c8p4hisx3dda817fh7pybd0r0j1jwa9nmw";
"swift-llbuild" = "106vnssh6pgy5s9dnq1hi1c9v2wkfydqgncg5dy7c9n23iisjy3s";
"swift-system" = "0402hkx2q2dv27gccnn8ma79ngvwiwzkhcv4zlcdldmy6cgi0px7";
"swift-tools-support-core" = "134f9x44jnzdy8cwi6hs372dwbyqvr4qmsjzjy25wzpyv6m9rhrz";
"Yams" = "1893y13sis2aimi1a5kgkczbf06z4yig054xb565yg2xm13srb45";
"swift-tools-support-core" = "1qvblyiazv58qwyxgyk2dh5ymbab3y70vm2q81qs6rmv43hs8ciz";
"Yams" = "11abhcfkmqm3cmh7vp7rqzvxd1zj02j2866a2pp6v9m89456xb76";
};
}

View file

@ -12,8 +12,8 @@
},
"state": {
"checkoutState": {
"revision": "e1465042f195f374b94f915ba8ca49de24300a0d",
"version": "1.0.2"
"revision": "e394bf350e38cb100b6bc4172834770ede1b7232",
"version": "1.0.3"
},
"name": "sourceControlCheckout"
},
@ -29,8 +29,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "564424db5fdb62dcb5d863bdf7212500ef03a87b"
"branch": "release/5.8",
"revision": "dccfc2e127a34b89a849407594cf2d604b598ba9"
},
"name": "sourceControlCheckout"
},
@ -63,8 +63,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "286b48b1d73388e1d49b2bb33aabf995838104e3"
"branch": "release/5.8",
"revision": "ac4871e01ef338cb95b5d28328cab0ec1dfae935"
},
"name": "sourceControlCheckout"
},
@ -80,8 +80,8 @@
},
"state": {
"checkoutState": {
"revision": "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa",
"version": "4.0.6"
"revision": "01835dc202670b5bb90d07f3eae41867e9ed29f6",
"version": "5.0.1"
},
"name": "sourceControlCheckout"
},
@ -89,5 +89,5 @@
}
]
},
"version": 5
"version": 6
}

View file

@ -1,14 +1,14 @@
--- a/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
+++ b/Sources/SwiftDriver/Jobs/GenericUnixToolchain+LinkerSupport.swift
@@ -9,6 +9,7 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
@@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//
+import Foundation
import TSCBasic
import SwiftOptions
@@ -116,7 +117,20 @@ extension GenericUnixToolchain {
import func TSCBasic.lookupExecutablePath
@@ -120,7 +121,20 @@ extension GenericUnixToolchain {
// just using `clang` and avoid a dependency on the C++ runtime.
let clangTool: Tool =
parsedOptions.hasArgument(.enableExperimentalCxxInterop) ? .clangxx : .clang
@ -30,7 +30,7 @@
if let toolsDirPath = parsedOptions.getLastArgument(.toolsDirectory) {
// FIXME: What if this isn't an absolute path?
let toolsDir = try AbsolutePath(validating: toolsDirPath.asSingle)
@@ -132,6 +146,7 @@ extension GenericUnixToolchain {
@@ -136,6 +150,7 @@ extension GenericUnixToolchain {
commandLine.appendFlag("-B")
commandLine.appendPath(toolsDir)
}

View file

@ -4,15 +4,15 @@ there, but we also here patch a check to try locate it via NIX_CC.
--- a/Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift
+++ b/Sources/SwiftDriver/Jobs/Toolchain+LinkerSupport.swift
@@ -9,6 +9,7 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
@@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//
+import Foundation
import TSCBasic
import SwiftOptions
@@ -24,6 +25,13 @@ extension Toolchain {
import protocol TSCBasic.FileSystem
@@ -26,6 +27,13 @@ extension Toolchain {
for targetInfo: FrontendTargetInfo,
parsedOptions: inout ParsedOptions
) throws -> VirtualPath {

View file

@ -57,9 +57,6 @@ in lib.mapAttrs mkInstallScript {
'';
Yams = ''
add_library(CYaml SHARED IMPORTED)
set_property(TARGET CYaml PROPERTY IMPORTED_LOCATION "@out@/lib/libCYaml@sharedLibExt@")
add_library(Yams SHARED IMPORTED)
set_property(TARGET Yams PROPERTY IMPORTED_LOCATION "@out@/lib/swift/@swiftOs@/libYams@sharedLibExt@")
'';

View file

@ -8,6 +8,7 @@
, swiftpm2nix
, Foundation
, XCTest
, pkg-config
, sqlite
, ncurses
, substituteAll
@ -38,13 +39,12 @@ let
propagatedBuildInputs = [ Foundation ];
patches = [
./patches/cmake-disable-rpath.patch
./patches/cmake-fix-quoting.patch
./patches/disable-index-store.patch
./patches/disable-sandbox.patch
./patches/disable-xctest.patch
./patches/fix-clang-cxx.patch
(substituteAll {
src = ./patches/disable-xctest.patch;
inherit (builtins) storeDir;
})
./patches/nix-pkgconfig-vars.patch
(substituteAll {
src = ./patches/fix-stdlib-path.patch;
inherit (builtins) storeDir;
@ -60,6 +60,21 @@ let
--replace \
'librariesPath = applicationPath.parentDirectory' \
"librariesPath = AbsolutePath(\"$out\")"
# Fix case-sensitivity issues.
# Upstream PR: https://github.com/apple/swift-package-manager/pull/6500
substituteInPlace Sources/CMakeLists.txt \
--replace \
'packageCollectionsSigning' \
'PackageCollectionsSigning'
substituteInPlace Sources/PackageCollectionsSigning/CMakeLists.txt \
--replace \
'SubjectPublickeyInfo' \
'SubjectPublicKeyInfo'
substituteInPlace Sources/PackageCollections/CMakeLists.txt \
--replace \
'FilepackageCollectionsSourcesStorage' \
'FilePackageCollectionsSourcesStorage'
'';
};
@ -67,12 +82,15 @@ let
runtimeDeps = [ git ]
++ lib.optionals stdenv.isDarwin [
xcbuild.xcrun
# vtool is used to determine a minimum deployment target. This is part of
# cctools, but adding that as a build input puts an unwrapped linker in
# PATH, and breaks builds. This small derivation exposes just vtool.
(runCommandLocal "vtool" { } ''
# 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
'')
];
@ -282,6 +300,12 @@ let
swift-tools-support-core
];
postPatch = ''
# Tries to link against CYaml, but that's private.
substituteInPlace Sources/SwiftDriver/CMakeLists.txt \
--replace CYaml ""
'';
postInstall = cmakeGlue.SwiftDriver + ''
# Swift modules are not installed.
mkdir -p $out/${swiftModuleSubdir}
@ -294,8 +318,11 @@ let
src = generated.sources.swift-crypto;
postPatch = ''
# Fix use of hardcoded tool paths on Darwin.
substituteInPlace CMakeLists.txt \
--replace /usr/bin/ar $NIX_CC/bin/ar
substituteInPlace CMakeLists.txt \
--replace /usr/bin/ranlib $NIX_CC/bin/ranlib
'';
postInstall = cmakeGlue.SwiftCrypto + ''
@ -313,6 +340,7 @@ let
buildInputs = [
llbuild
sqlite
swift-argument-parser
swift-collections
swift-crypto
@ -342,6 +370,7 @@ in stdenv.mkDerivation (commonAttrs // {
];
buildInputs = [
ncursesInput
pkg-config
sqlite
XCTest
]
@ -385,10 +414,10 @@ in stdenv.mkDerivation (commonAttrs // {
mkdir -p $out/bin $out/lib/swift
cp $binPath/swift-package $out/bin/
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; do
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

View file

@ -4,11 +4,11 @@
hashes = {
"swift-argument-parser" = "1jph9w7lk9nr20fsv2c8p4hisx3dda817fh7pybd0r0j1jwa9nmw";
"swift-collections" = "1k6sjx5rqmp3gklny77b480hyzy6gkhpi23r0s8ljfbrcwawgnan";
"swift-crypto" = "020b8q4ss2k7a65r5dgh59z40i6sn7ij1allxkh8c8a9d0jzn313";
"swift-driver" = "1lcb5wqragc74nd0fjnk47lyph9hs0i9cps1mplvp2i91yzjqk05";
"swift-llbuild" = "07zbp2dyfqd1bnyg7snpr9brn40jf22ivly5v10mql3hrg76a18h";
"swift-crypto" = "0kllp7j0hd8k67l9b9zr2c3ddc5bvshldchzivhcz3q31qvq9ag8";
"swift-driver" = "0cbvddj54k3sbw0vzlmzhccs7h43hi5kq6i3n2i0mysz3bf0c6zg";
"swift-llbuild" = "106vnssh6pgy5s9dnq1hi1c9v2wkfydqgncg5dy7c9n23iisjy3s";
"swift-system" = "0402hkx2q2dv27gccnn8ma79ngvwiwzkhcv4zlcdldmy6cgi0px7";
"swift-tools-support-core" = "134f9x44jnzdy8cwi6hs372dwbyqvr4qmsjzjy25wzpyv6m9rhrz";
"Yams" = "1893y13sis2aimi1a5kgkczbf06z4yig054xb565yg2xm13srb45";
"swift-tools-support-core" = "1qvblyiazv58qwyxgyk2dh5ymbab3y70vm2q81qs6rmv43hs8ciz";
"Yams" = "0b4lprxl4f6yqq0djnp394mxgmsxm2pljr7fh4f6ihdhnpwfsfvl";
};
}

View file

@ -46,8 +46,8 @@
},
"state": {
"checkoutState": {
"revision": "ddb07e896a2a8af79512543b1c7eb9797f8898a5",
"version": "1.1.7"
"revision": "75ec60b8b4cc0f085c3ac414f3dca5625fa3588e",
"version": "2.2.4"
},
"name": "sourceControlCheckout"
},
@ -63,8 +63,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "82b274af66cfbb8f3131677676517b34d01e30fd"
"branch": "release/5.8",
"revision": "7cfe0c0b6e6297efe88a3ce34e6138ee7eda969e"
},
"name": "sourceControlCheckout"
},
@ -80,8 +80,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "564424db5fdb62dcb5d863bdf7212500ef03a87b"
"branch": "release/5.8",
"revision": "dccfc2e127a34b89a849407594cf2d604b598ba9"
},
"name": "sourceControlCheckout"
},
@ -114,8 +114,8 @@
},
"state": {
"checkoutState": {
"branch": "release/5.7",
"revision": "286b48b1d73388e1d49b2bb33aabf995838104e3"
"branch": "release/5.8",
"revision": "ac4871e01ef338cb95b5d28328cab0ec1dfae935"
},
"name": "sourceControlCheckout"
},
@ -131,8 +131,8 @@
},
"state": {
"checkoutState": {
"revision": "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa",
"version": "4.0.6"
"revision": "f47ba4838c30dbd59998a4e4c87ab620ff959e8a",
"version": "5.0.5"
},
"name": "sourceControlCheckout"
},
@ -140,5 +140,5 @@
}
]
},
"version": 5
"version": 6
}

View file

@ -0,0 +1,12 @@
--- a/Sources/PackageCollectionsSigning/CMakeLists.txt
+++ b/Sources/PackageCollectionsSigning/CMakeLists.txt
@@ -43,6 +43,7 @@ target_link_libraries(PackageCollectionsSigning PUBLIC
PackageCollectionsModel
TSCBasic)
target_link_libraries(PackageCollectionsSigning PRIVATE
- PackageCollectionsSigningLibc
- $<$<PLATFORM_ID:Darwin>:SHELL:-Xlinker -framework -Xlinker Security>)
+ PackageCollectionsSigningLibc)
+target_link_options(PackageCollectionsSigning PRIVATE
+ "$<$<PLATFORM_ID:Darwin>:SHELL:-Xlinker -framework -Xlinker Security>")

View file

@ -2,13 +2,13 @@ Nix may already sandbox the build, in which case sandbox_apply will fail.
--- a/Sources/Basics/Sandbox.swift
+++ b/Sources/Basics/Sandbox.swift
@@ -30,12 +30,14 @@ public enum Sandbox {
@@ -33,12 +33,14 @@ public enum Sandbox {
readOnlyDirectories: [AbsolutePath] = []
) -> [String] {
) throws -> [String] {
#if os(macOS)
+ let env = ProcessInfo.processInfo.environment
+ if env["NIX_BUILD_TOP"] == nil || env["IN_NIX_SHELL"] != nil {
let profile = macOSSandboxProfile(strictness: strictness, writableDirectories: writableDirectories, readOnlyDirectories: readOnlyDirectories)
let profile = try macOSSandboxProfile(strictness: strictness, writableDirectories: writableDirectories, readOnlyDirectories: readOnlyDirectories)
return ["/usr/bin/sandbox-exec", "-p", profile] + command
- #else
+ }
@ -17,5 +17,5 @@ Nix may already sandbox the build, in which case sandbox_apply will fail.
return command
- #endif
}
/// Basic strictness level of a sandbox applied to a command line.

View file

@ -1,21 +1,21 @@
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/TestingSupport.swift
+++ b/Sources/Commands/TestingSupport.swift
@@ -60,7 +60,7 @@ enum TestingSupport {
--- a/Sources/Commands/Utilities/TestingSupport.swift
+++ b/Sources/Commands/Utilities/TestingSupport.swift
@@ -72,7 +72,7 @@ enum TestingSupport {
/// - Returns: Array of TestSuite
static func getTestSuites(fromTestAt path: AbsolutePath, swiftTool: SwiftTool, swiftOptions: SwiftToolOptions) throws -> [TestSuite] {
static func getTestSuites(fromTestAt path: AbsolutePath, swiftTool: SwiftTool, enableCodeCoverage: Bool, sanitizers: [Sanitizer]) throws -> [TestSuite] {
// Run the correct tool.
- #if os(macOS)
+ #if false
let data: String = try withTemporaryFile { tempFile in
let args = [try TestingSupport.xctestHelperPath(swiftTool: swiftTool).pathString, path.pathString, tempFile.path.pathString]
var env = try TestingSupport.constructTestEnvironment(toolchain: try swiftTool.getToolchain(), options: swiftOptions, buildParameters: swiftTool.buildParametersForTest())
let args = [try Self.xctestHelperPath(swiftTool: swiftTool).pathString, path.pathString, tempFile.path.pathString]
var env = try Self.constructTestEnvironment(
--- a/Sources/swiftpm-xctest-helper/main.swift
+++ b/Sources/swiftpm-xctest-helper/main.swift
@@ -9,8 +9,11 @@
*/
@@ -11,8 +11,11 @@
//===----------------------------------------------------------------------===//
#if os(macOS)
-import XCTest
@ -27,7 +27,7 @@ command-line runner available, so disable support.
/// A helper tool to get list of tests from a XCTest Bundle on macOS.
///
@@ -132,6 +135,7 @@ do {
@@ -134,6 +137,7 @@ do {
exit(1)
}
@ -35,14 +35,3 @@ command-line runner available, so disable support.
#else
#if os(Windows)
--- a/Sources/PackageModel/Destination.swift
+++ b/Sources/PackageModel/Destination.swift
@@ -174,7 +174,7 @@ public struct Destination: Encodable, Equatable {
arguments: ["/usr/bin/xcrun", "--sdk", "macosx", "--show-sdk-platform-path"],
environment: environment).spm_chomp()
- if let platformPath = platformPath, !platformPath.isEmpty {
+ if let platformPath = platformPath, !platformPath.isEmpty && !platformPath.starts(with: "@storeDir@") {
// For XCTest framework.
let fwk = AbsolutePath(platformPath).appending(
components: "Developer", "Library", "Frameworks")

View file

@ -2,9 +2,20 @@ 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.swift
+++ b/Sources/Build/BuildPlan.swift
@@ -2089,7 +2089,7 @@ public class BuildPlan: SPMBuildCore.BuildPlan {
for target in dependencies.staticTargets {
if case let target as ClangTarget = target.underlyingTarget, target.isCXX {
if buildParameters.hostTriple.isDarwin() {
- buildProduct.additionalFlags += ["-lc++"]
+ buildProduct.additionalFlags += ["-lc++", "-lc++abi"]
} else if buildParameters.hostTriple.isWindows() {
// Don't link any C++ library.
} else {
--- a/Sources/Build/LLBuildManifestBuilder.swift
+++ b/Sources/Build/LLBuildManifestBuilder.swift
@@ -782,7 +782,7 @@ extension LLBuildManifestBuilder {
@@ -786,7 +786,7 @@ extension LLBuildManifestBuilder {
args += ["-c", path.source.pathString, "-o", path.object.pathString]
@ -13,21 +24,10 @@ swiftpm to properly invoke clang++.
args.insert(clangCompiler, at: 0)
let objectFileNode: Node = .file(path.object)
--- a/Sources/PackageModel/Destination.swift
+++ b/Sources/PackageModel/Destination.swift
@@ -153,7 +153,7 @@ public struct Destination: Encodable, Equatable {
var extraCPPFlags: [String] = []
#if os(macOS)
- extraCPPFlags += ["-lc++"]
+ extraCPPFlags += ["-lc++", "-lc++abi"]
#elseif os(Windows)
extraCPPFlags += []
#else
--- a/Sources/PackageModel/Toolchain.swift
+++ b/Sources/PackageModel/Toolchain.swift
@@ -20,7 +20,7 @@ public protocol Toolchain {
var macosSwiftStdlib: AbsolutePath { get }
@@ -23,7 +23,7 @@ public protocol Toolchain {
var macosSwiftStdlib: AbsolutePath { get throws }
/// Path of the `clang` compiler.
- func getClangCompiler() throws -> AbsolutePath
@ -46,7 +46,7 @@ swiftpm to properly invoke clang++.
private let environment: EnvironmentVariables
@@ -150,29 +150,31 @@ public final class UserToolchain: Toolchain {
@@ -196,29 +196,31 @@ public final class UserToolchain: Toolchain {
}
/// Returns the path to clang compiler tool.
@ -70,7 +70,7 @@ swiftpm to properly invoke clang++.
// Then, check the toolchain.
+ let tool = isCXX ? "clang++" : "clang";
do {
- if let toolPath = try? UserToolchain.getTool("clang", binDir: self.destination.binDir) {
- if let toolPath = try? UserToolchain.getTool("clang", binDir: self.destination.toolchainBinDir) {
- self._clangCompiler = toolPath
+ if let toolPath = try? UserToolchain.getTool(tool, binDir: self.destination.binDir) {
+ self._clangCompiler[isCXX] = toolPath
@ -88,18 +88,18 @@ swiftpm to properly invoke clang++.
--- a/Sources/SPMBuildCore/BuildParameters.swift
+++ b/Sources/SPMBuildCore/BuildParameters.swift
@@ -342,7 +342,7 @@ private struct _Toolchain: Encodable {
@@ -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.extraCCFlags, forKey: .extraCCFlags)
try container.encode(toolchain.extraCPPFlags, forKey: .extraCPPFlags)
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
@@ -172,7 +172,7 @@ public final class XcodeBuildSystem: SPMBuildCore.BuildSystem {
@@ -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.
@ -107,15 +107,15 @@ swiftpm to properly invoke clang++.
+ 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) \(buildParameters.toolchain.toolchainLibDir.pathString)"
settings["LIBRARY_SEARCH_PATHS"] = "$(inherited) \(try buildParameters.toolchain.toolchainLibDir.pathString)"
--- a/Tests/BuildTests/MockBuildTestHelper.swift
+++ b/Tests/BuildTests/MockBuildTestHelper.swift
@@ -15,7 +15,7 @@ struct MockToolchain: PackageModel.Toolchain {
@@ -23,7 +23,7 @@ struct MockToolchain: PackageModel.Toolchain {
#else
let extraCPPFlags: [String] = ["-lstdc++"]
let extraFlags = BuildFlags(cxxCompilerFlags: ["-lstdc++"])
#endif
- func getClangCompiler() throws -> AbsolutePath {
+ func getClangCompiler(isCXX: Bool) throws -> AbsolutePath {
return AbsolutePath("/fake/path/to/clang")
return AbsolutePath(path: "/fake/path/to/clang")
}

View file

@ -4,20 +4,22 @@ necessary for back-deployment of some features.
--- a/Sources/PackageModel/Toolchain.swift
+++ b/Sources/PackageModel/Toolchain.swift
@@ -43,10 +43,16 @@ extension Toolchain {
}
@@ -53,12 +53,18 @@ extension Toolchain {
public var macosSwiftStdlib: AbsolutePath {
+ if swiftCompilerPath.pathString.starts(with: "@storeDir@") {
+ return AbsolutePath("@swiftLib@/lib/swift/macosx")
+ }
return AbsolutePath("../../lib/swift/macosx", relativeTo: resolveSymlinks(swiftCompilerPath))
public var macosSwiftStdlib: AbsolutePath {
get throws {
+ if swiftCompilerPath.pathString.starts(with: "@storeDir@") {
+ return AbsolutePath("@swiftLib@/lib/swift/macosx")
+ }
return try AbsolutePath(validating: "../../lib/swift/macosx", relativeTo: resolveSymlinks(swiftCompilerPath))
}
}
public var toolchainLibDir: AbsolutePath {
+ if swiftCompilerPath.pathString.starts(with: "@storeDir@") {
+ return AbsolutePath("@swiftLib@/lib")
+ }
// FIXME: Not sure if it's better to base this off of Swift compiler or our own binary.
return AbsolutePath("../../lib", relativeTo: resolveSymlinks(swiftCompilerPath))
}
get throws {
+ if swiftCompilerPath.pathString.starts(with: "@storeDir@") {
+ return AbsolutePath("@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))
}

View file

@ -0,0 +1,28 @@
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
}
}
}

View file

@ -105,7 +105,7 @@ dontLink=$isFrontend
for p in "${params[@]}"; do
case "$p" in
-enable-cxx-interop)
-enable-cxx-interop | -enable-experimental-cxx-interop)
isCxx=1 ;;
esac
done