Skip to content

Merge darwin/libdispatch-1121 to master #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 174 commits into from

Conversation

ktopley-apple
Copy link
Contributor

Merge tag darwin/libdispatch-1121 on darwin/trunk. This includes the latest Apple source drop libdispatch-1121 (up from 913.1.4), on top of tag darwin/darwin-012 which is the result of pulling into the Apple repository the PRs since the merge of darwin/libdispatch-913.1.4 (PR #289).

das and others added 30 commits December 6, 2018 14:39
CMake: carry over some nuances from autotools test config

Signed-off-by: Daniel A. Steffen <[email protected]>
1. add a CMake module to define additional warning flags to enable
   when compiling dispatch.

2. enable the additional warning flags by default for CMake

3. match autotools behavior of not including the BSD_OVERLAY
   when compiling the dispatch_c99 test case. This avoids
   a warning about __printflike being redefined when compiling
   this test case with the expanded set of warning flags.

Signed-off-by: Daniel A. Steffen <[email protected]>
Enable additional compiler warnings for CMake build

Signed-off-by: Daniel A. Steffen <[email protected]>
Signed-off-by: Daniel A. Steffen <[email protected]>
Signed-off-by: Daniel A. Steffen <[email protected]>
Signed-off-by: Daniel A. Steffen <[email protected]>
Signed-off-by: Daniel A. Steffen <[email protected]>
…ge-master

Merge darwin/libdispatch-913.1.4 to master

Signed-off-by: Daniel A. Steffen <[email protected]>
Add support to configure the build to use sanitizers to aid in finding
issues.  The `DISPATCH_USE_SANIZITERS` is a cmake option that defaults
to none, but can be one of `Address, Memory, MemoryWithOrigins,
Undefined, Leaks, Address;Undefined`.  This allows for easily building
libdispatch and the tests with the sanitizers.

Signed-off-by: Daniel A. Steffen <[email protected]>
build: add support to build with sanitization

Signed-off-by: Daniel A. Steffen <[email protected]>
Newer versions of glibc indicate that they intend to move the major
macro from sys/types.h to sys/sysmacros.h. Add a check for the header
and include that earlier to ensure that the macro is provided by the
newer header when available/possible. This avoids an unnecessary warning
from the system headers.

Because `config_ac.h` is not available at the right location, we cannot
include the header to check whether the header is available.  Rely on
the compiler provided `__has_include` instead of the configure check.
Adjust the inclusion of `sys/cdefs.h` accordingly.

Signed-off-by: Daniel A. Steffen <[email protected]>
linux: update header used for `major` macro

Signed-off-by: Daniel A. Steffen <[email protected]>
Fix building on armv6

Signed-off-by: Daniel A. Steffen <[email protected]>
This fixes issues around resuming or re-registering file-descriptors with
a previously triggered EPOLLONESHOT event.

Signed-off-by: Pierre Habouzit <[email protected]>
Fixes: SR-5759
Signed-off-by: Daniel A. Steffen <[email protected]>
Track armed events in muxnotes closely

Signed-off-by: Daniel A. Steffen <[email protected]>
It is possible for _dispatch_muxnote_create to return NULL, this error
condition was not being handled in dispatch_unote_register leading to
an immediate SIGSEGV when it happened.

Signed-off-by: Daniel A. Steffen <[email protected]>
SR-4677: avoid SIGSEGV if _dispatch_muxnote_create returns NULL

Signed-off-by: Daniel A. Steffen <[email protected]>
This adjusts the symlink creation so that it always occurs.  This also
allows us to ensure that we wire up the dependency for the swift module
to the symlink creation.  The CMake based build would fail without this
when trying to build dispatch for SourceKit on Linux.

Signed-off-by: Daniel A. Steffen <[email protected]>
build: fix symlink creation

Signed-off-by: Daniel A. Steffen <[email protected]>
rdar://problem/34132958

Signed-off-by: Daniel A. Steffen <[email protected]>
Synchronize the Linux and Darwin overlay versions of Time.swift

Signed-off-by: Daniel A. Steffen <[email protected]>
…val.

rdar://problem/34440944

Signed-off-by: Daniel A. Steffen <[email protected]>
Fix overflow traps in DispatchTime/DispatchWallTime/DispatchTimeInterval

Signed-off-by: Daniel A. Steffen <[email protected]>
Changes for SR-5759 introduced a bug where disarmed events got dropped when
a muxnote is reused, due to erroneously setting dmn->dmn_events to the
combination of new events and currently armed events.

Combining existing events with the combination of new events and armed events
implements the intended behavior.

Signed-off-by: Daniel A. Steffen <[email protected]>
Properly pick up new events when reusing a muxnote

Signed-off-by: Daniel A. Steffen <[email protected]>
Update the documentation to reference the CMake build infrastructure
rather than autotools for the non-Darwin targets.  Once the Darwin build
is switched over, the entire build process can be described in a single
block.

Signed-off-by: Daniel A. Steffen <[email protected]>
docs: update documentation to show how to use CMake

Signed-off-by: Daniel A. Steffen <[email protected]>
Most targets use unsigned chars.  Explicitly change the static tables to
`signed char`.  An alternative  would be to force signed chars during
the compilation of libdispatch.  When building for Linux AArch64, the
use of `-1` causes signed conversion warnings when initializing the
table.

Signed-off-by: Daniel A. Steffen <[email protected]>
Attempt to be better with signed conversions

Signed-off-by: Daniel A. Steffen <[email protected]>
adierking and others added 23 commits December 6, 2018 14:51
There's a quirk on Windows where exiting the process will still run fiber-local
storage destructors for the thread that called ExitProcess() (but only for that
thread). pthreads-based platforms don't call any key destructors on exit, and
_libdispatch_tsd_cleanup() assumes this. So, on Windows, calling exit() from a
queue thread will trigger the fatal error in _dispatch_frame_cleanup().

Implement a reliable method of detecting whether the process is exiting, and if
it is, ignore calls to _libdispatch_tsd_cleanup().

Signed-off-by: Kim Topley <[email protected]>
Ignore Windows FLS destructors during process exit

Signed-off-by: Kim Topley <[email protected]>
…of Data.enumerateBytes() for Swift 4.2 and obsolete the old version.

rdar://problem/40775762
Signed-off-by: Kim Topley <[email protected]>
Change the signature for DispatchData.enumerateBytes() to match that …

Signed-off-by: Kim Topley <[email protected]>
rdar://problem/40951342
Signed-off-by: Kim Topley <[email protected]>
Add documentation comments.

Signed-off-by: Kim Topley <[email protected]>
CMakeLists.txt checks for librt's presence but the result is never used. This
causes a link failure on systems where clock_gettime() is provided by librt.

Signed-off-by: Kim Topley <[email protected]>
build: link against librt if it's available
Signed-off-by: Kim Topley <[email protected]>
generic_unix_stubs.c seems to no longer be necessary. generic_unix_stubs.h still
had some required definitions in it, so move those into shims.h and a new
shims/mach.h. This also lets us remove some duplicated definitions in the
Windows shims.

Signed-off-by: Kim Topley <[email protected]>
Remove generic_unix_stubs

Signed-off-by: Kim Topley <[email protected]>
When building debug, swift requires a supplementary library.  The swift driver
is aware of this and will make the appropriate arrangements.  However, since the
swift component is compacted into the C library, the linker driver being used
does not understand this requirement.  Explicitly link against the support
library.  This allows building the debug configuration of libdispatch with a
release configuration of the swift standard library.

Signed-off-by: Kim Topley <[email protected]>
build: link against swiftOnoneSupport in debug configuration
Signed-off-by: Kim Topley <[email protected]>
Allow libdispatch to be embedded in other CMake projects using
add_subdirectory(). This essentially means that `CMAKE_SOURCE_DIR` and
`CMAKE_BINARY_DIR` cannot be used directly. Use the versions of these variables
which are scoped to the current project or directory.

Signed-off-by: Kim Topley <[email protected]>
build: support embedding in other CMake projects
Signed-off-by: Kim Topley <[email protected]>
This hack was only needed for Swift 3 mode in a narrow case.  Now that
we're dropping Swift 3 from master, the source break this was working
around is no longer relevant.

Signed-off-by: Kim Topley <[email protected]>
Drop @_downgrade_exhaustivity_check attribute

Signed-off-by: Kim Topley <[email protected]>
Remove version number used in 'available' attribute for non-specific platform '*'.

Signed-off-by: Kim Topley <[email protected]>
Fix redundant access-level modifiers.

Signed-off-by: Kim Topley <[email protected]>
Signed-off-by: Kim Topley <[email protected]>
@ktopley-apple
Copy link
Contributor Author

@swift-ci please test

BlocksRuntime_STATIC)
endif()
endif()
STATIC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is bad. I think that we are missing a merge from master. This will remove the shared BlocksRuntime build. We currently are building block static and shared.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking. I will be working on completing this source drop today.

