Commit 9f7192f8 authored by Drew's avatar Drew

Remove libdispatch patches that are no longer necessary

parent 43b7025c
commit 67450cb8247b86071759251bb6371b5056436594
Author: David Grove <groved@us.ibm.com>
Date: Wed Feb 3 23:04:04 2016 +0000
Initial integration of Swift overlay into libdispatch build
This commit adds a src/swift directory that contains
Dispatch.swift and Dispatch.c (based on existing files in
swift/stdlib/public/SDK/Dispatch) and a module.map.in template.
We made some initial changes to Dispatch.swift and Dispatch.c to
adapt them to Linux by dropping MACH API functions/adapters.
The libdispatch build process is extended to include Dispatch.o
in libdispatch.so and to generate Dispatch.swiftmodule,
Dispatch.swiftdoc and a module.map file when configure is
given a --with-swift-toolchain argument.
Swift programs that import Dispatch can be compiled, linked,
and run against the generated files. However, because of
the use of @convention(block) to bridge from Swift blocks to
the -fblocks expected by dispatch, swiftc must be given the
extra command line arguments -Xcc -fblocks
diff --git a/configure.ac b/configure.ac
index 670863f..c5b04ce 100644
--- a/configure.ac
+++ b/configure.ac
@@ -101,6 +101,20 @@ AS_IF([test "x$enable_apple_tsd_optimizations" = "xyes"],
[Define to use non-portable pthread TSD optimizations for Mac OS X)])]
)
+#
+# Enable building Swift overlay support into libdispatch
+#
+AC_ARG_WITH([swift-toolchain],
+ [AS_HELP_STRING([--with-swift-toolchain], [Specify path to Swift toolchain])],
+ [swift_toolchain_path=${withval}
+ AC_DEFINE(HAVE_SWIFT, 1, [Define if building for Swift])
+ SWIFTC="$swift_toolchain_path/bin/swiftc"
+ have_swift=true],
+ [have_swift=false]
+)
+AM_CONDITIONAL(HAVE_SWIFT, $have_swift)
+AC_SUBST([SWIFTC])
+
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([foreign no-dependencies subdir-objects])
LT_INIT([disable-static])
diff --git a/src/.gitignore b/src/.gitignore
index 65f9ee2..194c2cb 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -1,5 +1,9 @@
provider.h
+module.map
+module.build.map
.libs
*.lo
*.la
-
+*.o
+*.swiftmodule
+*.swiftdoc
diff --git a/src/Makefile.am b/src/Makefile.am
index ab1998a..316161e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,6 +46,9 @@ libdispatch_la_SOURCES= \
shims/tsd.h \
shims/yield.h
+EXTRA_libdispatch_la_SOURCES=
+EXTRA_libdispatch_la_DEPENDENCIES=
+
AM_CPPFLAGS=-I$(top_builddir) -I$(top_srcdir) \
-I$(top_srcdir)/private -I$(top_srcdir)/os
@@ -103,8 +106,39 @@ DTRACE_SOURCES=provider.h
$(DTRACE) -h -s $< -o $@
endif
-BUILT_SOURCES=$(MIG_SOURCES) $(DTRACE_SOURCES)
+if HAVE_SWIFT
+libdispatch_la_SOURCES+=swift/swift_wrappers.c
+EXTRA_libdispatch_la_SOURCES+=swift/Dispatch.swift
+EXTRA_libdispatch_la_DEPENDENCIES+=$(abs_builddir)/Dispatch.o $(abs_builddir)/Dispatch.swiftmodule
+libdispatch_la_LIBADD+=$(abs_builddir)/Dispatch.o
+
+SWIFT_MODULEMAPS=$(abs_builddir)/module.map $(abs_builddir)/module.build.map
+SWIFTMODULE_OBJECTS= \
+ $(abs_builddir)/Dispatch.swiftmodule \
+ $(abs_builddir)/Dispatch.swiftdoc \
+ $(abs_builddir)/Dispatch.o
+
+SWIFTC_FLAGS = -I$(abs_top_srcdir) -parse-as-library -Xcc -fblocks -Xcc -fmodule-map-file=module.build.map
+
+$(abs_builddir)/module.build.map: $(abs_srcdir)/swift/module.map.in
+ m4 -DPREFIX=$(abs_top_srcdir) $< > $@
+
+$(abs_builddir)/module.map: $(abs_srcdir)/swift/module.map.in
+ m4 -DPREFIX=$(includedir) $< > $@
+
+$(abs_builddir)/Dispatch.o: $(abs_srcdir)/swift/Dispatch.swift $(abs_builddir)/module.build.map
+ $(SWIFTC) $(SWIFTC_FLAGS) -c -o $@ $<
+
+$(abs_builddir)/Dispatch.swiftmodule: $(abs_srcdir)/swift/Dispatch.swift $(abs_builddir)/module.build.map
+ $(SWIFTC) $(SWIFTC_FLAGS) -emit-module -emit-module-path $@ $<
+
+swiftdir=$(includedir)/Dispatch
+swift_HEADERS=$(abs_builddir)/module.map $(abs_builddir)/Dispatch.swiftmodule $(abs_builddir)/Dispatch.swiftdoc
+
+endif
+
+BUILT_SOURCES=$(MIG_SOURCES) $(DTRACE_SOURCES) $(SWIFT_MODULEMAPS)
nodist_libdispatch_la_SOURCES=$(BUILT_SOURCES)
-CLEANFILES=$(BUILT_SOURCES)
+CLEANFILES=$(BUILT_SOURCES) $(SWIFTMODULE_OBJECTS)
DISTCLEANFILES=pthread_machdep.h pthread System mach objc
diff --git a/src/swift/Dispatch.swift b/src/swift/Dispatch.swift
new file mode 100644
index 0000000..d9d869f
--- /dev/null
+++ b/src/swift/Dispatch.swift
@@ -0,0 +1,168 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See http://swift.org/LICENSE.txt for license information
+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+@_exported import Dispatch
+
+/// The type of blocks submitted to dispatch queues, which take no arguments
+/// and have no return value.
+///
+/// The dispatch_block_t typealias is different from usual closures in that it
+/// uses @convention(block). This is to avoid unnecessary bridging between
+/// C blocks and Swift closures, which interferes with Grand Central Dispatch
+/// APIs that depend on the referential identity of a block.
+public typealias dispatch_block_t = @convention(block) () -> Void
+
+//===----------------------------------------------------------------------===//
+// Macros
+// FIXME: rdar://16851050 update API so these import better
+//===----------------------------------------------------------------------===//
+
+// dispatch/io.h
+public var DISPATCH_IO_STREAM: dispatch_io_type_t {
+ return 0
+}
+public var DISPATCH_IO_RANDOM: dispatch_io_type_t {
+ return 1
+}
+
+public var DISPATCH_IO_STOP: dispatch_io_close_flags_t {
+ return 1
+}
+public var DISPATCH_IO_STRICT_INTERVAL: dispatch_io_interval_flags_t {
+ return 1
+}
+
+public var DISPATCH_QUEUE_SERIAL: dispatch_queue_attr_t {
+ return nil
+}
+public var DISPATCH_CURRENT_QUEUE_LABEL: dispatch_queue_t {
+ return nil
+}
+public var DISPATCH_TARGET_QUEUE_DEFAULT: dispatch_queue_t {
+ return nil
+}
+public var DISPATCH_QUEUE_PRIORITY_HIGH: dispatch_queue_priority_t {
+ return 2
+}
+public var DISPATCH_QUEUE_PRIORITY_DEFAULT: dispatch_queue_priority_t {
+ return 0
+}
+public var DISPATCH_QUEUE_PRIORITY_LOW: dispatch_queue_priority_t {
+ return -2
+}
+public var DISPATCH_QUEUE_PRIORITY_BACKGROUND: dispatch_queue_priority_t {
+ return -32768
+}
+
+/*
+FIXME: LINUX_PORT: qos_class_t not being imported
+@warn_unused_result
+public func dispatch_get_global_queue(identifier: qos_class_t,
+ _ flags: UInt) -> dispatch_queue_t {
+ return dispatch_get_global_queue(Int(identifier.rawValue), flags)
+}
+*/
+
+public var DISPATCH_QUEUE_CONCURRENT: dispatch_queue_attr_t {
+ return _swift_dispatch_queue_concurrent()
+}
+
+@warn_unused_result
+@_silgen_name("_swift_dispatch_queue_concurrent")
+internal func _swift_dispatch_queue_concurrent() -> dispatch_queue_attr_t
+
+// dispatch/data.h
+public var dispatch_data_empty: dispatch_data_t {
+ return _swift_dispatch_data_empty()
+}
+
+@warn_unused_result
+@_silgen_name("_swift_dispatch_data_empty")
+internal func _swift_dispatch_data_empty() -> dispatch_data_t
+
+// dispatch/source.h
+// FIXME: DISPATCH_SOURCE_TYPE_*
+public var DISPATCH_PROC_EXIT: dispatch_source_proc_flags_t {
+ return 0x80000000
+}
+public var DISPATCH_PROC_FORK: dispatch_source_proc_flags_t { return 0x40000000 }
+public var DISPATCH_PROC_EXEC: dispatch_source_proc_flags_t { return 0x20000000 }
+public var DISPATCH_PROC_SIGNAL: dispatch_source_proc_flags_t { return 0x08000000 }
+public var DISPATCH_VNODE_DELETE: dispatch_source_vnode_flags_t { return 0x1 }
+public var DISPATCH_VNODE_WRITE: dispatch_source_vnode_flags_t { return 0x2 }
+public var DISPATCH_VNODE_EXTEND: dispatch_source_vnode_flags_t { return 0x4 }
+public var DISPATCH_VNODE_ATTRIB: dispatch_source_vnode_flags_t { return 0x8 }
+public var DISPATCH_VNODE_LINK: dispatch_source_vnode_flags_t { return 0x10 }
+public var DISPATCH_VNODE_RENAME: dispatch_source_vnode_flags_t { return 0x20 }
+public var DISPATCH_VNODE_REVOKE: dispatch_source_vnode_flags_t { return 0x40 }
+public var DISPATCH_TIMER_STRICT: dispatch_source_timer_flags_t { return 1 }
+
+public var DISPATCH_SOURCE_TYPE_DATA_ADD: dispatch_source_type_t {
+ return _swift_dispatch_source_type_data_add()
+}
+public var DISPATCH_SOURCE_TYPE_DATA_OR: dispatch_source_type_t {
+ return _swift_dispatch_source_type_data_or()
+}
+public var DISPATCH_SOURCE_TYPE_READ: dispatch_source_type_t {
+ return _swift_dispatch_source_type_read()
+}
+public var DISPATCH_SOURCE_TYPE_PROC: dispatch_source_type_t {
+ return _swift_dispatch_source_type_proc()
+}
+public var DISPATCH_SOURCE_TYPE_SIGNAL: dispatch_source_type_t {
+ return _swift_dispatch_source_type_signal()
+}
+public var DISPATCH_SOURCE_TYPE_TIMER: dispatch_source_type_t {
+ return _swift_dispatch_source_type_timer()
+}
+public var DISPATCH_SOURCE_TYPE_VNODE: dispatch_source_type_t {
+ return _swift_dispatch_source_type_vnode()
+}
+public var DISPATCH_SOURCE_TYPE_WRITE: dispatch_source_type_t {
+ return _swift_dispatch_source_type_write()
+}
+
+@warn_unused_result
+@_silgen_name("_swift_dispatch_source_type_DATA_ADD")
+internal func _swift_dispatch_source_type_data_add() -> dispatch_source_type_t
+
+@warn_unused_result
+@_silgen_name("_swift_dispatch_source_type_DATA_OR")
+internal func _swift_dispatch_source_type_data_or() -> dispatch_source_type_t
+
+@warn_unused_result
+@_silgen_name("_swift_dispatch_source_type_PROC")
+internal func _swift_dispatch_source_type_proc() -> dispatch_source_type_t
+
+@warn_unused_result
+@_silgen_name("_swift_dispatch_source_type_READ")
+internal func _swift_dispatch_source_type_read() -> dispatch_source_type_t
+
+@warn_unused_result
+@_silgen_name("_swift_dispatch_source_type_SIGNAL")
+internal func _swift_dispatch_source_type_signal() -> dispatch_source_type_t
+
+@warn_unused_result
+@_silgen_name("_swift_dispatch_source_type_TIMER")
+internal func _swift_dispatch_source_type_timer() -> dispatch_source_type_t
+
+@warn_unused_result
+@_silgen_name("_swift_dispatch_source_type_VNODE")
+internal func _swift_dispatch_source_type_vnode() -> dispatch_source_type_t
+
+@warn_unused_result
+@_silgen_name("_swift_dispatch_source_type_WRITE")
+internal func _swift_dispatch_source_type_write() -> dispatch_source_type_t
+
+// dispatch/time.h
+// DISPATCH_TIME_NOW: ok
+// DISPATCH_TIME_FOREVER: ok
diff --git a/src/swift/module.map.in b/src/swift/module.map.in
new file mode 100644
index 0000000..abaa557
--- /dev/null
+++ b/src/swift/module.map.in
@@ -0,0 +1,7 @@
+module Dispatch [system] {
+ umbrella header "PREFIX/dispatch/dispatch.h"
+ requires blocks
+ export *
+ link "dispatch"
+ link "BlocksRuntime"
+}
diff --git a/src/swift/swift_wrappers.c b/src/swift/swift_wrappers.c
new file mode 100644
index 0000000..3be5303
--- /dev/null
+++ b/src/swift/swift_wrappers.c
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// This source file is part of the Swift.org open source project
+//
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See http://swift.org/LICENSE.txt for license information
+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+//
+//===----------------------------------------------------------------------===//
+
+#include <dispatch/dispatch.h>
+
+DISPATCH_EXPORT
+dispatch_queue_attr_t
+_swift_dispatch_queue_serial(void) {
+ return DISPATCH_QUEUE_SERIAL;
+}
+
+DISPATCH_EXPORT
+dispatch_queue_attr_t
+_swift_dispatch_queue_concurrent(void) {
+ return DISPATCH_QUEUE_CONCURRENT;
+}
+
+DISPATCH_EXPORT
+dispatch_data_t
+_swift_dispatch_data_empty(void) {
+ return dispatch_data_empty;
+}
+
+#define SOURCE(t) \
+ DISPATCH_EXPORT \
+ dispatch_source_type_t \
+ _swift_dispatch_source_type_##t(void) { \
+ return DISPATCH_SOURCE_TYPE_##t; \
+ }
+
+SOURCE(DATA_ADD)
+SOURCE(DATA_OR)
+SOURCE(PROC)
+SOURCE(READ)
+SOURCE(SIGNAL)
+SOURCE(TIMER)
+SOURCE(VNODE)
+SOURCE(WRITE)
From 05d4aa0ba616e7b0c92642dc50df3d65e2d4ba08 Mon Sep 17 00:00:00 2001
From: David Grove <groved@us.ibm.com>
Date: Fri, 5 Feb 2016 19:38:21 +0000
Subject: [PATCH] Next step in connecting libdispatch and foundation builds
Three small changes for building libdispatch and foundation together.
(1) Put libdispatch into PRODUCTS before foundation
(2) Pass path to swift down into libdispatch build
(3) Pass paths to libdispatch down into foundation build
---
utils/build-script-impl | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/utils/build-script-impl b/utils/build-script-impl
index 3e71cbb..e49abfc 100755
--- a/utils/build-script-impl
+++ b/utils/build-script-impl
@@ -926,12 +926,12 @@ fi
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" xctest)
fi
-if [[ ! "${SKIP_BUILD_FOUNDATION}" ]] ; then
- PRODUCTS=("${PRODUCTS[@]}" foundation)
-fi
if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
PRODUCTS=("${PRODUCTS[@]}" libdispatch)
fi
+if [[ ! "${SKIP_BUILD_FOUNDATION}" ]] ; then
+ PRODUCTS=("${PRODUCTS[@]}" foundation)
+fi
SWIFT_STDLIB_TARGETS=()
SWIFT_PERFTEST_TARGETS=()
@@ -1801,6 +1801,12 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
LLVM_BIN="$(build_directory_bin ${deployment_target} llvm)"
NINJA_BIN="ninja"
+ # Staging: require opt-in for building with dispatch
+ if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
+ LIBDISPATCH_BUILD_DIR="$(build_directory ${deployment_target} libdispatch)"
+ LIBDISPATCH_BUILD_ARGS="-DLIBDISPATCH_SOURCE_DIR=${LIBDISPATCH_SOURCE_DIR} -DLIBDISPATCH_BUILD_DIR=${LIBDISPATCH_BUILD_DIR}"
+ fi
+
if [[ "${BUILD_NINJA}" ]]; then
NINJA_BUILD_DIR=$(build_directory build ninja)
NINJA_BIN="${NINJA_BUILD_DIR}/ninja"
@@ -1809,7 +1815,7 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
set -x
pushd "${FOUNDATION_SOURCE_DIR}"
SWIFTC="${SWIFTC_BIN}" CLANG="${LLVM_BIN}"/clang SWIFT="${SWIFT_BIN}" \
- SDKROOT="${SWIFT_BUILD_PATH}" BUILD_DIR="${build_dir}" DSTROOT="${INSTALL_DESTDIR}" PREFIX="${INSTALL_PREFIX}" ./configure "${FOUNDATION_BUILD_TYPE}" -DXCTEST_BUILD_DIR=${XCTEST_BUILD_DIR}
+ SDKROOT="${SWIFT_BUILD_PATH}" BUILD_DIR="${build_dir}" DSTROOT="${INSTALL_DESTDIR}" PREFIX="${INSTALL_PREFIX}" ./configure "${FOUNDATION_BUILD_TYPE}" -DXCTEST_BUILD_DIR=${XCTEST_BUILD_DIR} $LIBDISPATCH_BUILD_ARGS
${NINJA_BIN}
popd
{ set +x; } 2>/dev/null
@@ -1819,6 +1825,7 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
;;
libdispatch)
LIBDISPATCH_BUILD_DIR=$(build_directory ${deployment_target} ${product})
+ SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)"
set -x
if [[ ! -f "${LIBDISPATCH_BUILD_DIR}"/config.status ]]; then
@@ -1828,7 +1835,7 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
autoreconf -fvi
popd
pushd "${LIBDISPATCH_BUILD_DIR}"
- "${LIBDISPATCH_SOURCE_DIR}"/configure --prefix="${INSTALL_DESTDIR}"/"${INSTALL_PREFIX}"
+ "${LIBDISPATCH_SOURCE_DIR}"/configure --prefix="${INSTALL_DESTDIR}"/"${INSTALL_PREFIX}" --with-swift-toolchain="${SWIFT_BUILD_PATH}"
popd
fi
pushd "${LIBDISPATCH_BUILD_DIR}"
--
2.5.4 (Apple Git-61)
......@@ -29,11 +29,11 @@ ADD update-tags.sh /swift-dev/update-tags.sh
RUN bash /swift-dev/update-tags.sh
# Apply patches here
ADD LIBDISPATCH_PR_43.patch /swift-dev/
ADD SWIFT_PR_1212.patch /swift-dev/
# RUN cd ../swift-corelibs-libdispatch && git apply < ../LIBDISPATCH_PR_43.patch
RUN git config --global user.email "drew@sealedabstract.com" && git config --global user.name "Drew Crawford"
RUN git am -3 < ../SWIFT_PR_1212.patch
# ADD SAMPLE.patch /swift-dev/
# RUN cd ../swift-corelibs-libdispatch && git apply < ../SAMPLE.patch
# or for AM
# RUN git config --global user.email "drew@sealedabstract.com" && git config --global user.name "Drew Crawford"
# RUN git am -3 < ../SAMPLE.patch
# And now we build, like a good little linuxen.
# I believe this is what the linux build script does. In practice, this builds a system into /tmp/install and then tars it up.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment