From fbe4dd91544d046967901d030eb87152e418348e Mon Sep 17 00:00:00 2001 From: Michael Chiu Date: Mon, 25 Nov 2024 17:41:32 -0500 Subject: [PATCH 1/4] Adding FreeBSD support This commit adds required conditional compilation blocks to enable bulding on FreeBSD (tested on x86_64 FreeBSD 14.1-RELEASE-p6). Also implements FreeBSD synchronization shims using `_umtx_op(2)` --- stdlib/public/Platform/Platform.swift | 8 ++- stdlib/public/Platform/SwiftGlibc.h.gyb | 2 + stdlib/public/Platform/glibc.modulemap.gyb | 2 +- .../swift/shims/_SynchronizationShims.h | 5 ++ stdlib/public/Synchronization/CMakeLists.txt | 11 +++++ .../Synchronization/Mutex/FreeBSDImpl.swift | 49 +++++++++++++++++++ 6 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 stdlib/public/Synchronization/Mutex/FreeBSDImpl.swift diff --git a/stdlib/public/Platform/Platform.swift b/stdlib/public/Platform/Platform.swift index 0c2d63a0cffdb..0674acc9406af 100644 --- a/stdlib/public/Platform/Platform.swift +++ b/stdlib/public/Platform/Platform.swift @@ -338,12 +338,12 @@ public var SIG_DFL: sig_t? { return nil } public var SIG_IGN: sig_t { return unsafeBitCast(1, to: sig_t.self) } public var SIG_ERR: sig_t { return unsafeBitCast(-1, to: sig_t.self) } public var SIG_HOLD: sig_t { return unsafeBitCast(5, to: sig_t.self) } -#elseif os(OpenBSD) +#elseif os(OpenBSD) || os(FreeBSD) public var SIG_DFL: sig_t? { return nil } public var SIG_IGN: sig_t { return unsafeBitCast(1, to: sig_t.self) } public var SIG_ERR: sig_t { return unsafeBitCast(-1, to: sig_t.self) } public var SIG_HOLD: sig_t { return unsafeBitCast(3, to: sig_t.self) } -#elseif os(Linux) || os(FreeBSD) || os(PS4) || os(Android) || os(Haiku) +#elseif os(Linux) || os(PS4) || os(Android) || os(Haiku) #if !canImport(SwiftMusl) public typealias sighandler_t = __sighandler_t #endif @@ -495,3 +495,7 @@ public var environ: UnsafeMutablePointer?> { } #endif #endif // SWIFT_STDLIB_HAS_ENVIRON + +#if os(FreeBSD) +public let inet_pton = __inet_pton +#endif diff --git a/stdlib/public/Platform/SwiftGlibc.h.gyb b/stdlib/public/Platform/SwiftGlibc.h.gyb index 61d054e09b049..180396d655100 100644 --- a/stdlib/public/Platform/SwiftGlibc.h.gyb +++ b/stdlib/public/Platform/SwiftGlibc.h.gyb @@ -65,6 +65,7 @@ headers = [ 'spawn.h', 'strings.h', 'sys/event.h', + 'sys/extattr.h', 'sys/file.h', 'sys/inotify.h', 'sys/ioctl.h', @@ -84,6 +85,7 @@ headers = [ 'sys/times.h', 'sys/types.h', 'sys/uio.h', + 'sys/umtx.h', 'sys/un.h', 'sys/user.h', 'sys/utsname.h', diff --git a/stdlib/public/Platform/glibc.modulemap.gyb b/stdlib/public/Platform/glibc.modulemap.gyb index af25d0cf93ad1..21ac7881771f3 100644 --- a/stdlib/public/Platform/glibc.modulemap.gyb +++ b/stdlib/public/Platform/glibc.modulemap.gyb @@ -19,7 +19,7 @@ /// It's not named just Glibc so that it doesn't conflict in the event of a /// future official glibc modulemap. module SwiftGlibc [system] { -% if CMAKE_SDK in ["LINUX", "OPENBSD"]: +% if CMAKE_SDK in ["LINUX", "OPENBSD", "FREEBSD"]: link "m" % end % if CMAKE_SDK in ["LINUX", "FREEBSD", "OPENBSD", "CYGWIN"]: diff --git a/stdlib/public/SwiftShims/swift/shims/_SynchronizationShims.h b/stdlib/public/SwiftShims/swift/shims/_SynchronizationShims.h index 70a1eb6e004f0..0386a570df00f 100644 --- a/stdlib/public/SwiftShims/swift/shims/_SynchronizationShims.h +++ b/stdlib/public/SwiftShims/swift/shims/_SynchronizationShims.h @@ -66,4 +66,9 @@ static inline __swift_uint32_t _swift_stdlib_futex_unlock(__swift_uint32_t *lock #endif // defined(__linux__) +#if defined(__FreeBSD__) +#include +#include +#endif + #endif // SWIFT_STDLIB_SYNCHRONIZATION_SHIMS_H diff --git a/stdlib/public/Synchronization/CMakeLists.txt b/stdlib/public/Synchronization/CMakeLists.txt index 892d105c3f300..68ec912af8d16 100644 --- a/stdlib/public/Synchronization/CMakeLists.txt +++ b/stdlib/public/Synchronization/CMakeLists.txt @@ -54,6 +54,13 @@ set(SWIFT_SYNCHRONIZATION_LINUX_SOURCES Mutex/SpinLoopHint.swift ) +# FreeBSD sources + +set(SWIFT_SYNCHRONIZATION_FREEBSD_SOURCES + Mutex/FreeBSDImpl.swift + Mutex/Mutex.swift +) + # Wasm sources set(SWIFT_SYNCHRONIZATION_WASM_SOURCES @@ -100,6 +107,8 @@ add_swift_target_library(swiftSynchronization ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES ${SWIFT_SYNCHRONIZATION_WASM_SOURCES} SWIFT_SOURCES_DEPENDS_WINDOWS ${SWIFT_SYNCHRONIZATION_WINDOWS_SOURCES} + SWIFT_SOURCES_DEPENDS_FREEBSD + ${SWIFT_SYNCHRONIZATION_FREEBSD_SOURCES} SWIFT_SOURCES_DEPENDS_FREESTANDING Mutex/MutexUnavailable.swift @@ -123,6 +132,8 @@ add_swift_target_library(swiftSynchronization ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES Android SWIFT_MODULE_DEPENDS_WINDOWS WinSDK + SWIFT_MODULE_DEPENDS_FREEBSD + Glibc SWIFT_COMPILE_FLAGS ${SWIFT_SYNCHRNOIZATION_SWIFT_FLAGS} diff --git a/stdlib/public/Synchronization/Mutex/FreeBSDImpl.swift b/stdlib/public/Synchronization/Mutex/FreeBSDImpl.swift new file mode 100644 index 0000000000000..666e574278fda --- /dev/null +++ b/stdlib/public/Synchronization/Mutex/FreeBSDImpl.swift @@ -0,0 +1,49 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift Atomics open source project +// +// Copyright (c) 2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import Glibc + +@available(SwiftStdlib 6.0, *) +@frozen +@_staticExclusiveOnly +public struct _MutexHandle: ~Copyable { + @usableFromInline + let value: _Cell + + @available(SwiftStdlib 6.0, *) + @_alwaysEmitIntoClient + @_transparent + public init() { + value = _Cell(umutex()) + } + + @available(SwiftStdlib 6.0, *) + @_alwaysEmitIntoClient + @_transparent + internal borrowing func _lock() { + _umtx_op(value._address, UMTX_OP_MUTEX_LOCK, 0, nil, nil) + } + + @available(SwiftStdlib 6.0, *) + @_alwaysEmitIntoClient + @_transparent + internal borrowing func _tryLock() -> Bool { + _umtx_op(value._address, UMTX_OP_MUTEX_TRYLOCK, 0, nil, nil) != -1 + } + + @available(SwiftStdlib 6.0, *) + @_alwaysEmitIntoClient + @_transparent + internal borrowing func _unlock() { + _umtx_op(value._address, UMTX_OP_MUTEX_UNLOCK, 0, nil, nil) + } +} From ec6d4d3f03222cb05d6d6ac2150b2c79e6166c25 Mon Sep 17 00:00:00 2001 From: Michael Chiu Date: Fri, 29 Nov 2024 09:03:42 +0800 Subject: [PATCH 2/4] Merge swiftlang#38335 --- CMakeLists.txt | 2 ++ include/swift/AST/AutoDiff.h | 9 ++++++++- include/swift/AST/PlatformKinds.def | 1 + .../Differentiation/DifferentiationInvoker.h | 16 ++++++++++++---- lib/AST/PlatformKind.cpp | 4 ++++ lib/AST/Type.cpp | 7 ++++--- lib/ClangImporter/ClangImporter.cpp | 11 +++++++++++ lib/IRGen/TBDGen.cpp | 2 ++ lib/Option/SanitizerOptions.cpp | 3 ++- lib/PrintAsClang/DeclAndTypePrinter.cpp | 3 +++ lib/SymbolGraphGen/AvailabilityMixin.cpp | 2 ++ .../public/SwiftShims/swift/shims/SwiftStdint.h | 2 +- .../SourceKit/lib/SwiftLang/SwiftDocSupport.cpp | 4 ++++ 13 files changed, 56 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 197ea538bc25a..248188d681522 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1049,6 +1049,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(SWIFT_USE_LINKER_default "") elseif(DISTRO_NAME STREQUAL "Amazon Linux 2023") set(SWIFT_USE_LINKER_default "lld") +elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") + set(SWIFT_USE_LINKER_default "lld") else() get_gold_version(gold_version) if(NOT gold_version) diff --git a/include/swift/AST/AutoDiff.h b/include/swift/AST/AutoDiff.h index d4d2574882b6c..59f877a735459 100644 --- a/include/swift/AST/AutoDiff.h +++ b/include/swift/AST/AutoDiff.h @@ -422,7 +422,14 @@ class DerivativeFunctionTypeError Kind kind; /// The type and index of a differentiability parameter or result. - using TypeAndIndex = std::pair; + /// std::pair does not have a trivial copy constructor on FreeBSD <= 14 for + /// ABI reasons, so we have to define our own type here instead + struct TypeAndIndex { + Type first; + unsigned second; + + TypeAndIndex(Type type, unsigned index) : first(type), second(index) {} + }; private: union Value { diff --git a/include/swift/AST/PlatformKinds.def b/include/swift/AST/PlatformKinds.def index dd10bf495b65b..9b2fcdadd554a 100644 --- a/include/swift/AST/PlatformKinds.def +++ b/include/swift/AST/PlatformKinds.def @@ -34,6 +34,7 @@ AVAILABILITY_PLATFORM(visionOSApplicationExtension, "application extensions for AVAILABILITY_PLATFORM(macOSApplicationExtension, "application extensions for macOS") AVAILABILITY_PLATFORM(macCatalyst, "Mac Catalyst") AVAILABILITY_PLATFORM(macCatalystApplicationExtension, "application extensions for Mac Catalyst") +AVAILABILITY_PLATFORM(FreeBSD, "FreeBSD") AVAILABILITY_PLATFORM(OpenBSD, "OpenBSD") AVAILABILITY_PLATFORM(Windows, "Windows") diff --git a/include/swift/SILOptimizer/Differentiation/DifferentiationInvoker.h b/include/swift/SILOptimizer/Differentiation/DifferentiationInvoker.h index 63b9eb6eb824b..6d41cea11b128 100644 --- a/include/swift/SILOptimizer/Differentiation/DifferentiationInvoker.h +++ b/include/swift/SILOptimizer/Differentiation/DifferentiationInvoker.h @@ -71,10 +71,17 @@ struct DifferentiationInvoker { /// The parent `apply` instruction and the witness associated with the /// `IndirectDifferentiation` case. - std::pair - indirectDifferentiation; + /// Note: This used to be a std::pair, but on FreeBSD <= 14, libc++ is + /// configured with _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR + /// and hence does not have a trivial copy constructor + struct IndirectDifferentiation { + ApplyInst *applyInst; + SILDifferentiabilityWitness *witness; + }; + IndirectDifferentiation indirectDifferentiation; + Value(ApplyInst *applyInst, SILDifferentiabilityWitness *witness) - : indirectDifferentiation({applyInst, witness}) {} + : indirectDifferentiation({applyInst, witness}) {} /// The witness associated with the `SILDifferentiabilityWitnessInvoker` /// case. @@ -111,7 +118,8 @@ struct DifferentiationInvoker { std::pair getIndirectDifferentiation() const { assert(kind == Kind::IndirectDifferentiation); - return value.indirectDifferentiation; + return std::make_pair(value.indirectDifferentiation.applyInst, + value.indirectDifferentiation.witness); } SILDifferentiabilityWitness *getSILDifferentiabilityWitnessInvoker() const { diff --git a/lib/AST/PlatformKind.cpp b/lib/AST/PlatformKind.cpp index cbe557b9aba04..6dcd89fe0eba8 100644 --- a/lib/AST/PlatformKind.cpp +++ b/lib/AST/PlatformKind.cpp @@ -116,6 +116,7 @@ swift::basePlatformForExtensionPlatform(PlatformKind Platform) { case PlatformKind::tvOS: case PlatformKind::watchOS: case PlatformKind::visionOS: + case PlatformKind::FreeBSD: case PlatformKind::OpenBSD: case PlatformKind::Windows: case PlatformKind::none: @@ -160,6 +161,8 @@ static bool isPlatformActiveForTarget(PlatformKind Platform, return Target.isXROS(); case PlatformKind::OpenBSD: return Target.isOSOpenBSD(); + case PlatformKind::FreeBSD: + return Target.isOSFreeBSD(); case PlatformKind::Windows: return Target.isOSWindows(); case PlatformKind::none: @@ -278,6 +281,7 @@ bool swift::isPlatformSPI(PlatformKind Platform) { case PlatformKind::visionOS: case PlatformKind::visionOSApplicationExtension: case PlatformKind::OpenBSD: + case PlatformKind::FreeBSD: case PlatformKind::Windows: case PlatformKind::none: return false; diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index ec4e6748e7225..8cb024e9d0462 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -4704,7 +4704,8 @@ AnyFunctionType::getAutoDiffDerivativeFunctionLinearMapType( if (!resultTan) return llvm::make_error( this, DerivativeFunctionTypeError::Kind::NonDifferentiableResult, - std::make_pair(originalResultType, unsigned(originalResult.index))); + DerivativeFunctionTypeError::TypeAndIndex( + originalResultType, unsigned(originalResult.index))); if (!originalResult.isSemanticResultParameter) resultTanTypes.push_back(resultTan->getType()); @@ -4734,7 +4735,7 @@ AnyFunctionType::getAutoDiffDerivativeFunctionLinearMapType( this, DerivativeFunctionTypeError::Kind:: NonDifferentiableDifferentiabilityParameter, - std::make_pair(paramType, i)); + DerivativeFunctionTypeError::TypeAndIndex(paramType, i)); differentialParams.push_back(AnyFunctionType::Param( paramTan->getType(), Identifier(), diffParam.getParameterFlags())); @@ -4782,7 +4783,7 @@ AnyFunctionType::getAutoDiffDerivativeFunctionLinearMapType( this, DerivativeFunctionTypeError::Kind:: NonDifferentiableDifferentiabilityParameter, - std::make_pair(paramType, i)); + DerivativeFunctionTypeError::TypeAndIndex(paramType, i)); if (diffParam.isAutoDiffSemanticResult()) { if (paramType->isVoid()) diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index bc49de91e0cf5..fa2380c11c4ff 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -2562,6 +2562,10 @@ PlatformAvailability::PlatformAvailability(const LangOptions &langOpts) case PlatformKind::visionOSApplicationExtension: break; + case PlatformKind::FreeBSD: + deprecatedAsUnavailableMessage = ""; + break; + case PlatformKind::OpenBSD: deprecatedAsUnavailableMessage = ""; break; @@ -2609,6 +2613,9 @@ bool PlatformAvailability::isPlatformRelevant(StringRef name) const { return name == "xros" || name == "xros_app_extension" || name == "visionos" || name == "visionos_app_extension"; + case PlatformKind::FreeBSD: + return name == "freebsd"; + case PlatformKind::OpenBSD: return name == "openbsd"; @@ -2680,6 +2687,10 @@ bool PlatformAvailability::treatDeprecatedAsUnavailable( // No deprecation filter on xrOS return false; + case PlatformKind::FreeBSD: + // No deprecation filter on FreeBSD + return false; + case PlatformKind::OpenBSD: // No deprecation filter on OpenBSD return false; diff --git a/lib/IRGen/TBDGen.cpp b/lib/IRGen/TBDGen.cpp index f37257f5c21e0..bdb19d159fb21 100644 --- a/lib/IRGen/TBDGen.cpp +++ b/lib/IRGen/TBDGen.cpp @@ -244,6 +244,8 @@ getLinkerPlatformId(OriginallyDefinedInAttr::ActiveVersion Ver, llvm_unreachable("cannot find platform kind"); case swift::PlatformKind::OpenBSD: llvm_unreachable("not used for this platform"); + case swift::PlatformKind::FreeBSD: + llvm_unreachable("not used for this platform"); case swift::PlatformKind::Windows: llvm_unreachable("not used for this platform"); case swift::PlatformKind::iOS: diff --git a/lib/Option/SanitizerOptions.cpp b/lib/Option/SanitizerOptions.cpp index f8f8ccbb4bb19..57c00469da877 100644 --- a/lib/Option/SanitizerOptions.cpp +++ b/lib/Option/SanitizerOptions.cpp @@ -168,7 +168,8 @@ OptionSet swift::parseSanitizerArgValues( } // Check that we're one of the known supported targets for sanitizers. - if (!(Triple.isOSDarwin() || Triple.isOSLinux() || Triple.isOSWindows())) { + if (!(Triple.isOSDarwin() || Triple.isOSLinux() || Triple.isOSWindows() + || Triple.isOSFreeBSD())) { SmallString<128> b; Diags.diagnose(SourceLoc(), diag::error_unsupported_opt_for_target, (A->getOption().getPrefixedName() + diff --git a/lib/PrintAsClang/DeclAndTypePrinter.cpp b/lib/PrintAsClang/DeclAndTypePrinter.cpp index 18573bd2eccc1..a2f704a223431 100644 --- a/lib/PrintAsClang/DeclAndTypePrinter.cpp +++ b/lib/PrintAsClang/DeclAndTypePrinter.cpp @@ -1782,6 +1782,9 @@ class DeclAndTypePrinter::Implementation case PlatformKind::visionOSApplicationExtension: plat = "visionos_app_extension"; break; + case PlatformKind::FreeBSD: + plat = "freebsd"; + break; case PlatformKind::OpenBSD: plat = "openbsd"; break; diff --git a/lib/SymbolGraphGen/AvailabilityMixin.cpp b/lib/SymbolGraphGen/AvailabilityMixin.cpp index ece561a30ece6..4678641bf1598 100644 --- a/lib/SymbolGraphGen/AvailabilityMixin.cpp +++ b/lib/SymbolGraphGen/AvailabilityMixin.cpp @@ -54,6 +54,8 @@ StringRef getDomain(const SemanticAvailableAttr &AvAttr) { return { "watchOSAppExtension" }; case swift::PlatformKind::visionOSApplicationExtension: return { "visionOSAppExtension" }; + case swift::PlatformKind::FreeBSD: + return { "FreeBSD" }; case swift::PlatformKind::OpenBSD: return { "OpenBSD" }; case swift::PlatformKind::Windows: diff --git a/stdlib/public/SwiftShims/swift/shims/SwiftStdint.h b/stdlib/public/SwiftShims/swift/shims/SwiftStdint.h index 386186df0962c..2be8b51f53650 100644 --- a/stdlib/public/SwiftShims/swift/shims/SwiftStdint.h +++ b/stdlib/public/SwiftShims/swift/shims/SwiftStdint.h @@ -24,7 +24,7 @@ // Clang has been defining __INTxx_TYPE__ macros for a long time. // __UINTxx_TYPE__ are defined only since Clang 3.5. -#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) && !defined(__wasi__) +#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__wasi__) #include typedef int64_t __swift_int64_t; typedef uint64_t __swift_uint64_t; diff --git a/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp b/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp index cda9216374062..db994ef4b7d40 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp @@ -688,6 +688,7 @@ static void reportAvailabilityAttributes(ASTContext &Ctx, const Decl *D, static UIdent PlatformOSXAppExt("source.availability.platform.osx_app_extension"); static UIdent PlatformtvOSAppExt("source.availability.platform.tvos_app_extension"); static UIdent PlatformWatchOSAppExt("source.availability.platform.watchos_app_extension"); + static UIdent PlatformFreeBSD("source.availability.platform.freebsd"); static UIdent PlatformOpenBSD("source.availability.platform.openbsd"); static UIdent PlatformWindows("source.availability.platform.windows"); std::vector Scratch; @@ -739,6 +740,9 @@ static void reportAvailabilityAttributes(ASTContext &Ctx, const Decl *D, case PlatformKind::OpenBSD: PlatformUID = PlatformOpenBSD; break; + case PlatformKind::FreeBSD: + PlatformUID = PlatformFreeBSD; + break; case PlatformKind::Windows: PlatformUID = PlatformWindows; break; From 7ebbfeadd2774dedebc4f722cfc78010c63fb685 Mon Sep 17 00:00:00 2001 From: Michael Chiu Date: Tue, 3 Dec 2024 12:55:20 -0500 Subject: [PATCH 3/4] fix test --- test/IDE/complete_decl_attribute.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/test/IDE/complete_decl_attribute.swift b/test/IDE/complete_decl_attribute.swift index 6cf7505401f2c..6f8e9f0f6e706 100644 --- a/test/IDE/complete_decl_attribute.swift +++ b/test/IDE/complete_decl_attribute.swift @@ -78,6 +78,7 @@ actor MyGenericGlobalActor { // AVAILABILITY1-NEXT: Keyword/None: macOSApplicationExtension[#Platform#]; name=macOSApplicationExtension{{$}} // AVAILABILITY1-NEXT: Keyword/None: macCatalyst[#Platform#]; name=macCatalyst // AVAILABILITY1-NEXT: Keyword/None: macCatalystApplicationExtension[#Platform#]; name=macCatalystApplicationExtension +// AVAILABILITY1-NEXT: Keyword/None: FreeBSD[#Platform#]; name=FreeBSD{{$}} // AVAILABILITY1-NEXT: Keyword/None: OpenBSD[#Platform#]; name=OpenBSD{{$}} // AVAILABILITY1-NEXT: Keyword/None: Windows[#Platform#]; name=Windows{{$}} From c22dacbcf5e200379e6b693310d23263747f0b55 Mon Sep 17 00:00:00 2001 From: Michael Chiu Date: Sun, 26 Jan 2025 04:20:58 -0500 Subject: [PATCH 4/4] FreeBSD cxx stdlib and tests fixes --- stdlib/public/Cxx/std/CMakeLists.txt | 2 +- stdlib/public/Platform/SwiftGlibc.h.gyb | 1 + stdlib/public/runtime/CMakeLists.txt | 3 ++- ...sk_executor_and_serial_executor_both_executor.swift | 3 ++- .../custom_executors_complex_equality_crash.swift | 1 + ...distributed_actor_protocol_call_resilient_lib.swift | 1 + .../Cxx/stdlib/fake-toolchain-module-interface.swift | 2 +- test/Interop/Cxx/stdlib/use-std-optional.swift | 2 +- test/stdlib/DispatchTypes.swift | 10 +++++++++- test/stdlib/POSIX.swift | 1 + test/stdlib/simd_diagnostics.swift | 2 +- 11 files changed, 21 insertions(+), 7 deletions(-) diff --git a/stdlib/public/Cxx/std/CMakeLists.txt b/stdlib/public/Cxx/std/CMakeLists.txt index d92d3e369b1c9..57145807d7170 100644 --- a/stdlib/public/Cxx/std/CMakeLists.txt +++ b/stdlib/public/Cxx/std/CMakeLists.txt @@ -75,7 +75,7 @@ add_swift_target_library(swiftCxxStdlib STATIC NO_LINK_NAME IS_STDLIB IS_SWIFT_O DEPLOYMENT_VERSION_XROS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS} LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}" - TARGET_SDKS ALL_APPLE_PLATFORMS LINUX WINDOWS ANDROID + TARGET_SDKS ALL_APPLE_PLATFORMS LINUX WINDOWS ANDROID FREEBSD MACCATALYST_BUILD_FLAVOR zippered INSTALL_IN_COMPONENT compiler INSTALL_WITH_SHARED diff --git a/stdlib/public/Platform/SwiftGlibc.h.gyb b/stdlib/public/Platform/SwiftGlibc.h.gyb index 180396d655100..10e8283ba77f3 100644 --- a/stdlib/public/Platform/SwiftGlibc.h.gyb +++ b/stdlib/public/Platform/SwiftGlibc.h.gyb @@ -57,6 +57,7 @@ headers = [ 'nl_types.h', 'poll.h', 'pthread.h', + 'pthread_np.h', 'pwd.h', 'regex.h', 'sched.h', diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt index 407382ff6b38a..4be1ec0979657 100644 --- a/stdlib/public/runtime/CMakeLists.txt +++ b/stdlib/public/runtime/CMakeLists.txt @@ -93,7 +93,8 @@ set(swift_runtime_backtracing_sources Backtrace.cpp BacktraceUtils.cpp CrashHandlerMacOS.cpp - CrashHandlerLinux.cpp) + CrashHandlerLinux.cpp +) # Acknowledge that the following sources are known. set(LLVM_OPTIONAL_SOURCES diff --git a/test/Concurrency/Runtime/async_task_executor_and_serial_executor_both_executor.swift b/test/Concurrency/Runtime/async_task_executor_and_serial_executor_both_executor.swift index a9873a66213bc..c75fda96e4d60 100644 --- a/test/Concurrency/Runtime/async_task_executor_and_serial_executor_both_executor.swift +++ b/test/Concurrency/Runtime/async_task_executor_and_serial_executor_both_executor.swift @@ -8,11 +8,12 @@ // TODO: Need to find out how to combine %env- and %target-run and %import-libdispatch reliably. // UNSUPPORTED: OS=linux-gnu +// UNSUPPORTED: OS=freebsd // REQUIRES: concurrency // REQUIRES: executable_test // REQUIRES: libdispatch -// +// // REQUIRES: concurrency_runtime // UNSUPPORTED: back_deployment_runtime diff --git a/test/Concurrency/Runtime/custom_executors_complex_equality_crash.swift b/test/Concurrency/Runtime/custom_executors_complex_equality_crash.swift index 4290618008890..ca5422a2a6459 100644 --- a/test/Concurrency/Runtime/custom_executors_complex_equality_crash.swift +++ b/test/Concurrency/Runtime/custom_executors_complex_equality_crash.swift @@ -8,6 +8,7 @@ // TODO: Need to find out how to combine %env- and %target-run and %import-libdispatch reliably. // UNSUPPORTED: OS=linux-gnu +// UNSUPPORTED: OS=freebsd // REQUIRES: concurrency // REQUIRES: executable_test diff --git a/test/Distributed/Runtime/distributed_actor_protocol_call_resilient_lib.swift b/test/Distributed/Runtime/distributed_actor_protocol_call_resilient_lib.swift index 0e800d625732a..64e66a5485d9f 100644 --- a/test/Distributed/Runtime/distributed_actor_protocol_call_resilient_lib.swift +++ b/test/Distributed/Runtime/distributed_actor_protocol_call_resilient_lib.swift @@ -71,6 +71,7 @@ // Locating the built libraries failed on Linux (construction of test case), // but we primarily care about macOS in this test // UNSUPPORTED: OS=linux-gnu +// UNSUPPORTED: OS=freebsd // UNSUPPORTED: use_os_stdlib // UNSUPPORTED: back_deployment_runtime diff --git a/test/Interop/Cxx/stdlib/fake-toolchain-module-interface.swift b/test/Interop/Cxx/stdlib/fake-toolchain-module-interface.swift index 9fbab5154011c..dd36e27f2d234 100644 --- a/test/Interop/Cxx/stdlib/fake-toolchain-module-interface.swift +++ b/test/Interop/Cxx/stdlib/fake-toolchain-module-interface.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-ide-test -print-module -module-to-print=FakeToolchain -tools-directory %S/Inputs/fake-toolchain/bin -source-filename=x -enable-experimental-cxx-interop -Xcc -stdlib=libc++ | %FileCheck %s +// RUN: %target-swift-ide-test -print-module -module-to-print=FakeToolchain -tools-directory %S/Inputs/fake-toolchain/bin -source-filename=x -enable-experimental-cxx-interop -Xcc -stdlib=libc++ -Xcc -I%S/Inputs/fake-toolchain/include/c++/v1 | %FileCheck %s // Clang driver on Windows doesn't support -stdlib=libc++ // XFAIL: OS=windows-msvc diff --git a/test/Interop/Cxx/stdlib/use-std-optional.swift b/test/Interop/Cxx/stdlib/use-std-optional.swift index fa7695854406d..b2525041a2fcc 100644 --- a/test/Interop/Cxx/stdlib/use-std-optional.swift +++ b/test/Interop/Cxx/stdlib/use-std-optional.swift @@ -16,7 +16,7 @@ StdOptionalTestSuite.test("pointee") { let pointee = nonNilOpt.pointee expectEqual(123, pointee) -#if !os(Linux) // crashes on Ubuntu 18.04 (rdar://113414160) +#if !os(Linux) && !os(FreeBSD) // crashes on Ubuntu 18.04 (rdar://113414160) var modifiedOpt = getNilOptional() modifiedOpt.pointee = 777 expectEqual(777, modifiedOpt.pointee) diff --git a/test/stdlib/DispatchTypes.swift b/test/stdlib/DispatchTypes.swift index 536bd8ef83faa..ca2e305791700 100644 --- a/test/stdlib/DispatchTypes.swift +++ b/test/stdlib/DispatchTypes.swift @@ -1,4 +1,4 @@ -// RUN: %target-swift-frontend -typecheck %s +// RUN: %target-swift-frontend -typecheck %s %import-libdispatch // REQUIRES: libdispatch // UNSUPPORTED: OS=linux-gnu @@ -27,14 +27,22 @@ if #available(OSX 10.10, iOS 8.0, *) { // dispatch/source.h _ = DispatchSource.makeUserDataAddSource() _ = DispatchSource.makeUserDataOrSource() +#if !os(FreeBSD) _ = DispatchSource.makeMachSendSource(port: mach_port_t(0), eventMask: []) _ = DispatchSource.makeMachReceiveSource(port: mach_port_t(0)) _ = DispatchSource.makeMemoryPressureSource(eventMask: []) +#endif _ = DispatchSource.makeProcessSource(identifier: 0, eventMask: []) _ = DispatchSource.makeReadSource(fileDescriptor: 0) +#if os(FreeBSD) +_ = DispatchSource.makeSignalSource(signal: 2) +#else _ = DispatchSource.makeSignalSource(signal: SIGINT) +#endif _ = DispatchSource.makeTimerSource() +#if !os(FreeBSD) _ = DispatchSource.makeFileSystemObjectSource(fileDescriptor: 0, eventMask: []) +#endif _ = DispatchSource.makeWriteSource(fileDescriptor: 0) // dispatch/time.h diff --git a/test/stdlib/POSIX.swift b/test/stdlib/POSIX.swift index 42b9edb5f4123..8e36505194f9e 100644 --- a/test/stdlib/POSIX.swift +++ b/test/stdlib/POSIX.swift @@ -2,6 +2,7 @@ // REQUIRES: executable_test // UNSUPPORTED: OS=windows-msvc // UNSUPPORTED: OS=wasi +// UNSUPPORTED: OS=freebsd import StdlibUnittest import SwiftPrivateLibcExtras diff --git a/test/stdlib/simd_diagnostics.swift b/test/stdlib/simd_diagnostics.swift index f30d278c0cb4f..eb971c1042ffa 100644 --- a/test/stdlib/simd_diagnostics.swift +++ b/test/stdlib/simd_diagnostics.swift @@ -1,7 +1,7 @@ // RUN: %target-typecheck-verify-swift // FIXME: No simd module on linux rdar://problem/20795411 -// XFAIL: OS=linux-gnu, OS=windows-msvc, OS=openbsd, OS=linux-android, OS=linux-androideabi +// XFAIL: OS=linux-gnu, OS=windows-msvc, OS=openbsd, OS=linux-android, OS=linux-androideabi, OS=freebsd // XFAIL: OS=wasi import simd