diff --git a/CMakeLists.txt b/CMakeLists.txt index 3082cf9b1d682..c9d6b55c7f48c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1070,6 +1070,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 03b227b3aa411..34c815953aa35 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: @@ -292,6 +295,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 999c1b9aab043..60de204bcf4d6 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -4843,7 +4843,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()); @@ -4873,7 +4874,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())); @@ -4921,7 +4922,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 1db2ba6a5a890..221895b9d9ac3 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -2571,6 +2571,10 @@ PlatformAvailability::PlatformAvailability(const LangOptions &langOpts) case PlatformKind::visionOSApplicationExtension: break; + case PlatformKind::FreeBSD: + deprecatedAsUnavailableMessage = ""; + break; + case PlatformKind::OpenBSD: deprecatedAsUnavailableMessage = ""; break; @@ -2618,6 +2622,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"; @@ -2689,6 +2696,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 f74a6959b3c28..d96a80761cd4f 100644 --- a/lib/IRGen/TBDGen.cpp +++ b/lib/IRGen/TBDGen.cpp @@ -247,6 +247,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 df5c095341f86..1c10d69d4a539 100644 --- a/lib/Option/SanitizerOptions.cpp +++ b/lib/Option/SanitizerOptions.cpp @@ -168,7 +168,7 @@ OptionSet swift::parseSanitizerArgValues( } // Check that we're one of the known supported targets for sanitizers. - if (!(Triple.isOSDarwin() || Triple.isOSLinux() || Triple.isOSWindows() || Triple.isOSWASI())) { + if (!(Triple.isOSDarwin() || Triple.isOSLinux() || Triple.isOSWindows() || Triple.isOSWASI() || 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 771782096e88e..ea36fcbb9488a 100644 --- a/lib/PrintAsClang/DeclAndTypePrinter.cpp +++ b/lib/PrintAsClang/DeclAndTypePrinter.cpp @@ -1795,6 +1795,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/Cxx/std/CMakeLists.txt b/stdlib/public/Cxx/std/CMakeLists.txt index 010dad07b3ba9..a1f6ef3ee915a 100644 --- a/stdlib/public/Cxx/std/CMakeLists.txt +++ b/stdlib/public/Cxx/std/CMakeLists.txt @@ -63,7 +63,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 LINUX_STATIC WINDOWS ANDROID + TARGET_SDKS ALL_APPLE_PLATFORMS LINUX LINUX_STATIC WINDOWS ANDROID FREEBSD MACCATALYST_BUILD_FLAVOR zippered INSTALL_IN_COMPONENT compiler INSTALL_BINARY_SWIFTMODULE NON_DARWIN_ONLY diff --git a/stdlib/public/Platform/Platform.swift b/stdlib/public/Platform/Platform.swift index 016461e90a997..ad401ceedd5ce 100644 --- a/stdlib/public/Platform/Platform.swift +++ b/stdlib/public/Platform/Platform.swift @@ -236,12 +236,12 @@ public func ioctl( // signal.h //===----------------------------------------------------------------------===// -#if os(OpenBSD) +#if 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 @@ -384,3 +384,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..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', @@ -65,6 +66,7 @@ headers = [ 'spawn.h', 'strings.h', 'sys/event.h', + 'sys/extattr.h', 'sys/file.h', 'sys/inotify.h', 'sys/ioctl.h', @@ -84,6 +86,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/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/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 b410bdf3fee92..42cde68486399 100644 --- a/stdlib/public/Synchronization/CMakeLists.txt +++ b/stdlib/public/Synchronization/CMakeLists.txt @@ -59,6 +59,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 @@ -106,6 +113,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 @@ -129,6 +138,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) + } +} diff --git a/stdlib/public/core/CTypes.swift b/stdlib/public/core/CTypes.swift index 20ecba2bcf9bb..69a2771c3172d 100644 --- a/stdlib/public/core/CTypes.swift +++ b/stdlib/public/core/CTypes.swift @@ -116,6 +116,8 @@ public typealias CLongDouble = Double #elseif os(FreeBSD) #if arch(x86_64) || arch(i386) public typealias CLongDouble = Float80 +#elseif arch(arm64) +public typealias CLongDouble = Double #else #error("CLongDouble needs to be defined for this FreeBSD architecture") #endif 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/IDE/complete_decl_attribute.swift b/test/IDE/complete_decl_attribute.swift index a7104e38d3dc3..9082ed637fd86 100644 --- a/test/IDE/complete_decl_attribute.swift +++ b/test/IDE/complete_decl_attribute.swift @@ -83,6 +83,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{{$}} diff --git a/test/Interop/Cxx/stdlib/fake-toolchain-module-interface.swift b/test/Interop/Cxx/stdlib/fake-toolchain-module-interface.swift index 9fbab5154011c..f70b8ae1c02ad 100644 --- a/test/Interop/Cxx/stdlib/fake-toolchain-module-interface.swift +++ b/test/Interop/Cxx/stdlib/fake-toolchain-module-interface.swift @@ -5,6 +5,7 @@ // Android NDK layout might need more flags to find libc++ // XFAIL: OS=linux-androideabi // XFAIL: OS=linux-android +// XFAIL: OS=freebsd // CHECK: enum FakeNamespace { // CHECK: static func foo(_ x: Int32) 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 diff --git a/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp b/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp index 855072cd64d0f..e42bacce30b0f 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp @@ -685,6 +685,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; @@ -736,6 +737,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;