SHARED IMPORTED GLOBAL)
set_target_properties(swiftCore
PROPERTIES
IMPORTED_LOCATION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved to using the exported targets from Swift to avoid computing the path. This is much more fragile and I believe may break the build currently.

@@ -112,8 +152,7 @@ if(ENABLE_INTERNAL_PTHREAD_WORKQUEUES)
set(HAVE_PTHREAD_WORKQUEUES 0)
else()
check_include_files(pthread/workqueue_private.h HAVE_PTHREAD_WORKQUEUE_PRIVATE_H)
check_include_files(pthread_workqueue.h HAVE_PTHREAD_WORKQUEUE_H)
if(HAVE_PTHREAD_WORKQUEUE_PRIVATE_H AND HAVE_PTHREAD_WORKQUEUE_H)
if(HAVE_PTHREAD_WORKQUEUE_PRIVATE_H)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why drop the check here?

COMMAND
${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/private/generic/module.modulemap" "${PROJECT_SOURCE_DIR}/private/module.modulemap")
${CMAKE_COMMAND} -E create_symlink "${PROJECT_SOURCE_DIR}/private/generic/module.modulemap" "${PROJECT_SOURCE_DIR}/private/module.modulemap")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should keep the new behaviour for the module map handling as it exposed some issues with the different ports.

endif()
add_custom_target(module-maps ALL
add_custom_target(module-map-symlinks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to break dependencies as the target name changed.

list(APPEND compile_flags -target;${AST_TARGET})
list(APPEND link_flags -target;${AST_TARGET})
if(ASL_TARGET)
list(APPEND FLAGS -target;${ASL_TARGET})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks the compilation/cross-linking.

COMMAND
${CMAKE_COMMAND} -E make_directory ${module_directory}
COMMAND
${CMAKE_SWIFT_COMPILER} ${flags} -c ${sources} -o ${ASL_OUTPUT})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This increases the compile time significantly and forces a full recompile on every change.

PRIVATE
swift/DispatchStubs.cc
${CMAKE_CURRENT_BINARY_DIR}/swiftDispatch.o)
if(CMAKE_BUILD_TYPE MATCHES Debug)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change to use the swift driver for linking obviated this

if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
target_compile_options(dispatch PRIVATE /EHs-c-)
else()
if(NOT "${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks builds with clang-cl.

add_custom_command(TARGET dispatch POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory .libs
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:dispatch> .libs
COMMENT "Copying libdispatch to .libs")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything has been migrated, this is no longer needed

RUNTIME DESTINATION bin)

DESTINATION
"${INSTALL_TARGET_DIR}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the Windows port

@@ -205,14 +199,16 @@ enum {
DISPATCH_IOCNTL_MAX_PENDING_IO_REQS,
};

static struct dispatch_io_defaults_s {
extern struct dispatch_io_defaults_s {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, don't think that the extern is needed here as the statement is a definition.

@ktopley-apple
Copy link
Contributor Author

This PR is not ready. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.