diff --git a/CMakeLists.txt b/CMakeLists.txt index c01a60156a27e..b5c48bec5eca3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -800,6 +800,8 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUA set(SWIFT_USE_LINKER_default "lld") elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(SWIFT_USE_LINKER_default "") +elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) + set(SWIFT_USE_LINKER_default "") else() set(SWIFT_USE_LINKER_default "gold") endif() diff --git a/cmake/modules/SwiftConfigureSDK.cmake b/cmake/modules/SwiftConfigureSDK.cmake index b2fd776326750..66307be68000e 100644 --- a/cmake/modules/SwiftConfigureSDK.cmake +++ b/cmake/modules/SwiftConfigureSDK.cmake @@ -391,11 +391,11 @@ macro(configure_sdk_unix name architectures) message(FATAL_ERROR "unsupported arch for FreeBSD: ${arch}") endif() - if(CMAKE_HOST_SYSTEM_NAME NOT STREQUAL FreeBSD) + if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL FreeBSD) message(WARNING "CMAKE_SYSTEM_VERSION will not match target") endif() - string(REPLACE "[-].*" "" freebsd_system_version ${CMAKE_SYSTEM_VERSION}) + string(REGEX REPLACE "[-].*" "" freebsd_system_version ${CMAKE_SYSTEM_VERSION}) message(STATUS "FreeBSD Version: ${freebsd_system_version}") set(SWIFT_SDK_FREEBSD_ARCH_x86_64_TRIPLE "x86_64-unknown-freebsd${freebsd_system_version}") diff --git a/include/swift/AST/AutoDiff.h b/include/swift/AST/AutoDiff.h index 3bcdc5dc0852e..4c9237c0e2576 100644 --- a/include/swift/AST/AutoDiff.h +++ b/include/swift/AST/AutoDiff.h @@ -416,7 +416,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 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 017f09b7abe44..7aaeadc2aabea 100644 --- a/include/swift/AST/PlatformKinds.def +++ b/include/swift/AST/PlatformKinds.def @@ -32,6 +32,7 @@ AVAILABILITY_PLATFORM(watchOSApplicationExtension, "application extensions for w 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..418a72279ea53 100644 --- a/include/swift/SILOptimizer/Differentiation/DifferentiationInvoker.h +++ b/include/swift/SILOptimizer/Differentiation/DifferentiationInvoker.h @@ -71,8 +71,15 @@ 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 std::pair can't be + /// used here, because it does not have a trivial copy constructor. + struct IndirectDifferentiation { + ApplyInst *applyInst; + SILDifferentiabilityWitness *witness; + }; + IndirectDifferentiation indirectDifferentiation; + Value(ApplyInst *applyInst, SILDifferentiabilityWitness *witness) : indirectDifferentiation({applyInst, witness}) {} @@ -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 1684f363d8272..1a248b4578e9c 100644 --- a/lib/AST/PlatformKind.cpp +++ b/lib/AST/PlatformKind.cpp @@ -89,6 +89,8 @@ static bool isPlatformActiveForTarget(PlatformKind Platform, return Target.isWatchOS(); case PlatformKind::OpenBSD: return Target.isOSOpenBSD(); + case PlatformKind::FreeBSD: + return Target.isOSFreeBSD(); case PlatformKind::Windows: return Target.isOSWindows(); case PlatformKind::none: diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 86c18a3249a03..fa5e712420537 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -6464,7 +6464,8 @@ AnyFunctionType::getAutoDiffDerivativeFunctionLinearMapType( if (!resultTan) { return llvm::make_error( this, DerivativeFunctionTypeError::Kind::NonDifferentiableResult, - std::make_pair(originalResultType, /*index*/ 0)); + DerivativeFunctionTypeError::TypeAndIndex( + originalResultType, /*index*/ 0)); } auto resultTanType = resultTan->getType(); @@ -6497,7 +6498,8 @@ AnyFunctionType::getAutoDiffDerivativeFunctionLinearMapType( this, DerivativeFunctionTypeError::Kind:: NonDifferentiableDifferentiabilityParameter, - std::make_pair(paramType, i)); + DerivativeFunctionTypeError::TypeAndIndex( + paramType, 0)); } differentialParams.push_back(AnyFunctionType::Param( paramTan->getType(), Identifier(), diffParam.getParameterFlags())); @@ -6538,7 +6540,7 @@ AnyFunctionType::getAutoDiffDerivativeFunctionLinearMapType( this, DerivativeFunctionTypeError::Kind:: NonDifferentiableDifferentiabilityParameter, - std::make_pair(paramType, i)); + DerivativeFunctionTypeError::TypeAndIndex(paramType, i)); } if (diffParam.isInOut()) { hasInoutDiffParameter = true; diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 72186c8deea4a..893217bf30c68 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -625,7 +625,7 @@ importer::getNormalInvocationArguments( // using Glibc or a libc that respects that flag. This will cause some // source breakage however (specifically with strerror_r()) on Linux // without a workaround. - if (triple.isOSFuchsia() || triple.isAndroid()) { + if (triple.isOSFuchsia() || triple.isAndroid() || triple.isOSFreeBSD()) { // Many of the modern libc features are hidden behind feature macros like // _GNU_SOURCE or _XOPEN_SOURCE. invocationArgStrs.insert(invocationArgStrs.end(), { @@ -654,7 +654,7 @@ importer::getNormalInvocationArguments( } } - if (searchPathOpts.getSDKPath().empty()) { + if (searchPathOpts.getSDKPath().empty() && !triple.isOSFreeBSD()) { invocationArgStrs.push_back("-Xclang"); invocationArgStrs.push_back("-nostdsysteminc"); } else { @@ -2107,6 +2107,10 @@ PlatformAvailability::PlatformAvailability(const LangOptions &langOpts) deprecatedAsUnavailableMessage = ""; break; + case PlatformKind::FreeBSD: + deprecatedAsUnavailableMessage = ""; + break; + case PlatformKind::Windows: deprecatedAsUnavailableMessage = ""; break; @@ -2147,6 +2151,9 @@ bool PlatformAvailability::isPlatformRelevant(StringRef name) const { case PlatformKind::OpenBSD: return name == "openbsd"; + case PlatformKind::FreeBSD: + return name == "freebsd"; + case PlatformKind::Windows: return name == "windows"; @@ -2214,6 +2221,10 @@ bool PlatformAvailability::treatDeprecatedAsUnavailable( // No deprecation filter on OpenBSD return false; + case PlatformKind::FreeBSD: + // No deprecation filter on FreeBSD + return false; + case PlatformKind::Windows: // No deprecation filter on Windows return false; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index b2fca7c9bd83b..f4d9e6ec4a266 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -357,7 +357,7 @@ Driver::buildToolChain(const llvm::opt::InputArgList &ArgList) { return std::make_unique(*this, target); return std::make_unique(*this, target); case llvm::Triple::FreeBSD: - return std::make_unique(*this, target); + return std::make_unique(*this, target); case llvm::Triple::OpenBSD: return std::make_unique(*this, target); case llvm::Triple::Win32: diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index cdc4fe92e3166..33e38ec83a5fa 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -194,6 +194,16 @@ class LLVM_LIBRARY_VISIBILITY OpenBSD : public GenericUnix { ~OpenBSD() = default; }; +class LLVM_LIBRARY_VISIBILITY FreeBSD : public GenericUnix { +protected: + std::string getDefaultLinker() const override; + +public: + FreeBSD(const Driver &D, const llvm::Triple &Triple) + : GenericUnix(D, Triple) {} + ~FreeBSD() = default; +}; + } // end namespace toolchains } // end namespace driver } // end namespace swift diff --git a/lib/Driver/UnixToolChains.cpp b/lib/Driver/UnixToolChains.cpp index dc14e7782c79a..d2f198f075c60 100644 --- a/lib/Driver/UnixToolChains.cpp +++ b/lib/Driver/UnixToolChains.cpp @@ -418,3 +418,7 @@ std::string toolchains::Cygwin::getDefaultLinker() const { std::string toolchains::OpenBSD::getDefaultLinker() const { return "lld"; } + +std::string toolchains::FreeBSD::getDefaultLinker() const { + return "lld"; +} diff --git a/lib/Frontend/Frontend.cpp b/lib/Frontend/Frontend.cpp index 577ee9b4b43e3..f77307f1fb4ed 100644 --- a/lib/Frontend/Frontend.cpp +++ b/lib/Frontend/Frontend.cpp @@ -781,6 +781,8 @@ static bool shouldImportConcurrencyByDefault(const llvm::Triple &target) { return true; if (target.isOSOpenBSD()) return true; + if (target.isOSFreeBSD()) + return true; #endif return false; } diff --git a/lib/Option/SanitizerOptions.cpp b/lib/Option/SanitizerOptions.cpp index 94a02095c363c..0a64e8e8a810e 100644 --- a/lib/Option/SanitizerOptions.cpp +++ b/lib/Option/SanitizerOptions.cpp @@ -162,7 +162,7 @@ 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 a2614cf32ab8d..7b0abc35f2e95 100644 --- a/lib/PrintAsClang/DeclAndTypePrinter.cpp +++ b/lib/PrintAsClang/DeclAndTypePrinter.cpp @@ -1089,6 +1089,9 @@ class DeclAndTypePrinter::Implementation case PlatformKind::watchOSApplicationExtension: plat = "watchos_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 62f75f1457b97..b46296471243c 100644 --- a/lib/SymbolGraphGen/AvailabilityMixin.cpp +++ b/lib/SymbolGraphGen/AvailabilityMixin.cpp @@ -57,6 +57,8 @@ StringRef getDomain(const AvailableAttr &AvAttr) { return { "tvOSAppExtension" }; case swift::PlatformKind::watchOSApplicationExtension: return { "watchOSAppExtension" }; + case swift::PlatformKind::FreeBSD: + return { "FreeBSD" }; case swift::PlatformKind::OpenBSD: return { "OpenBSD" }; case swift::PlatformKind::Windows: diff --git a/lib/TBDGen/TBDGen.cpp b/lib/TBDGen/TBDGen.cpp index ef276f561bbe6..54e70bbf56b2c 100644 --- a/lib/TBDGen/TBDGen.cpp +++ b/lib/TBDGen/TBDGen.cpp @@ -238,6 +238,8 @@ getLinkerPlatformId(OriginallyDefinedInAttr::ActiveVersion Ver) { switch(Ver.Platform) { case swift::PlatformKind::none: llvm_unreachable("cannot find platform kind"); + case swift::PlatformKind::FreeBSD: + llvm_unreachable("not used for this platform"); case swift::PlatformKind::OpenBSD: llvm_unreachable("not used for this platform"); case swift::PlatformKind::Windows: diff --git a/lib/Threading/Pthreads.cpp b/lib/Threading/Pthreads.cpp index a1a6f85d9de52..1e9887a7c6fb6 100644 --- a/lib/Threading/Pthreads.cpp +++ b/lib/Threading/Pthreads.cpp @@ -101,6 +101,7 @@ swift::threading_impl::thread_get_current_stack_bounds() { #if defined(__FreeBSD__) if (pthread_attr_init(&attr)) return {}; +#define pthread_getattr_np pthread_attr_get_np #endif if (!pthread_getattr_np(pthread_self(), &attr)) { diff --git a/stdlib/cmake/modules/AddSwiftStdlib.cmake b/stdlib/cmake/modules/AddSwiftStdlib.cmake index 9ffd1fccf3ca9..fd04ccf75f8d0 100644 --- a/stdlib/cmake/modules/AddSwiftStdlib.cmake +++ b/stdlib/cmake/modules/AddSwiftStdlib.cmake @@ -294,6 +294,10 @@ function(_add_target_variant_c_compile_flags) endif() endif() + if("${CFLAGS_SDK}" STREQUAL "FREEBSD") + list(APPEND result "-D_GNU_SOURCE") + endif() + if("${CFLAGS_SDK}" STREQUAL "WASI") list(APPEND result "-D_WASI_EMULATED_MMAN") endif() @@ -1090,6 +1094,10 @@ function(add_swift_target_library_single target name) set_target_properties("${target}" PROPERTIES INSTALL_RPATH "$ORIGIN") + elseif("${SWIFTLIB_SINGLE_SDK}" STREQUAL "FREEBSD") + set_target_properties("${target}" + PROPERTIES + INSTALL_RPATH "$ORIGIN") elseif("${SWIFTLIB_SINGLE_SDK}" STREQUAL "CYGWIN") set_target_properties("${target}" PROPERTIES diff --git a/stdlib/private/OSLog/OSLogFloatFormatting.swift b/stdlib/private/OSLog/OSLogFloatFormatting.swift index 8397f849e5abb..eeaa63296b39c 100644 --- a/stdlib/private/OSLog/OSLogFloatFormatting.swift +++ b/stdlib/private/OSLog/OSLogFloatFormatting.swift @@ -350,7 +350,7 @@ extension OSLogFloatFormatting { // fprintf formatters promote Float to Double case is Float.Type: return "" case is Double.Type: return "" -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) // fprintf formatters use L for Float80 case is Float80.Type: return "L" #endif diff --git a/stdlib/private/StdlibUnittest/OpaqueIdentityFunctions.swift b/stdlib/private/StdlibUnittest/OpaqueIdentityFunctions.swift index 98f83cd131d0c..97601cffbed9c 100644 --- a/stdlib/private/StdlibUnittest/OpaqueIdentityFunctions.swift +++ b/stdlib/private/StdlibUnittest/OpaqueIdentityFunctions.swift @@ -77,7 +77,7 @@ public func getFloat32(_ x: Float32) -> Float32 { return _opaqueIdentity(x) } @inline(never) public func getFloat64(_ x: Float64) -> Float64 { return _opaqueIdentity(x) } -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) @inline(never) public func getFloat80(_ x: Float80) -> Float80 { return _opaqueIdentity(x) } #endif diff --git a/stdlib/private/StdlibUnittest/SymbolLookup.swift b/stdlib/private/StdlibUnittest/SymbolLookup.swift index 3916dfc14f957..f41a2fd9cc8c6 100644 --- a/stdlib/private/StdlibUnittest/SymbolLookup.swift +++ b/stdlib/private/StdlibUnittest/SymbolLookup.swift @@ -23,7 +23,7 @@ #error("Unsupported platform") #endif -#if canImport(Darwin) || os(OpenBSD) +#if canImport(Darwin) || os(FreeBSD) || os(OpenBSD) let RTLD_DEFAULT = UnsafeMutableRawPointer(bitPattern: -2) #elseif os(Linux) || os(WASI) let RTLD_DEFAULT = UnsafeMutableRawPointer(bitPattern: 0) diff --git a/stdlib/public/CommandLineSupport/CommandLine.cpp b/stdlib/public/CommandLineSupport/CommandLine.cpp index dd0f743dada8b..e72ba52ef2f37 100644 --- a/stdlib/public/CommandLineSupport/CommandLine.cpp +++ b/stdlib/public/CommandLineSupport/CommandLine.cpp @@ -36,6 +36,8 @@ #include #endif +#include + // Backing storage for overrides of `Swift.CommandLine.arguments`. static char **_swift_stdlib_ProcessOverrideUnsafeArgv = nullptr; static int _swift_stdlib_ProcessOverrideUnsafeArgc = 0; diff --git a/stdlib/public/Differentiation/FloatingPointDifferentiation.swift.gyb b/stdlib/public/Differentiation/FloatingPointDifferentiation.swift.gyb index 3414fd8a51004..12df024629586 100644 --- a/stdlib/public/Differentiation/FloatingPointDifferentiation.swift.gyb +++ b/stdlib/public/Differentiation/FloatingPointDifferentiation.swift.gyb @@ -26,7 +26,7 @@ def Availability(bits): }% % if bits == 80: -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end % if bits == 16: #if !os(macOS) && !(os(iOS) && targetEnvironment(macCatalyst)) diff --git a/stdlib/public/Differentiation/TgmathDerivatives.swift.gyb b/stdlib/public/Differentiation/TgmathDerivatives.swift.gyb index 34d5254c89ae0..5049761f9062b 100644 --- a/stdlib/public/Differentiation/TgmathDerivatives.swift.gyb +++ b/stdlib/public/Differentiation/TgmathDerivatives.swift.gyb @@ -141,7 +141,7 @@ func _${derivative_kind}Trunc${generic_signature} ( % linear_map_kind = 'differential' if derivative_kind == 'jvp' else 'pullback' % for T in ['Float', 'Double', 'Float80']: % if T == 'Float80': -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end @inlinable @derivative(of: exp) @@ -282,7 +282,7 @@ func _${derivative_kind}Erfc(_ x: ${T}) -> (value: ${T}, ${linear_map_kind}: (${ // Binary functions %for T in ['Float', 'Double', 'Float80']: % if T == 'Float80': -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end @inlinable @derivative(of: pow) diff --git a/stdlib/public/Platform/Glibc.swift.gyb b/stdlib/public/Platform/Glibc.swift.gyb index 2de990adfffaf..aabd9090786b3 100644 --- a/stdlib/public/Platform/Glibc.swift.gyb +++ b/stdlib/public/Platform/Glibc.swift.gyb @@ -36,7 +36,7 @@ public let FLT_RADIX = Double.radix %for type, prefix in [('Float', 'FLT'), ('Double', 'DBL'), ('Float80', 'LDBL')]: % if type == "Float80": -#if !os(Android) && (arch(i386) || arch(x86_64)) +#if !(os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end // Where does the 1 come from? C counts the usually-implicit leading // significand bit, but Swift does not. Neither is really right or wrong. diff --git a/stdlib/public/Platform/libc-freebsd.modulemap.gyb b/stdlib/public/Platform/libc-freebsd.modulemap.gyb new file mode 100644 index 0000000000000..835b2547d2163 --- /dev/null +++ b/stdlib/public/Platform/libc-freebsd.modulemap.gyb @@ -0,0 +1,311 @@ +//===--- libc-freebsd.modulemap.gyb ----------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2021 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 +// +//===----------------------------------------------------------------------===// + +/// Partial modulemap for libc on FreeBSD based on 13.0-RELEASE-p1. +module SwiftGlibc [system] { + link "pthread" + link "util" + + // C standard library + module C { + module complex { + header "${GLIBC_INCLUDE_PATH}/complex.h" + export * + } + module ctype { + header "${GLIBC_INCLUDE_PATH}/ctype.h" + export * + } + module errno { + header "${GLIBC_INCLUDE_PATH}/errno.h" + export * + } + module fenv { + header "${GLIBC_INCLUDE_PATH}/fenv.h" + export * + } + module inttypes { + header "${GLIBC_INCLUDE_PATH}/inttypes.h" + export * + } + module locale { + header "${GLIBC_INCLUDE_PATH}/locale.h" + export * + } + module math { + link "m" + header "${GLIBC_INCLUDE_PATH}/math.h" + export * + } + module setjmp { + header "${GLIBC_INCLUDE_PATH}/setjmp.h" + export * + } + module signal { + header "${GLIBC_INCLUDE_PATH}/signal.h" + export * + } + + module stdio { + header "${GLIBC_INCLUDE_PATH}/stdio.h" + export * + } + module stdlib { + header "${GLIBC_INCLUDE_PATH}/stdlib.h" + export * + export stddef + } + module stdint { + header "${GLIBC_INCLUDE_PATH}/stdint.h" + export * + } + module string { + header "${GLIBC_INCLUDE_PATH}/string.h" + export * + } + module time { + header "${GLIBC_INCLUDE_PATH}/time.h" + export * + } + } + + // POSIX + module POSIX { + module cpio { + header "${GLIBC_INCLUDE_PATH}/cpio.h" + export * + } + module nl_types { + header "${GLIBC_INCLUDE_PATH}/nl_types.h" + export * + } + module ftw { + header "${GLIBC_INCLUDE_PATH}/ftw.h" + export * + } + module glob { + header "${GLIBC_INCLUDE_PATH}/glob.h" + export * + } + module langinfo { + header "${GLIBC_INCLUDE_PATH}/langinfo.h" + export * + } + module netdb { + header "${GLIBC_INCLUDE_PATH}/netdb.h" + export * + } + module ifaddrs { + header "${GLIBC_INCLUDE_PATH}/ifaddrs.h" + export * + } + module search { + header "${GLIBC_INCLUDE_PATH}/search.h" + export * + } + module spawn { + header "${GLIBC_INCLUDE_PATH}/spawn.h" + export * + } + module syslog { + header "${GLIBC_INCLUDE_PATH}/syslog.h" + export * + } + module tar { + header "${GLIBC_INCLUDE_PATH}/tar.h" + export * + } + module arpa { + module inet { + header "${GLIBC_INCLUDE_PATH}/arpa/inet.h" + export * + } + export * + } + module dirent { + header "${GLIBC_INCLUDE_PATH}/dirent.h" + export * + } + module dl { + header "${GLIBC_INCLUDE_PATH}/link.h" + export * + } + module dlfcn { + header "${GLIBC_INCLUDE_PATH}/dlfcn.h" + export * + } + module fcntl { + header "${GLIBC_INCLUDE_PATH}/fcntl.h" + export * + } + module fnmatch { + header "${GLIBC_INCLUDE_PATH}/fnmatch.h" + export * + } + module grp { + header "${GLIBC_INCLUDE_PATH}/grp.h" + export * + } + module ioctl { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/ioctl.h" + export * + } + module libgen { + header "${GLIBC_INCLUDE_PATH}/libgen.h" + export * + } + module net { + module if { + header "${GLIBC_INCLUDE_PATH}/net/if.h" + export * + } + } + module netinet { + module in { + header "${GLIBC_INCLUDE_PATH}/netinet/in.h" + export * + + exclude header "${GLIBC_INCLUDE_PATH}/netinet6/in6.h" + } + module tcp { + header "${GLIBC_INCLUDE_PATH}/netinet/tcp.h" + export * + } + } + module poll { + header "${GLIBC_INCLUDE_PATH}/poll.h" + export * + } + module pthread { + header "${GLIBC_INCLUDE_PATH}/pthread.h" + export * + } + module pwd { + header "${GLIBC_INCLUDE_PATH}/pwd.h" + export * + } + module regex { + header "${GLIBC_INCLUDE_PATH}/regex.h" + export * + } + module sched { + header "${GLIBC_INCLUDE_PATH}/sched.h" + export * + } + module semaphore { + header "${GLIBC_INCLUDE_PATH}/semaphore.h" + export * + } + module strings { + header "${GLIBC_INCLUDE_PATH}/strings.h" + export * + } + + module sys { + export * + + module file { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/file.h" + export * + } + module sem { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/sem.h" + export * + } + module shm { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/shm.h" + export * + } + module statvfs { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/statvfs.h" + export * + } + module ipc { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/ipc.h" + export * + } + module mman { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/mman.h" + export * + } + module msg { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/msg.h" + export * + } + module resource { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/resource.h" + export * + } + module select { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/select.h" + export * + } + module socket { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/socket.h" + export * + } + module stat { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/stat.h" + export * + } + module time { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/time.h" + export * + } + module times { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/times.h" + export * + } + module types { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/types.h" + export * + } + module event { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/event.h" + export * + } + module uio { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/uio.h" + export * + } + module un { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/un.h" + export * + } + module user { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/user.h" + export * + } + module utsname { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/utsname.h" + export * + } + module wait { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/wait.h" + export * + } + } + module termios { + header "${GLIBC_INCLUDE_PATH}/termios.h" + export * + } + module unistd { + header "${GLIBC_INCLUDE_PATH}/unistd.h" + export * + } + } +} + +module CUUID [system] { + header "${GLIBC_INCLUDE_PATH}/uuid.h" + export * +} diff --git a/stdlib/public/Platform/tgmath.swift.gyb b/stdlib/public/Platform/tgmath.swift.gyb index cf8c9fa88069b..558258ce9550c 100644 --- a/stdlib/public/Platform/tgmath.swift.gyb +++ b/stdlib/public/Platform/tgmath.swift.gyb @@ -222,7 +222,7 @@ def TypedBinaryFunctions(): // Note these do not have a corresponding LLVM intrinsic % for T, CT, f, ufunc in TypedUnaryFunctions(): % if T == 'Float80': -#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android)) +#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android) || os(FreeBSD)) % end @_transparent public func ${ufunc}(_ x: ${T}) -> ${T} { @@ -239,7 +239,7 @@ public func ${ufunc}(_ x: ${T}) -> ${T} { // Note these have a corresponding LLVM intrinsic % for T, ufunc in TypedUnaryIntrinsicFunctions(): % if T == 'Float80': -#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android)) +#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android) || os(FreeBSD)) % end @_transparent public func ${ufunc}(_ x: ${T}) -> ${T} { @@ -258,7 +258,7 @@ public func ${ufunc}(_ x: ${T}) -> ${T} { % for ufunc in UnaryIntrinsicFunctions: % for T, CT, f in OverlayFloatTypes(): % if T == 'Float80': -#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android)) +#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android) || os(FreeBSD)) % end @_transparent public func ${ufunc}(_ x: ${T}) -> ${T} { @@ -275,7 +275,7 @@ public func ${ufunc}(_ x: ${T}) -> ${T} { % for T, CT, f, bfunc in TypedBinaryFunctions(): % if T == 'Float80': -#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android)) +#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android) || os(FreeBSD)) % end @_transparent public func ${bfunc}(_ lhs: ${T}, _ rhs: ${T}) -> ${T} { @@ -290,7 +290,7 @@ public func ${bfunc}(_ lhs: ${T}, _ rhs: ${T}) -> ${T} { % # This is AllFloatTypes not OverlayFloatTypes because of the tuple return. % for T, CT, f in AllFloatTypes(): % if T == 'Float80': -#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android) || os(OpenBSD)) +#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android) || os(FreeBSD) || os(OpenBSD)) % else: // lgamma not available on Windows, apparently? #if !os(Windows) @@ -308,7 +308,7 @@ public func lgamma(_ x: ${T}) -> (${T}, Int) { % # This is AllFloatTypes not OverlayFloatTypes because of the tuple return. % for T, CT, f in AllFloatTypes(): % if T == 'Float80': -#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android)) +#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android) || os(FreeBSD)) % end @_transparent public func remquo(_ x: ${T}, _ y: ${T}) -> (${T}, Int) { @@ -324,7 +324,7 @@ public func remquo(_ x: ${T}, _ y: ${T}) -> (${T}, Int) { % for T, CT, f in OverlayFloatTypes(): % if T == 'Float80': -#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android)) +#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android) || os(FreeBSD)) % end @available(swift, deprecated: 4.2/*, obsoleted: 5.1*/, message: "use ${T}(nan: ${T}.RawSignificand).") diff --git a/stdlib/public/SwiftShims/SwiftStdint.h b/stdlib/public/SwiftShims/SwiftStdint.h index 7b83e90d72799..1d030dbbad58f 100644 --- a/stdlib/public/SwiftShims/SwiftStdint.h +++ b/stdlib/public/SwiftShims/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__) +#if !defined(__APPLE__) && !defined(__linux__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) #include typedef int64_t __swift_int64_t; typedef uint64_t __swift_uint64_t; diff --git a/stdlib/public/core/BuiltinMath.swift b/stdlib/public/core/BuiltinMath.swift index 762da5135f640..d9437377d7554 100644 --- a/stdlib/public/core/BuiltinMath.swift +++ b/stdlib/public/core/BuiltinMath.swift @@ -113,7 +113,7 @@ public func _rint(_ x: Double) -> Double { // Float80 Intrinsics (80 bits) -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) @_transparent public func _cos(_ x: Float80) -> Float80 { return Float80(Builtin.int_cos_FPIEEE80(x._value)) diff --git a/stdlib/public/core/FloatingPoint.swift b/stdlib/public/core/FloatingPoint.swift index d4f5e6a48e244..01fa3ccbe79c4 100644 --- a/stdlib/public/core/FloatingPoint.swift +++ b/stdlib/public/core/FloatingPoint.swift @@ -1518,7 +1518,7 @@ public protocol BinaryFloatingPoint: FloatingPoint, ExpressibleByFloatLiteral { /// - Parameter value: A floating-point value to be converted. init(_ value: Double) -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) /// Creates a new instance from the given value, rounded to the closest /// possible representation. /// @@ -1929,7 +1929,7 @@ extension BinaryFloatingPoint { significandBitPattern: UInt64(truncatingIfNeeded: value.significandBitPattern)) self = Self(value_) -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) case (15, 63): let value_ = value as? Float80 ?? Float80( sign: value.sign, diff --git a/stdlib/public/core/FloatingPointParsing.swift.gyb b/stdlib/public/core/FloatingPointParsing.swift.gyb index f9343a57c173b..9fe6dca097c9d 100644 --- a/stdlib/public/core/FloatingPointParsing.swift.gyb +++ b/stdlib/public/core/FloatingPointParsing.swift.gyb @@ -41,7 +41,7 @@ internal func _isspace_clocale(_ u: UTF16.CodeUnit) -> Bool { % Self = floatName(bits) % if bits == 80: -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % elif bits == 16: #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) % end diff --git a/stdlib/public/core/FloatingPointTypes.swift.gyb b/stdlib/public/core/FloatingPointTypes.swift.gyb index a223c3764a5e2..1d375957aa848 100644 --- a/stdlib/public/core/FloatingPointTypes.swift.gyb +++ b/stdlib/public/core/FloatingPointTypes.swift.gyb @@ -60,7 +60,7 @@ else: }% % if bits == 80: -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % elif bits == 16: #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) % end @@ -911,7 +911,7 @@ extension ${Self}: _ExpressibleByBuiltinIntegerLiteral, ExpressibleByIntegerLite } % if bits != 80: -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end % builtinFloatLiteralBits = 80 @@ -1117,7 +1117,7 @@ extension ${Self} { % That = src_type.stdlib_name % if srcBits == 80: -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % elif srcBits == 16: #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) % end diff --git a/stdlib/public/core/IntegerTypes.swift.gyb b/stdlib/public/core/IntegerTypes.swift.gyb index b39637f3b8ada..1eae1ca6512c6 100644 --- a/stdlib/public/core/IntegerTypes.swift.gyb +++ b/stdlib/public/core/IntegerTypes.swift.gyb @@ -1128,7 +1128,7 @@ public struct ${Self} % (lower, upper) = getFtoIBounds(floatBits=FloatBits, intBits=int(bits), signed=signed) % if FloatType == 'Float80': -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % elif FloatType == 'Float16': #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) % end diff --git a/stdlib/public/core/Mirrors.swift b/stdlib/public/core/Mirrors.swift index fd682555e494e..55bb30d893986 100644 --- a/stdlib/public/core/Mirrors.swift +++ b/stdlib/public/core/Mirrors.swift @@ -252,7 +252,7 @@ extension Int: _CustomPlaygroundQuickLookable { } } -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) extension Float80: CustomReflectable { /// A mirror that reflects the Float80 instance. public var customMirror: Mirror { diff --git a/stdlib/public/core/Policy.swift b/stdlib/public/core/Policy.swift index 9da0e8aa94c88..3388b1ac75964 100644 --- a/stdlib/public/core/Policy.swift +++ b/stdlib/public/core/Policy.swift @@ -110,7 +110,7 @@ public typealias StringLiteralType = String //===----------------------------------------------------------------------===// // Default types for unconstrained number literals //===----------------------------------------------------------------------===// -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) public typealias _MaxBuiltinFloatType = Builtin.FPIEEE80 #else public typealias _MaxBuiltinFloatType = Builtin.FPIEEE64 diff --git a/stdlib/public/core/Runtime.swift b/stdlib/public/core/Runtime.swift index 53486b890eeba..d162f2a830eca 100644 --- a/stdlib/public/core/Runtime.swift +++ b/stdlib/public/core/Runtime.swift @@ -367,7 +367,7 @@ internal func _float64ToString( } -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) // Returns a UInt64, but that value is the length of the string, so it's // guaranteed to fit into an Int. This is part of the ABI, so we can't diff --git a/stdlib/public/core/VarArgs.swift b/stdlib/public/core/VarArgs.swift index 91429ac4dc8f2..0a4f9c9f45e8d 100644 --- a/stdlib/public/core/VarArgs.swift +++ b/stdlib/public/core/VarArgs.swift @@ -411,7 +411,7 @@ extension Double: _CVarArgPassedAsDouble, _CVarArgAligned { } } -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) extension Float80: CVarArg, _CVarArgAligned { /// Transform `self` into a series of machine words that can be /// appropriately interpreted by C varargs. diff --git a/test/AutoDiff/stdlib/differentiable_stdlib_conformances.swift b/test/AutoDiff/stdlib/differentiable_stdlib_conformances.swift index 21fc2137c28d0..0f0d15d2d28f6 100644 --- a/test/AutoDiff/stdlib/differentiable_stdlib_conformances.swift +++ b/test/AutoDiff/stdlib/differentiable_stdlib_conformances.swift @@ -14,7 +14,7 @@ where T: Differentiable, T == T.TangentVector {} func testFloatingPointDifferentiableConformance() { assertSelfEqualsTangentVector(Float.self) assertSelfEqualsTangentVector(Double.self) - #if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android)) + #if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(Android) || os(FreeBSD)) assertSelfEqualsTangentVector(Float80.self) #endif } diff --git a/test/AutoDiff/stdlib/floating_point.swift.gyb b/test/AutoDiff/stdlib/floating_point.swift.gyb index d9e398bb0f0ab..d8b756988f0b1 100644 --- a/test/AutoDiff/stdlib/floating_point.swift.gyb +++ b/test/AutoDiff/stdlib/floating_point.swift.gyb @@ -1,7 +1,7 @@ // RUN: %target-run-simple-swiftgyb(-Xfrontend -enable-experimental-forward-mode-differentiation) // REQUIRES: executable_test -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) typealias TestLiteralType = Float80 #else typealias TestLiteralType = Double @@ -31,7 +31,7 @@ func expectEqualWithTolerance(_ expected: TestLiteralType, _ actual: T, %for Self in ['Float', 'Double', 'Float80']: %if Self == 'Float80': -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) %end FloatingPointDerivativeTests.test("${Self}.+") { diff --git a/test/AutoDiff/stdlib/tgmath_derivatives.swift.gyb b/test/AutoDiff/stdlib/tgmath_derivatives.swift.gyb index 39535f5f1fb55..0745631835a66 100644 --- a/test/AutoDiff/stdlib/tgmath_derivatives.swift.gyb +++ b/test/AutoDiff/stdlib/tgmath_derivatives.swift.gyb @@ -11,7 +11,7 @@ #error("Unsupported platform") #endif -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) typealias TestLiteralType = Float80 #else typealias TestLiteralType = Double @@ -78,7 +78,7 @@ where T == T.TangentVector { %for T in ['Float', 'Double', 'Float80']: %if T == 'Float80': -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) %end DerivativeTests.test("${op}_${T}") { diff --git a/test/AutoDiff/validation-test/class_differentiation.swift b/test/AutoDiff/validation-test/class_differentiation.swift index bc3f4b926eb4a..0d93606d0cd04 100644 --- a/test/AutoDiff/validation-test/class_differentiation.swift +++ b/test/AutoDiff/validation-test/class_differentiation.swift @@ -390,7 +390,7 @@ ClassTests.test("ClassMethods - generic") { } } -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) class SubSpecializeOverrideCustomDerivatives: Super { @differentiable(reverse, wrt: x) override func f(_ x: Tracked) -> Tracked { @@ -422,7 +422,7 @@ ClassTests.test("ClassMethods - generic") { expectEqual((1, 1), classValueWithGradient(SubOverride())) expectEqual((3, 3), classValueWithGradient(SubSpecializeOverride())) expectEqual((3, 3), classValueWithGradient(SubOverrideCustomDerivatives())) -#if !(os(Windows) || os(Android)) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(Android) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) expectEqual((3, 3), classValueWithGradient(SubSpecializeOverrideCustomDerivatives())) #endif } diff --git a/test/AutoDiff/validation-test/reflection.swift b/test/AutoDiff/validation-test/reflection.swift index 70a558508c776..1a2e824d24246 100644 --- a/test/AutoDiff/validation-test/reflection.swift +++ b/test/AutoDiff/validation-test/reflection.swift @@ -3,6 +3,9 @@ // RUN: %empty-directory(%t) import _Differentiation +// SR-12893 +// XFAIL: freebsd + // RUN: %target-build-swift -Xfrontend -enable-anonymous-context-mangled-names %S/Inputs/AutoDiffTypes.swift -parse-as-library -emit-module -emit-library -module-name TypesToReflect -o %t/%target-library-name(TypesToReflect) // RUN: %target-build-swift -Xfrontend -enable-anonymous-context-mangled-names %S/Inputs/AutoDiffTypes.swift %S/Inputs/main.swift -emit-module -emit-executable -module-name TypesToReflect -o %t/TypesToReflect diff --git a/test/ClangImporter/Dispatch_test.swift b/test/ClangImporter/Dispatch_test.swift index 31081489f890a..8ee552eba8ec8 100644 --- a/test/ClangImporter/Dispatch_test.swift +++ b/test/ClangImporter/Dispatch_test.swift @@ -4,6 +4,7 @@ // UNSUPPORTED: OS=linux-gnu // UNSUPPORTED: OS=linux-android // UNSUPPORTED: OS=openbsd +// UNSUPPORTED: OS=freebsd import Dispatch diff --git a/test/ClangImporter/cfuncs_parse.swift b/test/ClangImporter/cfuncs_parse.swift index 746dce15787b3..49dade07b7f3e 100644 --- a/test/ClangImporter/cfuncs_parse.swift +++ b/test/ClangImporter/cfuncs_parse.swift @@ -64,7 +64,7 @@ func test_pow() { pow(1.5, 2.5) } -#if !((os(Android) || os(Linux)) && arch(arm64)) +#if !((os(Android) || os(Linux)) && arch(arm64)) && !os(FreeBSD) // long doubles in AAPCS64 are 128 bits, which is not supported by // Swift, so don't test this. SR-9072. func test_powl() { diff --git a/test/ClangImporter/clang_builtin_pcm.swift b/test/ClangImporter/clang_builtin_pcm.swift index 4f4d90c8fa8b3..0adf69b5461d9 100644 --- a/test/ClangImporter/clang_builtin_pcm.swift +++ b/test/ClangImporter/clang_builtin_pcm.swift @@ -4,6 +4,9 @@ // RUN: %target-swift-frontend -typecheck -verify -module-cache-path %t/clang-module-cache %s // RUN: ls -lR %t/clang-module-cache | %FileCheck %s +// fails on FreeBSD because `size_t` is not in scope +// XFAIL: freebsd + // CHECK: _Builtin_intrinsics{{.*}}.pcm import _Builtin_intrinsics diff --git a/test/Driver/Dependencies/only-skip-once.swift b/test/Driver/Dependencies/only-skip-once.swift index f632dbd934505..b4bb62e4be2fc 100644 --- a/test/Driver/Dependencies/only-skip-once.swift +++ b/test/Driver/Dependencies/only-skip-once.swift @@ -1,4 +1,4 @@ -// XFAIL: OS=linux-gnu, OS=openbsd, OS=windows-msvc, OS=linux-android, OS=linux-androideabi +// XFAIL: OS=linux-gnu, OS=openbsd, OS=windows-msvc, OS=linux-android, OS=linux-androideabi, OS=freebsd // RUN: %empty-directory(%t) // RUN: cp -r %S/Inputs/only-skip-once/* %t diff --git a/test/Driver/embed-bitcode.swift b/test/Driver/embed-bitcode.swift index 1b21eedd0c01b..7ff10a66a1ca2 100644 --- a/test/Driver/embed-bitcode.swift +++ b/test/Driver/embed-bitcode.swift @@ -1,3 +1,5 @@ +// UNSUPPORTED: freebsd + // RUN: %target-swiftc_driver -driver-print-bindings -embed-bitcode %s 2>&1 | %FileCheck -check-prefix=CHECK-%target-object-format %s // CHECK-macho: "swift-frontend", inputs: ["{{.*}}embed-bitcode.swift"], output: {llvm-bc: "[[BC:.*\.bc]]"} // CHECK-macho: "swift-frontend", inputs: ["[[BC]]"], output: {object: "[[OBJECT:.*\.o]]"} diff --git a/test/Driver/frontend.swift b/test/Driver/frontend.swift index b34eb00876f34..d8ef440a3d036 100644 --- a/test/Driver/frontend.swift +++ b/test/Driver/frontend.swift @@ -1,5 +1,6 @@ // RUN: %swiftc_driver %s -### 2>&1 | %FileCheck %s // UNSUPPORTED: OS=windows-msvc +// UNSUPPORTED: OS=freebsd // CHECK: swift-frontend diff --git a/test/Driver/linker-autolink-extract.swift b/test/Driver/linker-autolink-extract.swift index 907607af0486d..1f210ed30bb36 100644 --- a/test/Driver/linker-autolink-extract.swift +++ b/test/Driver/linker-autolink-extract.swift @@ -1,6 +1,7 @@ // RUN: %swiftc_driver -driver-print-jobs -target x86_64-unknown-linux-gnu -g %s | %FileCheck -check-prefix DEBUG_LINUX %s // REQUIRES: autolink-extract +// UNSUPPORTED: freebsd // DEBUG_LINUX: bin/swift // DEBUG_LINUX-NEXT: bin/swift-autolink-extract diff --git a/test/Driver/subcommands.swift b/test/Driver/subcommands.swift index ce90687f97033..e851d19666a2a 100644 --- a/test/Driver/subcommands.swift +++ b/test/Driver/subcommands.swift @@ -1,6 +1,8 @@ // REQUIRES: shell // Check that 'swift' and 'swift repl' invoke the REPL. +// UNSUPPORTED: freebsd + // RUN: rm -rf %t.dir // RUN: mkdir -p %t.dir/usr/bin // RUN: %hardlink-or-copy(from: %swift_frontend_plain, to: %t.dir/usr/bin/swift) diff --git a/test/IDE/complete_decl_attribute.swift b/test/IDE/complete_decl_attribute.swift index 21dd3a05f10ae..d23126fef5e3f 100644 --- a/test/IDE/complete_decl_attribute.swift +++ b/test/IDE/complete_decl_attribute.swift @@ -58,6 +58,7 @@ actor MyGlobalActor { // 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{{$}} // AVAILABILITY1-NEXT: End completions diff --git a/test/IRGen/abitypes.swift b/test/IRGen/abitypes.swift index 760c2e1d42a20..86a19f195208d 100644 --- a/test/IRGen/abitypes.swift +++ b/test/IRGen/abitypes.swift @@ -1,7 +1,7 @@ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi %s -emit-ir -enable-objc-interop | %FileCheck -check-prefix=%target-cpu-%target-os-abi %s // FIXME: rdar://problem/19648117 Needs splitting objc parts out -// 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 import gadget import Foundation diff --git a/test/IRGen/static_initializer.sil b/test/IRGen/static_initializer.sil index f8532c7a4aae3..6dd7c2654a533 100644 --- a/test/IRGen/static_initializer.sil +++ b/test/IRGen/static_initializer.sil @@ -2,6 +2,9 @@ // REQUIRES: CPU=x86_64 +// fails on FreeBSD because T18static_initializer16TestArrayStorageC_tailelems1c is [1 x i64] instead of [2 x i64] +// XFAIL: freebsd + // Generated from // var x : Int32 = 2 // public func f() -> Int32 { return x } diff --git a/test/Index/Store/driver-index.swift b/test/Index/Store/driver-index.swift index a45c4f0daaf48..0b274a9d6d774 100644 --- a/test/Index/Store/driver-index.swift +++ b/test/Index/Store/driver-index.swift @@ -1,2 +1,2 @@ // RUN: %swiftc_driver -driver-print-jobs -index-file -index-file-path %s %S/Inputs/SwiftModuleA.swift %s -o %t.output_for_index -index-store-path %t.index_store -module-name driver_index 2>&1 | %FileCheck %s -// CHECK: {{.*}}swift{{(-frontend)?(c\.exe")?}} -frontend -typecheck {{.*}}SwiftModuleA.swift{{"?}} -primary-file {{.*}}driver-index.swift{{"?}} {{.*}}-o {{.*}}.output_for_index{{"?}} {{.*}}-disable-typo-correction {{.*}}-index-store-path {{.*}}.index_store{{"?}} -index-system-modules +// CHECK: {{.*}}swift{{(-frontend)?c?(\.exe")?}} -frontend -typecheck {{.*}}SwiftModuleA.swift{{"?}} -primary-file {{.*}}driver-index.swift{{"?}} {{.*}}-o {{.*}}.output_for_index{{"?}} {{.*}}-disable-typo-correction {{.*}}-index-store-path {{.*}}.index_store{{"?}} -index-system-modules diff --git a/test/LinkerSections/function_sections.swift b/test/LinkerSections/function_sections.swift index a2cf2a39a5c34..eb01d59563ea7 100644 --- a/test/LinkerSections/function_sections.swift +++ b/test/LinkerSections/function_sections.swift @@ -1,4 +1,4 @@ -// REQUIRES: OS=linux-gnu || OS=freebsd +// REQUIRES: OS=linux-gnu || OS=linux-androideabi || OS=linux-android || OS=freebsd // RUN: %empty-directory(%t) // RUN: %target-build-swift -Xfrontend -function-sections -emit-module -emit-library -static -parse-stdlib %S/Inputs/FunctionSections.swift // RUN: %target-build-swift -Xlinker --gc-sections -Xlinker -Map=%t/../../FunctionSections.map -I%t/../.. -L%t/../.. -lFunctionSections %S/Inputs/FunctionSectionsUse.swift diff --git a/test/Parse/enum.swift b/test/Parse/enum.swift index 83bee6d5464a3..12bc7589388dc 100644 --- a/test/Parse/enum.swift +++ b/test/Parse/enum.swift @@ -7,6 +7,7 @@ // Windows does not support FP80 // XFAIL: OS=windows-msvc +// XFAIL: OS=freebsd enum Empty {} diff --git a/test/Prototypes/CollectionTransformers.swift b/test/Prototypes/CollectionTransformers.swift index 4943ba01d0c57..1bbbf35535bbc 100644 --- a/test/Prototypes/CollectionTransformers.swift +++ b/test/Prototypes/CollectionTransformers.swift @@ -200,7 +200,7 @@ import Darwin import Dispatch // FIXME: port to Linux. -// XFAIL: OS=linux-gnu, OS=windows-msvc, OS=openbsd, OS=linux-android +// XFAIL: OS=linux-gnu, OS=windows-msvc, OS=openbsd, OS=linux-android, OS=freebsd // A wrapper for pthread_t with platform-independent interface. public struct _stdlib_pthread_t : Equatable, Hashable { diff --git a/test/Reflection/box_descriptors.sil b/test/Reflection/box_descriptors.sil index 6c0b23c02b285..325f244662d5f 100644 --- a/test/Reflection/box_descriptors.sil +++ b/test/Reflection/box_descriptors.sil @@ -7,6 +7,7 @@ // SR-12893 // XFAIL: OS=openbsd +// XFAIL: OS=freebsd sil_stage canonical diff --git a/test/Reflection/capture_descriptors.sil b/test/Reflection/capture_descriptors.sil index 75d99f22138ea..7f79d669ba7d1 100644 --- a/test/Reflection/capture_descriptors.sil +++ b/test/Reflection/capture_descriptors.sil @@ -3,6 +3,7 @@ // SR-12893 // XFAIL: OS=openbsd +// XFAIL: OS=freebsd // UNSUPPORTED: OS=linux-android, OS=linux-androideabi // RUN: %empty-directory(%t) diff --git a/test/Reflection/typeref_decoding_concurrency.swift b/test/Reflection/typeref_decoding_concurrency.swift index 53489cbdd111f..2c61d20a1c14d 100644 --- a/test/Reflection/typeref_decoding_concurrency.swift +++ b/test/Reflection/typeref_decoding_concurrency.swift @@ -10,6 +10,10 @@ // UNSUPPORTED: use_os_stdlib // UNSUPPORTED: back_deployment_runtime +// SR-12893 +// XFAIL: openbsd +// XFAIL: freebsd + // RUN: %empty-directory(%t) // RUN: %target-build-swift -Xfrontend -enable-anonymous-context-mangled-names %S/Inputs/ConcurrencyTypes.swift -parse-as-library -emit-module -emit-library -module-name TypesToReflect -o %t/%target-library-name(TypesToReflect) -target x86_64-apple-macosx12.0 diff --git a/test/Reflection/typeref_decoding_imported.swift b/test/Reflection/typeref_decoding_imported.swift index de550812f7ba3..1822f1f5fa3ad 100644 --- a/test/Reflection/typeref_decoding_imported.swift +++ b/test/Reflection/typeref_decoding_imported.swift @@ -2,6 +2,7 @@ // SR-12893 // XFAIL: OS=openbsd +// XFAIL: OS=freebsd // RUN: %empty-directory(%t) diff --git a/test/SILOptimizer/diagnostic_constant_propagation_floats_x86.swift b/test/SILOptimizer/diagnostic_constant_propagation_floats_x86.swift index c32c83d7d982a..4f442a1ac0975 100644 --- a/test/SILOptimizer/diagnostic_constant_propagation_floats_x86.swift +++ b/test/SILOptimizer/diagnostic_constant_propagation_floats_x86.swift @@ -3,6 +3,7 @@ // // REQUIRES: CPU=i386 || CPU=x86_64 // UNSUPPORTED: OS=windows-msvc +// UNSUPPORTED: OS=freebsd // // These are tests for diagnostics produced by constant propagation pass // on floating-point operations that are specific to x86 architectures, diff --git a/test/Sanitizers/tsan/actor_counters.swift b/test/Sanitizers/tsan/actor_counters.swift index 4fd7d86140daa..830af66af6c09 100644 --- a/test/Sanitizers/tsan/actor_counters.swift +++ b/test/Sanitizers/tsan/actor_counters.swift @@ -7,6 +7,7 @@ // UNSUPPORTED: use_os_stdlib // UNSUPPORTED: OS=linux-gnu // UNSUPPORTED: OS=windows-msvc +// UNSUPPORTED: OS=freebsd // REQUIRES: rdar83246843 diff --git a/test/Sanitizers/tsan/basic_future.swift b/test/Sanitizers/tsan/basic_future.swift index d14dbdd89bb3e..f2d8f0adcfc74 100644 --- a/test/Sanitizers/tsan/basic_future.swift +++ b/test/Sanitizers/tsan/basic_future.swift @@ -6,6 +6,8 @@ // REQUIRES: tsan_runtime // UNSUPPORTED: use_os_stdlib +// XFAIL: freebsd + import Dispatch #if canImport(Darwin) diff --git a/test/Sanitizers/tsan/mainactor.swift b/test/Sanitizers/tsan/mainactor.swift index 3688a94f4c6d3..a1110db90d6c2 100644 --- a/test/Sanitizers/tsan/mainactor.swift +++ b/test/Sanitizers/tsan/mainactor.swift @@ -7,6 +7,8 @@ // UNSUPPORTED: use_os_stdlib // UNSUPPORTED: threading_none +// XFAIL: freebsd + import Dispatch /// @returns true iff the expected answer is actually the case, i.e., correct. diff --git a/test/Sanitizers/tsan/tsan.swift b/test/Sanitizers/tsan/tsan.swift index 5ab536a61651b..19773d1057825 100644 --- a/test/Sanitizers/tsan/tsan.swift +++ b/test/Sanitizers/tsan/tsan.swift @@ -11,6 +11,8 @@ // don't support TSan. // UNSUPPORTED: remote_run +// XFAIL: freebsd + #if canImport(Darwin) import Darwin #elseif canImport(Glibc) @@ -47,7 +49,7 @@ var racey_x: Int; // TSan %deflake as part of the test. for _ in 1...5 { -#if os(macOS) || os(iOS) +#if os(macOS) || os(iOS) || os(FreeBSD) var t : pthread_t? #else var t : pthread_t = 0 @@ -58,7 +60,7 @@ for _ in 1...5 { return nil }, nil) -#if os(macOS) || os(iOS) +#if os(macOS) || os(iOS) || os(FreeBSD) threads.append(t!) #else threads.append(t) @@ -70,6 +72,7 @@ for t in threads { print("nil thread") continue } + print("Thread \(t)") pthread_join(t, nil) } diff --git a/test/lit.cfg b/test/lit.cfg index bcaa103bf6370..aaf11a5791f7e 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -220,7 +220,7 @@ config.llvm_obj_root = getattr(config, 'llvm_obj_root', None) lto_flags = "" -if platform.system() == 'OpenBSD': +if platform.system() == 'OpenBSD' or platform.system() == 'FreeBSD': llvm_libs_dir = getattr(config, 'llvm_libs_dir', None) if not llvm_libs_dir: lit_config.fatal('No LLVM libs dir set.') @@ -398,6 +398,12 @@ if run_os == 'openbsd' and run_cpu == 'amd64': target_arch = run_cpu run_cpu = 'x86_64' +# FreeBSD uses the amd64 cpu identifier, which is equivalent to +# x86_64, but Swift uses x86_64 only, so we set it to that +if run_os == 'freebsd' and run_cpu == 'amd64': + target_arch = run_cpu + run_cpu = 'x86_64' + run_ptrsize = '64' if ('64' in run_cpu or run_cpu == "s390x") else '32' if run_cpu == 'arm64_32': run_ptrsize = '32' diff --git a/test/stdlib/DispatchTypes.swift b/test/stdlib/DispatchTypes.swift index 536bd8ef83faa..a62f15c5919d2 100644 --- a/test/stdlib/DispatchTypes.swift +++ b/test/stdlib/DispatchTypes.swift @@ -4,6 +4,7 @@ // UNSUPPORTED: OS=linux-gnu // UNSUPPORTED: OS=linux-android // UNSUPPORTED: OS=openbsd +// UNSUPPORTED: OS=freebsd import Dispatch diff --git a/test/stdlib/FloatingPoint.swift.gyb b/test/stdlib/FloatingPoint.swift.gyb index 84953ac355c6c..25aa2cc55a903 100644 --- a/test/stdlib/FloatingPoint.swift.gyb +++ b/test/stdlib/FloatingPoint.swift.gyb @@ -4,7 +4,7 @@ import Swift import StdlibUnittest -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) struct Float80Bits : Equatable, CustomStringConvertible { var signAndExponent: UInt16 @@ -54,7 +54,7 @@ extension Float80 { % ('Float80', 'Float80Bits') % ]: % if FloatTy == 'Float80': -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end func expectBitwiseEqual( _ expected: ${FloatTy}, _ actual: ${FloatTy}, @@ -480,7 +480,7 @@ func genericAbs(_ x: T) -> T { %for Self in ['Float', 'Double', 'Float80']: % if Self == 'Float80': -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end FloatingPoint.test("${Self}.round") { for rule in [FloatingPointRoundingRule.toNearestOrAwayFromZero, @@ -665,7 +665,7 @@ FloatingPoint.test("${Self}.nextUp, .nextDown/nan") { } %end -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) FloatingPoint.test("Float80/ExpressibleByIntegerLiteral") { expectEqual(positiveOne(), 1.0 as Float80) @@ -886,7 +886,7 @@ FloatingPoint.test("${FloatSelf}/{Comparable,Hashable,Equatable}") { % end % for Self in ['Float32', 'Float64', 'Float80']: -#if ${'!os(Windows) && (arch(i386) || arch(x86_64))' if Self == 'Float80' else 'true'} +#if ${'!(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64))' if Self == 'Float80' else 'true'} FloatingPoint.test("${Self}/Strideable") { // FIXME: the test data could probably be better chosen here, to // exercise more cases. Note: NaNs (and possibly Infs) are singular @@ -1079,7 +1079,7 @@ FloatingPoint.test("Float64/Literals") { } } -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) FloatingPoint.test("Float80/Literals") { do { @@ -1223,7 +1223,7 @@ FloatingPoint.test("Float64/quietNaN") { #endif } -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) FloatingPoint.test("Float80/quietNaN") { do { @@ -1327,7 +1327,7 @@ FloatingPoint.test("Float64/signalingNaN") { #endif -#if !os(Windows) && arch(x86_64) +#if !(os(Windows) || os(FreeBSD)) && arch(x86_64) FloatingPoint.test("Float80/signalingNaN") { do { diff --git a/test/stdlib/FloatingPointIR_FP80.swift b/test/stdlib/FloatingPointIR_FP80.swift index a5f0344ec054e..1de34d2588133 100644 --- a/test/stdlib/FloatingPointIR_FP80.swift +++ b/test/stdlib/FloatingPointIR_FP80.swift @@ -4,6 +4,7 @@ // REQUIRES: CPU=i386 || CPU=x86_64 // UNSUPPORTED: OS=windows-msvc +// UNSUPPORTED: OS=freebsd var globalFloat80 : Float80 = 0.0 diff --git a/test/stdlib/Inputs/FloatingPointConversion.swift.gyb b/test/stdlib/Inputs/FloatingPointConversion.swift.gyb index 433c232733857..d512657a5d17d 100644 --- a/test/stdlib/Inputs/FloatingPointConversion.swift.gyb +++ b/test/stdlib/Inputs/FloatingPointConversion.swift.gyb @@ -20,7 +20,7 @@ var FloatingPointConversionFailures = TestSuite("FloatingPointToFloatingPointCon #if !os(macOS) && !(os(iOS) && targetEnvironment(macCatalyst)) % end % if Self == 'Float80': -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end % for other_type in all_floating_point_types(): @@ -31,7 +31,7 @@ var FloatingPointConversionFailures = TestSuite("FloatingPointToFloatingPointCon #if !os(macOS) && !(os(iOS) && targetEnvironment(macCatalyst)) % end % if OtherFloat == 'Float80': -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end % if OtherSignificandBits <= SelfSignificandBits: diff --git a/test/stdlib/NumericParsing.swift.gyb b/test/stdlib/NumericParsing.swift.gyb index 26c3a87e6957c..2b846d21c37fe 100644 --- a/test/stdlib/NumericParsing.swift.gyb +++ b/test/stdlib/NumericParsing.swift.gyb @@ -137,7 +137,7 @@ tests.test("FixedWidthInteger/maxUInt64") { % for Self in 'Float', 'Double', 'Float80': % if Self == 'Float80': -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end tests.test("${Self}/Basics") { diff --git a/test/stdlib/NumericParsing2.swift.gyb b/test/stdlib/NumericParsing2.swift.gyb index e0facb797606d..e93a8b69b336d 100644 --- a/test/stdlib/NumericParsing2.swift.gyb +++ b/test/stdlib/NumericParsing2.swift.gyb @@ -37,7 +37,7 @@ var tests = TestSuite("NumericParsing2") % for Self in 'Float', 'Double', 'Float80': % if Self == 'Float80': -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end tests.test("${Self}/Overflow/Underflow") { diff --git a/test/stdlib/POSIX.swift b/test/stdlib/POSIX.swift index c60aa771c0000..d22daf9f9d81d 100644 --- a/test/stdlib/POSIX.swift +++ b/test/stdlib/POSIX.swift @@ -17,7 +17,12 @@ chdir(CommandLine.arguments[1]) var POSIXTests = TestSuite("POSIXTests") -let semaphoreName = "TestSem" +// POSIX requires names that begin with `/` to work, +// but lets implementations decide what to do with +// names that don't. For better compatibility, we +// use a name that starts with `/`. +let semaphoreName = "/TestSem" + #if os(Android) // In Android, the cwd is the root directory, which is not writable. let fn: String = { @@ -136,9 +141,11 @@ POSIXTests.test("ioctl(CInt, UInt, CInt): fail") { expectEqual(-1, fd) expectEqual(ENOENT, errno) +#if !os(FreeBSD) // A simple check to verify that ioctl is available let _ = ioctl(fd, 0, 0) expectEqual(EBADF, errno) +#endif } #if os(Linux) || os(Android) diff --git a/test/stdlib/PrintFloat.swift.gyb b/test/stdlib/PrintFloat.swift.gyb index 8d36cb0449156..bd64aa702b4f3 100644 --- a/test/stdlib/PrintFloat.swift.gyb +++ b/test/stdlib/PrintFloat.swift.gyb @@ -294,7 +294,7 @@ fileprivate let generatedCases_Double: [(Double, String)] = [ (0x1.63ed4a60c9c91p+324, "4.751595491707413e+97") ] -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) // Float80 found via Errol technique. // // As with Double, except for Float80. The original list in this @@ -350,7 +350,7 @@ let PrintTests = TestSuite("FloatingPointPrinting") #if !((os(macOS) || targetEnvironment(macCatalyst)) && arch(x86_64)) @available(SwiftStdlib 5.3, *) % elif FloatType == 'Float80': -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) % end // Verify that a particular value provides a specific description string. @@ -547,7 +547,7 @@ PrintTests.test("CustomStringConvertible") { hasDescription(Float(1.0)) hasDescription(Double(1.0)) -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) hasDescription(Float80(1.0)) #endif hasDescription(CFloat(1.0)) @@ -563,7 +563,7 @@ PrintTests.test("CustomDebugStringConvertible") { hasDebugDescription(Float(1.0)) hasDebugDescription(Double(1.0)) -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) hasDebugDescription(Float80(1.0)) #endif hasDebugDescription(CFloat(1.0)) @@ -981,7 +981,7 @@ PrintTests.test("Printable_Double") { } PrintTests.test("Printable_Float80") { -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) func asFloat80(_ f: Swift.Float80) -> Swift.Float80 { return f } // Sanity diff --git a/test/stdlib/VarArgs.swift b/test/stdlib/VarArgs.swift index 9e5c36c52d73d..e49090f50dc28 100644 --- a/test/stdlib/VarArgs.swift +++ b/test/stdlib/VarArgs.swift @@ -155,7 +155,7 @@ func test_varArgs6() { let i8 = Int8(1) let f32 = Float(1.1) let f64 = Double(2.2) -#if !os(Windows) && (arch(i386) || arch(x86_64)) +#if !(os(Windows) || os(FreeBSD)) && (arch(i386) || arch(x86_64)) let f80 = Float80(4.5) my_printf("a %g %d %g %d %Lg %d %g a\n", f32, i8, f64, i8, f80, i8, f32) my_printf("b %d %g %d %g %d %Lg %d %g b\n", i8, f32, i8, f64, i8, f80, i8, f32) 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/test/stdlib/tgmath.swift.gyb b/test/stdlib/tgmath.swift.gyb index 1a982fb1617a9..ef691534c2112 100644 --- a/test/stdlib/tgmath.swift.gyb +++ b/test/stdlib/tgmath.swift.gyb @@ -29,7 +29,7 @@ #error("Unsupported platform") #endif -#if (arch(i386) || arch(x86_64)) && !os(Windows) +#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(FreeBSD)) typealias TestLiteralType = Float80 #else typealias TestLiteralType = Double @@ -83,7 +83,7 @@ internal protocol TGMath: BinaryFloatingPoint { %end static func _remquo(_ x: Self, _ y: Self) -> (Self, Int) static func _fma(_ x: Self, _ y: Self, _ z: Self) -> Self -#if !os(Windows) && !os(OpenBSD) +#if !(os(Windows) || os(FreeBSD) || os(OpenBSD)) static func _lgamma(_ x: Self) -> (Self, Int) #endif static func _modf(_ x: Self) -> (Self, Self) @@ -124,7 +124,7 @@ internal extension TGMath { expectEqualWithTolerance(0.4041169094348222983238250859191217675, Self._erf(0.375)) expectEqualWithTolerance(0.5958830905651777016761749140808782324, Self._erfc(0.375)) expectEqualWithTolerance(2.3704361844166009086464735041766525098, Self._tgamma(0.375)) -#if !os(Windows) && !os(OpenBSD) +#if !(os(Windows) || os(FreeBSD) || os(OpenBSD)) expectEqualWithTolerance( -0.11775527074107877445136203331798850, Self._lgamma(1.375).0, ulps: 16) expectEqual(1, Self._lgamma(1.375).1) #endif @@ -176,7 +176,7 @@ internal extension TGMath { %for T in ['Float', 'Double', 'CGFloat', 'Float80']: % if T == 'Float80': -#if (arch(i386) || arch(x86_64)) && !os(Windows) +#if (arch(i386) || arch(x86_64)) && !(os(Windows) || os(FreeBSD)) % elif T == 'CGFloat': #if _runtime(_ObjC) && canImport(CoreGraphics) import CoreGraphics @@ -191,7 +191,7 @@ extension ${T}: TGMath { %end static func _remquo(_ x: ${T}, _ y: ${T}) -> (${T}, Int) { return remquo(x, y) } static func _fma(_ x: ${T}, _ y: ${T}, _ z: ${T}) -> ${T} { return fma(x, y, z) } -#if !os(Windows) && !os(OpenBSD) +#if !(os(Windows) || os(FreeBSD) || os(OpenBSD)) static func _lgamma(_ x: ${T}) -> (${T}, Int) { return lgamma(x) } #endif static func _modf(_ x: ${T}) -> (${T}, ${T}) { return modf(x) } diff --git a/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp b/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp index 1b5aeda85795d..2193002d6201f 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftDocSupport.cpp @@ -681,6 +681,7 @@ static void reportAttributes(ASTContext &Ctx, 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; @@ -711,6 +712,8 @@ static void reportAttributes(ASTContext &Ctx, PlatformUID = PlatformtvOSAppExt; break; case PlatformKind::watchOSApplicationExtension: PlatformUID = PlatformWatchOSAppExt; break; + case PlatformKind::FreeBSD: + PlatformUID = PlatformFreeBSD; break; case PlatformKind::OpenBSD: PlatformUID = PlatformOpenBSD; break; case PlatformKind::Windows: diff --git a/tools/swift-dependency-tool/swift-dependency-tool.cpp b/tools/swift-dependency-tool/swift-dependency-tool.cpp index c8c900bc472bf..6b2209d5b8e73 100644 --- a/tools/swift-dependency-tool/swift-dependency-tool.cpp +++ b/tools/swift-dependency-tool/swift-dependency-tool.cpp @@ -30,7 +30,7 @@ using namespace fine_grained_dependencies; // This introduces a redefinition where ever std::is_same_t // holds -#if !(defined(__linux__) || defined(_WIN64)) +#if !(defined(__linux__) || defined(_WIN64) || defined(__FreeBSD__)) LLVM_YAML_DECLARE_SCALAR_TRAITS(size_t, QuotingType::None) #endif LLVM_YAML_DECLARE_ENUM_TRAITS(swift::fine_grained_dependencies::NodeKind) @@ -89,7 +89,7 @@ LLVM_YAML_DECLARE_MAPPING_TRAITS( namespace llvm { namespace yaml { // This introduces a redefinition for Linux. -#if !(defined(__linux__) || defined(_WIN64)) +#if !(defined(__linux__) || defined(_WIN64) || defined(__FreeBSD__)) void ScalarTraits::output(const size_t &Val, void *, raw_ostream &out) { out << Val; }