From 014963fdcfa733e13ccd79b0524e3174f95fbd31 Mon Sep 17 00:00:00 2001 From: K Staring Date: Tue, 13 Sep 2016 09:23:57 +0200 Subject: [PATCH 01/25] add define for FreeBSD getline() compat --- tools/swift-demangle/swift-demangle.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/swift-demangle/swift-demangle.cpp b/tools/swift-demangle/swift-demangle.cpp index dcbcf0139619..934331bea551 100644 --- a/tools/swift-demangle/swift-demangle.cpp +++ b/tools/swift-demangle/swift-demangle.cpp @@ -14,6 +14,10 @@ // //===----------------------------------------------------------------------===// +#if defined(__FreeBSD__) +#define _WITH_GETLINE +#endif + #include "swift/Basic/DemangleWrappers.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/CommandLine.h" @@ -102,6 +106,8 @@ static void demangle(llvm::raw_ostream &os, llvm::StringRef name, } } +extern ssize_t getline(char **linep, size_t *linecapp, FILE *stream); + static int demangleSTDIN(const swift::Demangle::DemangleOptions &options) { // This doesn't handle Unicode symbols, but maybe that's okay. llvm::Regex maybeSymbol("_T[_a-zA-Z0-9$]+"); From 6428295d701ae9a65d72d0ec4156b0af0048e072 Mon Sep 17 00:00:00 2001 From: K Staring Date: Wed, 14 Sep 2016 20:00:33 +0200 Subject: [PATCH 02/25] Two fixes for FreeBSD build add /usr/local/include to include path in stdlib/public/stubs use FreeBSD procfs path to cmdline when building for FreeBSD --- stdlib/public/stubs/CMakeLists.txt | 4 ++++ stdlib/public/stubs/CommandLine.cpp | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/stdlib/public/stubs/CMakeLists.txt b/stdlib/public/stubs/CMakeLists.txt index c47fb2c24552..71df4316c450 100644 --- a/stdlib/public/stubs/CMakeLists.txt +++ b/stdlib/public/stubs/CMakeLists.txt @@ -1,6 +1,10 @@ set(swift_stubs_objc_sources) set(swift_stubs_unicode_normalization_sources) +include_directories(AFTER + /usr/local/include +) + if(SWIFT_HOST_VARIANT MATCHES "${SWIFT_DARWIN_VARIANTS}") set(swift_stubs_objc_sources Availability.mm diff --git a/stdlib/public/stubs/CommandLine.cpp b/stdlib/public/stubs/CommandLine.cpp index 2132140091ab..2355b87499b0 100644 --- a/stdlib/public/stubs/CommandLine.cpp +++ b/stdlib/public/stubs/CommandLine.cpp @@ -58,6 +58,11 @@ extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { return *_NSGetArgv(); } #elif defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD__) +#if defined(__FreeBSD__) +# define PROCFS_CMDLINE_PATH "/proc/curproc/cmdline" +#else +# define PROCFS_CMDLINE_PATH "/proc/self/cmdline" +#endif SWIFT_RUNTIME_STDLIB_INTERFACE extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { assert(outArgLen != nullptr); @@ -67,10 +72,12 @@ extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { return _swift_stdlib_ProcessOverrideUnsafeArgv; } - FILE *cmdline = fopen("/proc/self/cmdline", "rb"); + FILE *cmdline = fopen(PROCFS_CMDLINE_PATH, "rb"); if (!cmdline) { swift::fatalError(0, - "fatal error: Unable to open interface to '/proc/self/cmdline'.\n"); + "fatal error: Unable to open interface to '" + PROCFS_CMDLINE_PATH + "'.\n"); } char *arg = nullptr; size_t size = 0; From afc95a5e2adee291239674649bdb8f0f2e1f2530 Mon Sep 17 00:00:00 2001 From: K Staring Date: Tue, 13 Sep 2016 11:08:00 +0200 Subject: [PATCH 03/25] disable handy pthread wrappers on FreeBSD since they don't compile Things like: PthreadBarriers.swift:114:50: error: cannot convert value of type 'UnsafeMutablePointer' (aka 'UnsafeMutablePointer') to expected argument type 'UnsafeMutablePointer' (aka 'UnsafeMutablePointer>') on barrier.pointee.mutex . I need to do more research to understand this --- stdlib/private/StdlibUnittest/RaceTest.swift | 2 ++ .../SwiftPrivatePthreadExtras/PthreadBarriers.swift | 2 ++ .../SwiftPrivatePthreadExtras.swift | 2 ++ stdlib/public/Platform/glibc.modulemap.gyb | 3 +++ stdlib/public/stubs/CMakeLists.txt | 8 +++++--- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/stdlib/private/StdlibUnittest/RaceTest.swift b/stdlib/private/StdlibUnittest/RaceTest.swift index 8795ce1af0f6..967cf480edbe 100644 --- a/stdlib/private/StdlibUnittest/RaceTest.swift +++ b/stdlib/private/StdlibUnittest/RaceTest.swift @@ -54,6 +54,7 @@ func autoreleasepool(invoking code: () -> Void) { } #endif +#if !os(FreeBSD) /// Race tests that need a fresh set of data for every trial should implement /// this protocol. /// @@ -603,3 +604,4 @@ public func runRaceTest( runRaceTest(ClosureBasedRaceTest.self, trials: trials, threads: threads) } +#endif diff --git a/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift b/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift index 19d006297ad3..c2e39d236d07 100644 --- a/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift +++ b/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift @@ -16,6 +16,7 @@ import Darwin import Glibc #endif +#if !os(FreeBSD) // // Implement pthread barriers. // @@ -129,3 +130,4 @@ public func _stdlib_pthread_barrier_wait( return _stdlib_PTHREAD_BARRIER_SERIAL_THREAD } } +#endif diff --git a/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift b/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift index e5566f8b3e9a..a04a4a1306f3 100644 --- a/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift +++ b/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift @@ -21,6 +21,7 @@ import Darwin import Glibc #endif +#if !os(FreeBSD) /// An abstract base class to encapsulate the context necessary to invoke /// a block from pthread_create. internal class PthreadBlockContext { @@ -140,3 +141,4 @@ public class _stdlib_Barrier { } } } +#endif diff --git a/stdlib/public/Platform/glibc.modulemap.gyb b/stdlib/public/Platform/glibc.modulemap.gyb index a0f7987701a2..c7e36dd65694 100644 --- a/stdlib/public/Platform/glibc.modulemap.gyb +++ b/stdlib/public/Platform/glibc.modulemap.gyb @@ -35,6 +35,7 @@ module SwiftGlibc [system] { header "${GLIBC_INCLUDE_PATH}/complex.h" export * } +% if CMAKE_SDK != "FREEBSD": module pty { header "${GLIBC_INCLUDE_PATH}/pty.h" export * @@ -351,10 +352,12 @@ module SwiftGlibc [system] { header "${GLIBC_ARCH_INCLUDE_PATH}/sys/select.h" export * } +% if CMAKE_SDK != "FREEBSD": module sendfile { header "${GLIBC_ARCH_INCLUDE_PATH}/sys/sendfile.h" export * } +% end module socket { header "${GLIBC_ARCH_INCLUDE_PATH}/sys/socket.h" export * diff --git a/stdlib/public/stubs/CMakeLists.txt b/stdlib/public/stubs/CMakeLists.txt index 71df4316c450..3dc6f594c952 100644 --- a/stdlib/public/stubs/CMakeLists.txt +++ b/stdlib/public/stubs/CMakeLists.txt @@ -1,9 +1,11 @@ set(swift_stubs_objc_sources) set(swift_stubs_unicode_normalization_sources) -include_directories(AFTER - /usr/local/include -) +if("${CMAKE_SDK}" STREQUAL "FREEBSD") + include_directories(AFTER + /usr/local/include + ) +endif() if(SWIFT_HOST_VARIANT MATCHES "${SWIFT_DARWIN_VARIANTS}") set(swift_stubs_objc_sources From f11d05717ef6663024077e243947cb631655bb8f Mon Sep 17 00:00:00 2001 From: K Staring Date: Tue, 13 Sep 2016 11:18:07 +0200 Subject: [PATCH 04/25] CMAKE_SDK apparenty isn't always filled when cmake runs; always use /usr/local/include for now --- stdlib/public/stubs/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/public/stubs/CMakeLists.txt b/stdlib/public/stubs/CMakeLists.txt index 3dc6f594c952..0e5b92ed3a5e 100644 --- a/stdlib/public/stubs/CMakeLists.txt +++ b/stdlib/public/stubs/CMakeLists.txt @@ -1,11 +1,11 @@ set(swift_stubs_objc_sources) set(swift_stubs_unicode_normalization_sources) -if("${CMAKE_SDK}" STREQUAL "FREEBSD") +#if(${SWIFT_SDK} STREQUAL "FREEBSD") include_directories(AFTER /usr/local/include ) -endif() +#endif() if(SWIFT_HOST_VARIANT MATCHES "${SWIFT_DARWIN_VARIANTS}") set(swift_stubs_objc_sources From 4c84a33233750e861398b4e2b05812d66dc16815 Mon Sep 17 00:00:00 2001 From: K Staring Date: Thu, 15 Sep 2016 19:08:27 +0200 Subject: [PATCH 05/25] remove extraneous extern getline --- tools/swift-demangle/swift-demangle.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/swift-demangle/swift-demangle.cpp b/tools/swift-demangle/swift-demangle.cpp index 934331bea551..61021a0aa12f 100644 --- a/tools/swift-demangle/swift-demangle.cpp +++ b/tools/swift-demangle/swift-demangle.cpp @@ -106,8 +106,6 @@ static void demangle(llvm::raw_ostream &os, llvm::StringRef name, } } -extern ssize_t getline(char **linep, size_t *linecapp, FILE *stream); - static int demangleSTDIN(const swift::Demangle::DemangleOptions &options) { // This doesn't handle Unicode symbols, but maybe that's okay. llvm::Regex maybeSymbol("_T[_a-zA-Z0-9$]+"); From 4dbf4de036e76071eb41668c0c6e1e01946f85ca Mon Sep 17 00:00:00 2001 From: K Staring Date: Fri, 16 Sep 2016 20:49:22 +0200 Subject: [PATCH 06/25] don't try to link "dl" on FreeBSD --- stdlib/public/Platform/glibc.modulemap.gyb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stdlib/public/Platform/glibc.modulemap.gyb b/stdlib/public/Platform/glibc.modulemap.gyb index c7e36dd65694..fe1bb520a859 100644 --- a/stdlib/public/Platform/glibc.modulemap.gyb +++ b/stdlib/public/Platform/glibc.modulemap.gyb @@ -26,7 +26,9 @@ module SwiftGlibc [system] { link "util" % end +% if CMAKE_SDK != "FREEBSD": link "dl" +% end // C standard library module C { From 98a8b589575fe07afd2fb9841649b09018f0defd Mon Sep 17 00:00:00 2001 From: K Staring Date: Tue, 20 Sep 2016 03:46:35 +0200 Subject: [PATCH 07/25] add //FIXME for FreeBSD outcommented code, add sys/event.h for kqueue (untested) --- stdlib/private/StdlibUnittest/RaceTest.swift | 1 + .../private/SwiftPrivatePthreadExtras/PthreadBarriers.swift | 1 + .../SwiftPrivatePthreadExtras.swift | 1 + stdlib/public/Platform/glibc.modulemap.gyb | 6 ++++++ 4 files changed, 9 insertions(+) diff --git a/stdlib/private/StdlibUnittest/RaceTest.swift b/stdlib/private/StdlibUnittest/RaceTest.swift index 967cf480edbe..29844422e91a 100644 --- a/stdlib/private/StdlibUnittest/RaceTest.swift +++ b/stdlib/private/StdlibUnittest/RaceTest.swift @@ -54,6 +54,7 @@ func autoreleasepool(invoking code: () -> Void) { } #endif +// FIXME: On FreeBSD, code in this file doesn't compile #if !os(FreeBSD) /// Race tests that need a fresh set of data for every trial should implement /// this protocol. diff --git a/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift b/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift index c2e39d236d07..0f78978e65d0 100644 --- a/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift +++ b/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift @@ -16,6 +16,7 @@ import Darwin import Glibc #endif +// FIXME: On FreeBSD, code in this file doesn't compile #if !os(FreeBSD) // // Implement pthread barriers. diff --git a/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift b/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift index a04a4a1306f3..228808327cfa 100644 --- a/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift +++ b/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift @@ -21,6 +21,7 @@ import Darwin import Glibc #endif +// FIXME: On FreeBSD, code in this file doesn't compile #if !os(FreeBSD) /// An abstract base class to encapsulate the context necessary to invoke /// a block from pthread_create. diff --git a/stdlib/public/Platform/glibc.modulemap.gyb b/stdlib/public/Platform/glibc.modulemap.gyb index fe1bb520a859..29ebec5b9a1f 100644 --- a/stdlib/public/Platform/glibc.modulemap.gyb +++ b/stdlib/public/Platform/glibc.modulemap.gyb @@ -380,6 +380,12 @@ module SwiftGlibc [system] { header "${GLIBC_ARCH_INCLUDE_PATH}/sys/types.h" export * } +% if CMAKE_SDK != "FREEBSD": + module event { + header "${GLIBC_ARCH_INCLUDE_PATH}/sys/event.h" + export * + } +% end module uio { header "${GLIBC_ARCH_INCLUDE_PATH}/sys/uio.h" export * From 7c50ccde5e1d8f4ac08ebaf26a297b2fb4c182df Mon Sep 17 00:00:00 2001 From: K Staring Date: Tue, 20 Sep 2016 03:53:36 +0200 Subject: [PATCH 08/25] fix cut/paste typo 'CMAKE_SDK != "FreeBSD"' to 'CMAKE_SDK in ["FreeBSD"]' (assuming some time more kqueue-supported platforms will want to support Swift) --- stdlib/public/Platform/glibc.modulemap.gyb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/Platform/glibc.modulemap.gyb b/stdlib/public/Platform/glibc.modulemap.gyb index 29ebec5b9a1f..0f7216691c4a 100644 --- a/stdlib/public/Platform/glibc.modulemap.gyb +++ b/stdlib/public/Platform/glibc.modulemap.gyb @@ -380,7 +380,7 @@ module SwiftGlibc [system] { header "${GLIBC_ARCH_INCLUDE_PATH}/sys/types.h" export * } -% if CMAKE_SDK != "FREEBSD": +% if CMAKE_SDK in ["FREEBSD"]: module event { header "${GLIBC_ARCH_INCLUDE_PATH}/sys/event.h" export * From 7edc3100bf6b4de02921d28f099d86f8488c02cb Mon Sep 17 00:00:00 2001 From: K Staring Date: Thu, 22 Sep 2016 20:28:10 +0200 Subject: [PATCH 09/25] fix unbalanced '% if'/'% end', found by gribozavr --- stdlib/public/Platform/glibc.modulemap.gyb | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/public/Platform/glibc.modulemap.gyb b/stdlib/public/Platform/glibc.modulemap.gyb index 0f7216691c4a..fcab6bb91e1c 100644 --- a/stdlib/public/Platform/glibc.modulemap.gyb +++ b/stdlib/public/Platform/glibc.modulemap.gyb @@ -47,6 +47,7 @@ module SwiftGlibc [system] { export * } % end +% end % if CMAKE_SDK in ["LINUX", "ANDROID", "CYGWIN"]: module features { From 47b4c7ee78744cab873a3d8e63a8444a3bd0fe76 Mon Sep 17 00:00:00 2001 From: K Staring Date: Thu, 29 Sep 2016 07:12:15 +0200 Subject: [PATCH 10/25] fixed the pthread compilation errors by following Sangjin Han's advice, see also Han's PR: https://github.com/apple/swift/pull/3886/files#diff-99fd89ad44c4466de8ad6b8aab9c207d --- .../SwiftPrivatePthreadExtras/PthreadBarriers.swift | 8 +++++--- .../SwiftPrivatePthreadExtras.swift | 11 +++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift b/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift index 0f78978e65d0..251aedcbb48c 100644 --- a/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift +++ b/stdlib/private/SwiftPrivatePthreadExtras/PthreadBarriers.swift @@ -16,8 +16,6 @@ import Darwin import Glibc #endif -// FIXME: On FreeBSD, code in this file doesn't compile -#if !os(FreeBSD) // // Implement pthread barriers. // @@ -45,8 +43,13 @@ public var _stdlib_PTHREAD_BARRIER_SERIAL_THREAD: CInt { } public struct _stdlib_pthread_barrier_t { +#if CYGWIN || os(FreeBSD) + var mutex: UnsafeMutablePointer? = nil + var cond: UnsafeMutablePointer? = nil +#else var mutex: UnsafeMutablePointer? = nil var cond: UnsafeMutablePointer? = nil +#endif /// The number of threads to synchronize. var count: CUnsignedInt = 0 @@ -131,4 +134,3 @@ public func _stdlib_pthread_barrier_wait( return _stdlib_PTHREAD_BARRIER_SERIAL_THREAD } } -#endif diff --git a/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift b/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift index 228808327cfa..194912dbcb60 100644 --- a/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift +++ b/stdlib/private/SwiftPrivatePthreadExtras/SwiftPrivatePthreadExtras.swift @@ -21,8 +21,6 @@ import Darwin import Glibc #endif -// FIXME: On FreeBSD, code in this file doesn't compile -#if !os(FreeBSD) /// An abstract base class to encapsulate the context necessary to invoke /// a block from pthread_create. internal class PthreadBlockContext { @@ -61,9 +59,15 @@ internal func invokeBlockContext( return context.run() } +#if CYGWIN || os(FreeBSD) +public typealias _stdlib_pthread_attr_t = UnsafePointer +#else +public typealias _stdlib_pthread_attr_t = UnsafePointer +#endif + /// Block-based wrapper for `pthread_create`. public func _stdlib_pthread_create_block( - _ attr: UnsafePointer?, + _ attr: _stdlib_pthread_attr_t?, _ start_routine: @escaping (Argument) -> Result, _ arg: Argument ) -> (CInt, pthread_t?) { @@ -142,4 +146,3 @@ public class _stdlib_Barrier { } } } -#endif From ede70f251350eb0023fb8869f6f205dffa013af0 Mon Sep 17 00:00:00 2001 From: K Staring Date: Tue, 4 Oct 2016 08:47:26 +0200 Subject: [PATCH 11/25] rolled back FreeBSD /proc changes and rewrote as per @landonf suggestion, through sysctl() call. Kept the function as similar to the other functions as possible. --- stdlib/public/stubs/CommandLine.cpp | 49 +++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/stdlib/public/stubs/CommandLine.cpp b/stdlib/public/stubs/CommandLine.cpp index 2355b87499b0..9d22df779983 100644 --- a/stdlib/public/stubs/CommandLine.cpp +++ b/stdlib/public/stubs/CommandLine.cpp @@ -57,12 +57,7 @@ extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { *outArgLen = *_NSGetArgc(); return *_NSGetArgv(); } -#elif defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD__) -#if defined(__FreeBSD__) -# define PROCFS_CMDLINE_PATH "/proc/curproc/cmdline" -#else -# define PROCFS_CMDLINE_PATH "/proc/self/cmdline" -#endif +#elif defined(__linux__) || defined(__CYGWIN__) SWIFT_RUNTIME_STDLIB_INTERFACE extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { assert(outArgLen != nullptr); @@ -72,12 +67,10 @@ extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { return _swift_stdlib_ProcessOverrideUnsafeArgv; } - FILE *cmdline = fopen(PROCFS_CMDLINE_PATH, "rb"); + FILE *cmdline = fopen("/proc/self/cmdline", "rb"); if (!cmdline) { swift::fatalError(0, - "fatal error: Unable to open interface to '" - PROCFS_CMDLINE_PATH - "'.\n"); + "fatal error: Unable to open interface to '/proc/self/cmdline'.\n"); } char *arg = nullptr; size_t size = 0; @@ -111,6 +104,42 @@ extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { *outArgLen = __argc; return __argv; } +#elif defined(__FreeBSD__) +#include +#include +#include +#include +#include + +SWIFT_RUNTIME_STDLIB_INTERFACE +extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { + assert(outArgLen != nullptr); + + if (_swift_stdlib_ProcessOverrideUnsafeArgv) { + *outArgLen = _swift_stdlib_ProcessOverrideUnsafeArgc; + return _swift_stdlib_ProcessOverrideUnsafeArgv; + } + + char argPtr[8192]; // or use ARG_MAX? 8192 is used in LLDB though.. + size_t argPtrSize = sizeof(argPtr); + int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ARGS, getpid() }; + if (sysctl(mib, 4, argPtr, &argPtrSize, NULL, 0) != 0) + swift::fatalError(0, "fatal error: could not retrieve commandline " + "arguments: sysctl: %s.\n", strerror(errno)); + + char *curPtr = argPtr; + char *endPtr = argPtr + argPtrSize; + + std::vector argvec; + for (; curPtr < endPtr; curPtr += strlen(curPtr) + 1) + argvec.push_back(strdup(curPtr)); + *outArgLen = argvec.size(); + char **outBuf = (char **)calloc(argvec.size() + 1, sizeof(char *)); + std::copy(argvec.begin(), argvec.end(), outBuf); + outBuf[argvec.size()] = nullptr; + + return outBuf; +} #else // __ANDROID__; Add your favorite arch's command line arg grabber here. SWIFT_RUNTIME_STDLIB_INTERFACE extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { From 07166c0008a104d7e8099c0554b4526d934d89e2 Mon Sep 17 00:00:00 2001 From: K Staring Date: Fri, 21 Oct 2016 22:19:54 +0200 Subject: [PATCH 12/25] revert outcommented code-- the code was outcommented due to the pthread wrappers not compiling, but the wrappers compile now thanks to @tinysun212's suggestions --- stdlib/private/StdlibUnittest/RaceTest.swift | 4 ---- 1 file changed, 4 deletions(-) diff --git a/stdlib/private/StdlibUnittest/RaceTest.swift b/stdlib/private/StdlibUnittest/RaceTest.swift index ba7593e74904..f32a48e490ff 100644 --- a/stdlib/private/StdlibUnittest/RaceTest.swift +++ b/stdlib/private/StdlibUnittest/RaceTest.swift @@ -55,8 +55,6 @@ func autoreleasepool(invoking code: () -> Void) { } #endif -// FIXME: On FreeBSD, code in this file doesn't compile -#if !os(FreeBSD) /// Race tests that need a fresh set of data for every trial should implement /// this protocol. /// @@ -722,5 +720,3 @@ public func runRaceTest( runRaceTest(ClosureBasedRaceTest.self, operations: operations, timeoutInSeconds: timeoutInSeconds, threads: threads) } - -#endif From 419c832cb3a675fb29c3426c9e39218ddb161db1 Mon Sep 17 00:00:00 2001 From: K Staring Date: Fri, 21 Oct 2016 22:21:31 +0200 Subject: [PATCH 13/25] default ld.gold on FreeBSD for as long as the ld linker problem exists on {linux,freebsd} --- cmake/modules/AddSwift.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake index 7e840b774a58..3d2c04ff4ce7 100644 --- a/cmake/modules/AddSwift.cmake +++ b/cmake/modules/AddSwift.cmake @@ -984,6 +984,9 @@ function(_add_swift_library_single target name) "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "ELF") list(APPEND link_flags "-fuse-ld=gold") endif() + if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "FREEBSD") + list(APPEND link_flags "-fuse-ld=gold") + endif() if(SWIFT_ENABLE_LLD_LINKER OR ("${SWIFTLIB_SINGLE_SDK}" STREQUAL "WINDOWS" AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WINDOWS")) From db8878e3e81c795106e9c17a025589d10d143989 Mon Sep 17 00:00:00 2001 From: K Staring Date: Fri, 21 Oct 2016 22:23:44 +0200 Subject: [PATCH 14/25] incoorporate @landonf and @dcci's suggestions wrt dynamic sysct KERN_PROC_ARGS buffer --- stdlib/public/stubs/CommandLine.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/stdlib/public/stubs/CommandLine.cpp b/stdlib/public/stubs/CommandLine.cpp index 9d22df779983..b83e21902f0c 100644 --- a/stdlib/public/stubs/CommandLine.cpp +++ b/stdlib/public/stubs/CommandLine.cpp @@ -120,10 +120,23 @@ extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { return _swift_stdlib_ProcessOverrideUnsafeArgv; } - char argPtr[8192]; // or use ARG_MAX? 8192 is used in LLDB though.. - size_t argPtrSize = sizeof(argPtr); + char *argPtr = NULL; // or use ARG_MAX? 8192 is used in LLDB though.. int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ARGS, getpid() }; - if (sysctl(mib, 4, argPtr, &argPtrSize, NULL, 0) != 0) + size_t argPtrSize = 0; + for (int i = 0; i < 3 && !argPtr; i++) { // give up after 3 tries + if (sysctl(mib, 4, NULL, &argPtrSize, NULL, 0) != -1) { + argPtr = (char *)malloc(argPtrSize); + if (sysctl(mib, 4, argPtr, &argPtrSize, NULL, 0) == -1) { + free(argPtr); + argPtr = NULL; + if (errno != ENOMEM) + break; + } + } else { + break; + } + } + if (!argPtr) swift::fatalError(0, "fatal error: could not retrieve commandline " "arguments: sysctl: %s.\n", strerror(errno)); @@ -137,6 +150,8 @@ extern "C" char ** _swift_stdlib_getUnsafeArgvArgc(int *outArgLen) { char **outBuf = (char **)calloc(argvec.size() + 1, sizeof(char *)); std::copy(argvec.begin(), argvec.end(), outBuf); outBuf[argvec.size()] = nullptr; + + free(argPtr); return outBuf; } From 22c0b4a9c82444aa758bb27f081153c7e74fb21a Mon Sep 17 00:00:00 2001 From: K Staring Date: Fri, 21 Oct 2016 22:25:19 +0200 Subject: [PATCH 15/25] fix ICU include paths. Please check this commit and verify that the previous solution simply coudn't have worked *at all*. The usage of slightly differently named variables (e.g. *LIB vs *LIBS) and lower-case module in the include for loop while a TOUPPER variable should have been used, caused the INCLUDE variables to never be filled. Apart from that, a find_package() was missing in the stubs CMakeFiles.txt . --- cmake/modules/FindICU.cmake | 37 +++++++++++++++--------------- stdlib/public/stubs/CMakeLists.txt | 3 +++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/cmake/modules/FindICU.cmake b/cmake/modules/FindICU.cmake index d2d85b525435..e5266af6e35f 100644 --- a/cmake/modules/FindICU.cmake +++ b/cmake/modules/FindICU.cmake @@ -5,33 +5,34 @@ include(FindPackageHandleStandardArgs) find_package(PkgConfig) set(ICU_REQUIRED) -foreach(MODULE ${ICU_FIND_COMPONENTS}) - string(TOUPPER "${MODULE}" MODULE) - string(TOLOWER "${MODULE}" module) +foreach(FIND_COMP_ITEM ${ICU_FIND_COMPONENTS}) + string(TOUPPER "${FIND_COMP_ITEM}" UMODULE) + string(TOLOWER "${FIND_COMP_ITEM}" LMODULE) list(APPEND ICU_REQUIRED - ICU_${MODULE}_INCLUDE_DIR ICU_${MODULE}_LIBRARIES) + ICU_${UMODULE}_INCLUDE_DIR ICU_${UMODULE}_LIBRARIES) - pkg_check_modules(PC_ICU_${MODULE} QUIET icu-${module}) - if(${PC_ICU_${MODULE}_FOUND}) - set(ICU_${MODULE}_DEFINITIONS ${PC_ICU_${MODULE}_CFLAGS_OTHER}) + pkg_check_modules(PC_ICU_${UMODULE} QUIET icu-${LMODULE}) + if(${PC_ICU_${UMODULE}_FOUND}) + set(ICU_${UMODULE}_DEFINITIONS ${PC_ICU_${UMODULE}_CFLAGS_OTHER}) - find_path(ICU_${MODULE}_INCLUDE_DIR unicode - HINTS ${PC_ICU_${MODULE}_INCLUDEDIR} ${PC_ICU_${MODULE}_INCLUDE_DIRS}) - set(ICU_${MODULE}_INCLUDE_DIR ${ICU_${MODULE}_INCLUDE_DIR}) + find_path(ICU_${UMODULE}_INCLUDE_DIR unicode + HINTS ${PC_ICU_${UMODULE}_INCLUDEDIR} ${PC_ICU_${UMODULE}_INCLUDE_DIRS}) + set(ICU_${UMODULE}_INCLUDE_DIRS ${ICU_${UMODULE}_INCLUDE_DIR}) - find_library(ICU_${MODULE}_LIBRARY NAMES icu${module} - HINTS ${PC_ICU_${MODULE}_LIBDIR} ${PC_ICU_${MODULE}_LIBRARY_DIRS}) - set(ICU_${MODULE}_LIBRARIES ${ICU_${MODULE}_LIBRARY}) + find_library(ICU_${UMODULE}_LIBRARY NAMES icu${LMODULE} + HINTS ${PC_ICU_${UMODULE}_LIBDIR} ${PC_ICU_${UMODULE}_LIBRARY_DIRS}) + set(ICU_${UMODULE}_LIBRARIES ${ICU_${UMODULE}_LIBRARY}) endif() endforeach() foreach(sdk ANDROID;FREEBSD;LINUX;WINDOWS) - foreach(MODULE ${ICU_FIND_COMPONENTS}) - if("${SWIFT_${sdk}_ICU_${MODULE}_INCLUDE}" STREQUAL "") - set(SWIFT_${sdk}_ICU_${MODULE}_INCLUDE ${ICU_${MODULE}_INCLUDE_DIRS}) + foreach(ITEM ${ICU_FIND_COMPONENTS}) + string(TOUPPER "${ITEM}" UMODULE) + if("${SWIFT_${sdk}_ICU_${UMODULE}_INCLUDE}" STREQUAL "") + set(SWIFT_${sdk}_ICU_${UMODULE}_INCLUDE ${ICU_${UMODULE}_INCLUDE_DIRS}) endif() - if("${SWIFT_${sdk}_ICU_${MODULE}}" STREQUAL "") - set(SWIFT_${sdk}_ICU_${MODULE} ${ICU_${MODULE}_LIBRARY}) + if("${SWIFT_${sdk}_ICU_${UMODULE}}" STREQUAL "") + set(SWIFT_${sdk}_ICU_${UMODULE} ${ICU_${UMODULE}_LIBRARY}) endif() endforeach() endforeach() diff --git a/stdlib/public/stubs/CMakeLists.txt b/stdlib/public/stubs/CMakeLists.txt index 3d021d975d75..14e6066b2d9c 100644 --- a/stdlib/public/stubs/CMakeLists.txt +++ b/stdlib/public/stubs/CMakeLists.txt @@ -18,6 +18,9 @@ set(LLVM_OPTIONAL_SOURCES ${swift_stubs_objc_sources} ${swift_stubs_unicode_normalization_sources}) +find_package(ICU REQUIRED COMPONENTS uc) +set(ICU_UC_LIBRARY "") + set(swift_stubs_c_compile_flags ${SWIFT_RUNTIME_CORE_CXX_FLAGS}) list(APPEND swift_stubs_c_compile_flags -DswiftCore_EXPORTS) From fb70a1bfad13049a7bb086491ec39687f2492f93 Mon Sep 17 00:00:00 2001 From: K Staring Date: Sat, 22 Oct 2016 12:00:36 +0200 Subject: [PATCH 16/25] incoorporate @jeremyandrews' suggestion --- stdlib/public/Platform/glibc.modulemap.gyb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/stdlib/public/Platform/glibc.modulemap.gyb b/stdlib/public/Platform/glibc.modulemap.gyb index 8581e51ab442..1461e38ac6cd 100644 --- a/stdlib/public/Platform/glibc.modulemap.gyb +++ b/stdlib/public/Platform/glibc.modulemap.gyb @@ -37,7 +37,8 @@ module SwiftGlibc [system] { header "${GLIBC_INCLUDE_PATH}/complex.h" export * } -% if CMAKE_SDK != "FREEBSD": +% end +% if CMAKE_SDK in ["LINUX", "CYGWIN"]: module pty { header "${GLIBC_INCLUDE_PATH}/pty.h" export * @@ -47,6 +48,15 @@ module SwiftGlibc [system] { export * } % end +% if CMAKE_SDK == "FREEBSD": + module pty { + header "${GLIBC_INCLUDE_PATH}/libutil.h" + export * + } + module utmp { + header "${GLIBC_INCLUDE_PATH}/utmpx.h" + export * + } % end % if CMAKE_SDK in ["LINUX", "ANDROID", "CYGWIN"]: From 97d3fbaffbb7545337bf71266051cb73ce7eca07 Mon Sep 17 00:00:00 2001 From: K Staring Date: Mon, 24 Oct 2016 08:23:22 +0200 Subject: [PATCH 17/25] change some variables to make it more clear - when comparing with swift/master - what exactly changed. In short: the first loop used ${MODULE} in uppercase when setting the INCLUDE paths, while the second loop used ${MODULE} in lowercase to retrieve the INCLUDE paths. This can't have worked. Also, there was a discrepancy for the first and second loop where *_INCLUDE_DIR vs *_INCLUDE_DIRS was used. Again, this cannot have worked (just try in the currenct swift/master code, surround the code with some message(STATUS ...) lines) --- cmake/modules/FindICU.cmake | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/cmake/modules/FindICU.cmake b/cmake/modules/FindICU.cmake index e5266af6e35f..9eb2c6940bcb 100644 --- a/cmake/modules/FindICU.cmake +++ b/cmake/modules/FindICU.cmake @@ -5,34 +5,34 @@ include(FindPackageHandleStandardArgs) find_package(PkgConfig) set(ICU_REQUIRED) -foreach(FIND_COMP_ITEM ${ICU_FIND_COMPONENTS}) - string(TOUPPER "${FIND_COMP_ITEM}" UMODULE) - string(TOLOWER "${FIND_COMP_ITEM}" LMODULE) +foreach(MODULE ${ICU_FIND_COMPONENTS}) + string(TOUPPER "${MODULE}" MODULE) + string(TOLOWER "${MODULE}" module) list(APPEND ICU_REQUIRED - ICU_${UMODULE}_INCLUDE_DIR ICU_${UMODULE}_LIBRARIES) + ICU_${MODULE}_INCLUDE_DIR ICU_${MODULE}_LIBRARIES) - pkg_check_modules(PC_ICU_${UMODULE} QUIET icu-${LMODULE}) - if(${PC_ICU_${UMODULE}_FOUND}) - set(ICU_${UMODULE}_DEFINITIONS ${PC_ICU_${UMODULE}_CFLAGS_OTHER}) + pkg_check_modules(PC_ICU_${MODULE} QUIET icu-${module}) + if(${PC_ICU_${MODULE}_FOUND}) + set(ICU_${MODULE}_DEFINITIONS ${PC_ICU_${MODULE}_CFLAGS_OTHER}) - find_path(ICU_${UMODULE}_INCLUDE_DIR unicode - HINTS ${PC_ICU_${UMODULE}_INCLUDEDIR} ${PC_ICU_${UMODULE}_INCLUDE_DIRS}) - set(ICU_${UMODULE}_INCLUDE_DIRS ${ICU_${UMODULE}_INCLUDE_DIR}) + find_path(ICU_${MODULE}_INCLUDE_DIR unicode + HINTS ${PC_ICU_${MODULE}_INCLUDEDIR} ${PC_ICU_${MODULE}_INCLUDE_DIRS}) + set(ICU_${MODULE}_INCLUDE_DIRS ${ICU_${MODULE}_INCLUDE_DIR}) - find_library(ICU_${UMODULE}_LIBRARY NAMES icu${LMODULE} - HINTS ${PC_ICU_${UMODULE}_LIBDIR} ${PC_ICU_${UMODULE}_LIBRARY_DIRS}) - set(ICU_${UMODULE}_LIBRARIES ${ICU_${UMODULE}_LIBRARY}) + find_library(ICU_${MODULE}_LIBRARY NAMES icu${module} + HINTS ${PC_ICU_${MODULE}_LIBDIR} ${PC_ICU_${MODULE}_LIBRARY_DIRS}) + set(ICU_${MODULE}_LIBRARIES ${ICU_${MODULE}_LIBRARY}) endif() endforeach() foreach(sdk ANDROID;FREEBSD;LINUX;WINDOWS) - foreach(ITEM ${ICU_FIND_COMPONENTS}) - string(TOUPPER "${ITEM}" UMODULE) - if("${SWIFT_${sdk}_ICU_${UMODULE}_INCLUDE}" STREQUAL "") - set(SWIFT_${sdk}_ICU_${UMODULE}_INCLUDE ${ICU_${UMODULE}_INCLUDE_DIRS}) + foreach(MODULE ${ICU_FIND_COMPONENTS}) + string(TOUPPER "${MODULE}" MODULE) + if("${SWIFT_${sdk}_ICU_${MODULE}_INCLUDE}" STREQUAL "") + set(SWIFT_${sdk}_ICU_${MODULE}_INCLUDE ${ICU_${MODULE}_INCLUDE_DIRS}) endif() - if("${SWIFT_${sdk}_ICU_${UMODULE}}" STREQUAL "") - set(SWIFT_${sdk}_ICU_${UMODULE} ${ICU_${UMODULE}_LIBRARY}) + if("${SWIFT_${sdk}_ICU_${MODULE}}" STREQUAL "") + set(SWIFT_${sdk}_ICU_${MODULE} ${ICU_${MODULE}_LIBRARY}) endif() endforeach() endforeach() From 5384630a188e67a9e980b074c0391b87f1787c9a Mon Sep 17 00:00:00 2001 From: K Staring Date: Tue, 25 Oct 2016 20:42:17 +0200 Subject: [PATCH 18/25] don't require ICU on Darwin as per jrose-apple's comment --- stdlib/public/stubs/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stdlib/public/stubs/CMakeLists.txt b/stdlib/public/stubs/CMakeLists.txt index 14e6066b2d9c..85d524711b2e 100644 --- a/stdlib/public/stubs/CMakeLists.txt +++ b/stdlib/public/stubs/CMakeLists.txt @@ -18,8 +18,10 @@ set(LLVM_OPTIONAL_SOURCES ${swift_stubs_objc_sources} ${swift_stubs_unicode_normalization_sources}) -find_package(ICU REQUIRED COMPONENTS uc) -set(ICU_UC_LIBRARY "") +if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") + find_package(ICU REQUIRED COMPONENTS uc) + set(ICU_UC_LIBRARY "") +endif() set(swift_stubs_c_compile_flags ${SWIFT_RUNTIME_CORE_CXX_FLAGS}) list(APPEND swift_stubs_c_compile_flags -DswiftCore_EXPORTS) From 6613f07fc58dc267ff6fd3152ac7424dbfc4ed7f Mon Sep 17 00:00:00 2001 From: K Staring Date: Tue, 25 Oct 2016 20:46:56 +0200 Subject: [PATCH 19/25] Update RaceTest.swift From 197b64ff70c4625c9321efd92336a57050c05bdc Mon Sep 17 00:00:00 2001 From: K Staring Date: Tue, 25 Oct 2016 21:09:30 +0200 Subject: [PATCH 20/25] re-instate newline? --- stdlib/private/StdlibUnittest/RaceTest.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/private/StdlibUnittest/RaceTest.swift b/stdlib/private/StdlibUnittest/RaceTest.swift index f32a48e490ff..cbddee12f91b 100644 --- a/stdlib/private/StdlibUnittest/RaceTest.swift +++ b/stdlib/private/StdlibUnittest/RaceTest.swift @@ -720,3 +720,4 @@ public func runRaceTest( runRaceTest(ClosureBasedRaceTest.self, operations: operations, timeoutInSeconds: timeoutInSeconds, threads: threads) } + From 134bd2e96228e40f67b4537710acda8beed68b68 Mon Sep 17 00:00:00 2001 From: K Staring Date: Tue, 25 Oct 2016 22:07:49 +0200 Subject: [PATCH 21/25] don't hard-force ld.gold as per @jrose-apple 's suggestion --- cmake/modules/AddSwift.cmake | 3 --- utils/build-script-impl | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake index 9120b76f20ba..1ae52c051f12 100644 --- a/cmake/modules/AddSwift.cmake +++ b/cmake/modules/AddSwift.cmake @@ -981,9 +981,6 @@ function(_add_swift_library_single target name) "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "ELF") list(APPEND link_flags "-fuse-ld=gold") endif() - if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "FREEBSD") - list(APPEND link_flags "-fuse-ld=gold") - endif() if(SWIFT_ENABLE_LLD_LINKER OR ("${SWIFTLIB_SINGLE_SDK}" STREQUAL "WINDOWS" AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WINDOWS")) diff --git a/utils/build-script-impl b/utils/build-script-impl index 92408e9bd22d..b3bd55478892 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -407,6 +407,7 @@ function set_build_options_for_host() { SWIFT_HOST_VARIANT="freebsd" SWIFT_HOST_VARIANT_SDK="FREEBSD" SWIFT_HOST_VARIANT_ARCH="x86_64" + USE_GOLD_LINKER=1 ;; cygwin-x86_64) SWIFT_HOST_VARIANT="windows" From 0039860e22721e2d4d4d89255e7836b10cbfb46c Mon Sep 17 00:00:00 2001 From: K Staring Date: Thu, 17 Nov 2016 21:00:38 +0100 Subject: [PATCH 22/25] add cast to convey to the compiler which overload to use --- lib/IRGen/IRGenDebugInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index d6d04500477e..a19f2713a606 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -1480,7 +1480,7 @@ llvm::DIType *IRGenDebugInfo::createType(DebugTypeInfo DbgTy, // Use "__ObjC" as default for implicit decls. // FIXME: Do something more clever based on the decl's mangled name. StringRef ModulePath; - StringRef ModuleName = "__ObjC"; + StringRef ModuleName;// = "__ObjC"; if (auto *OwningModule = ClangDecl->getImportedOwningModule()) ModuleName = OwningModule->getTopLevelModuleName(); @@ -1488,7 +1488,7 @@ llvm::DIType *IRGenDebugInfo::createType(DebugTypeInfo DbgTy, if (auto *ClangModule = SwiftModule->findUnderlyingClangModule()) { // FIXME: Clang submodules are not handled here. // FIXME: Clang module config macros are not handled here. - ModuleName = ClangModule->getFullModuleName(); + ModuleName = (StringRef)ClangModule->getFullModuleName(); // FIXME: A clang module's Directory is supposed to be the // directory containing the module map, but ClangImporter // sets it to the module cache directory. From 5462fb235d3ecb9c7520b5b06a53a0c4c16ba570 Mon Sep 17 00:00:00 2001 From: K Staring Date: Thu, 17 Nov 2016 21:08:44 +0100 Subject: [PATCH 23/25] different solution for detecting icu (not needed on Darwin, required on other platforms) --- stdlib/public/stubs/CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/stdlib/public/stubs/CMakeLists.txt b/stdlib/public/stubs/CMakeLists.txt index 85d524711b2e..0044c44be58c 100644 --- a/stdlib/public/stubs/CMakeLists.txt +++ b/stdlib/public/stubs/CMakeLists.txt @@ -18,11 +18,18 @@ set(LLVM_OPTIONAL_SOURCES ${swift_stubs_objc_sources} ${swift_stubs_unicode_normalization_sources}) -if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") - find_package(ICU REQUIRED COMPONENTS uc) - set(ICU_UC_LIBRARY "") +# ICU isn't required on Darwin, but is on every other platform. +# Now in case we're cross-compiling from Darwin for another platform, +# the find_package should still be executed. +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(icu_required, "REQUIRED") +else() + set(icu_required, "") endif() +find_package(ICU ${icu_required} COMPONENTS uc) +set(ICU_UC_LIBRARY "") + set(swift_stubs_c_compile_flags ${SWIFT_RUNTIME_CORE_CXX_FLAGS}) list(APPEND swift_stubs_c_compile_flags -DswiftCore_EXPORTS) From 9c53bb2a7f10ca38dbcdb057c81f2b7d32c6170e Mon Sep 17 00:00:00 2001 From: K Staring Date: Thu, 17 Nov 2016 21:22:27 +0100 Subject: [PATCH 24/25] fix stupid outcomment which shouldn't have been committed :-/ --- lib/IRGen/IRGenDebugInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/IRGen/IRGenDebugInfo.cpp b/lib/IRGen/IRGenDebugInfo.cpp index d4eeca9e8974..505289c8e620 100644 --- a/lib/IRGen/IRGenDebugInfo.cpp +++ b/lib/IRGen/IRGenDebugInfo.cpp @@ -1481,7 +1481,7 @@ llvm::DIType *IRGenDebugInfo::createType(DebugTypeInfo DbgTy, // FIXME: Do something more clever based on the decl's mangled name. std::string FullModuleNameBuffer; StringRef ModulePath; - StringRef ModuleName;// = "__ObjC"; + StringRef ModuleName = "__ObjC"; if (auto *OwningModule = ClangDecl->getImportedOwningModule()) ModuleName = OwningModule->getTopLevelModuleName(); From cd52ed65c9bff95992b18422cbbd430f272f1ab4 Mon Sep 17 00:00:00 2001 From: K Staring Date: Wed, 14 Dec 2016 00:10:22 +0100 Subject: [PATCH 25/25] fix erroneous logic pointed and commas out by @jrose-apple and @llvm-beanz --- stdlib/public/stubs/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/public/stubs/CMakeLists.txt b/stdlib/public/stubs/CMakeLists.txt index 0044c44be58c..0c6f47c91378 100644 --- a/stdlib/public/stubs/CMakeLists.txt +++ b/stdlib/public/stubs/CMakeLists.txt @@ -22,9 +22,9 @@ set(LLVM_OPTIONAL_SOURCES # Now in case we're cross-compiling from Darwin for another platform, # the find_package should still be executed. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - set(icu_required, "REQUIRED") + set(icu_required "") else() - set(icu_required, "") + set(icu_required "REQUIRED") endif() find_package(ICU ${icu_required} COMPONENTS uc)