Skip to content

Backport build and Windows fixes for 5.9 #794

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

Merged
merged 6 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ config
configure
libtool
.dirstamp
/dispatch/module.modulemap
/private/module.modulemap
22 changes: 4 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,26 +261,12 @@ endif()


if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
add_custom_command(OUTPUT
"${PROJECT_SOURCE_DIR}/dispatch/module.modulemap"
"${PROJECT_SOURCE_DIR}/private/module.modulemap"
COMMAND
${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/dispatch/darwin/module.modulemap" "${PROJECT_SOURCE_DIR}/dispatch/module.modulemap"
COMMAND
${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/private/darwin/module.modulemap" "${PROJECT_SOURCE_DIR}/private/module.modulemap")
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-fmodule-map-file=${PROJECT_SOURCE_DIR}/dispatch/darwin/module.modulemap>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-fmodule-map-file=${PROJECT_SOURCE_DIR}/private/darwin/module.modulemap>)
else()
add_custom_command(OUTPUT
"${PROJECT_SOURCE_DIR}/dispatch/module.modulemap"
"${PROJECT_SOURCE_DIR}/private/module.modulemap"
COMMAND
${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/dispatch/generic/module.modulemap" "${PROJECT_SOURCE_DIR}/dispatch/module.modulemap"
COMMAND
${CMAKE_COMMAND} -E copy_if_different "${PROJECT_SOURCE_DIR}/private/generic/module.modulemap" "${PROJECT_SOURCE_DIR}/private/module.modulemap")
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-fmodule-map-file=${PROJECT_SOURCE_DIR}/dispatch/generic/module.modulemap>
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-fmodule-map-file=${PROJECT_SOURCE_DIR}/private/generic/module.modulemap>)
endif()
add_custom_target(module-maps ALL
DEPENDS
"${PROJECT_SOURCE_DIR}/dispatch/module.modulemap"
"${PROJECT_SOURCE_DIR}/private/module.modulemap")

configure_file("${PROJECT_SOURCE_DIR}/cmake/config.h.in"
"${PROJECT_BINARY_DIR}/config/config_ac.h")
Expand Down
24 changes: 12 additions & 12 deletions dispatch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@

if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(DISPATCH_MODULE_MAP ${PROJECT_SOURCE_DIR}/dispatch/darwin/module.modulemap)
elseif(BUILD_SHARED_LIBS)
set(DISPATCH_MODULE_MAP ${PROJECT_SOURCE_DIR}/dispatch/generic/module.modulemap)
else()
set(DISPATCH_MODULE_MAP ${PROJECT_SOURCE_DIR}/dispatch/generic_static/module.modulemap)
endif()
configure_file(dispatch-vfs.yaml.in
${CMAKE_BINARY_DIR}/dispatch-vfs-overlay.yaml
@ONLY)

install(FILES
base.h
block.h
Expand All @@ -16,19 +27,8 @@ install(FILES
DESTINATION
"${INSTALL_DISPATCH_HEADERS_DIR}")
if(ENABLE_SWIFT)
set(base_dir "${CMAKE_CURRENT_SOURCE_DIR}")
if(NOT BUILD_SHARED_LIBS)
set(base_dir "${CMAKE_CURRENT_SOURCE_DIR}/generic_static")
endif()

get_filename_component(
MODULE_MAP
module.modulemap
REALPATH
BASE_DIR "${base_dir}")

install(FILES
${MODULE_MAP}
${DISPATCH_MODULE_MAP}
DESTINATION
"${INSTALL_DISPATCH_HEADERS_DIR}")
endif()
Expand Down
11 changes: 11 additions & 0 deletions dispatch/dispatch-vfs.yaml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: 0
case-sensitive: false
use-external-names: false
roots:
- name: "@CMAKE_CURRENT_SOURCE_DIR@"
type: directory
contents:
- name: module.modulemap
type: file
external-contents: "@DISPATCH_MODULE_MAP@"
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ target_link_libraries(dispatch PUBLIC
BlocksRuntime::BlocksRuntime)
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
target_link_libraries(dispatch PRIVATE
AdvAPI32
ShLwApi
WS2_32
WinMM
Expand Down
1 change: 1 addition & 0 deletions src/shims/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ void _dispatch_sema4_init(_dispatch_sema4_t *sema, int policy DISPATCH_UNUSED)

// lazily allocate the semaphore port

os_atomic_cmpxchg(sema, *sema, 0, relaxed);
while (!dispatch_assume(tmp = CreateSemaphore(NULL, 0, LONG_MAX, NULL))) {
_dispatch_temporary_resource_shortage();
}
Expand Down
3 changes: 2 additions & 1 deletion src/swift/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ target_compile_options(swiftDispatch PRIVATE
"SHELL:-Xcc -fmodule-map-file=${PROJECT_SOURCE_DIR}/dispatch/module.modulemap"
"SHELL:-Xcc -I${PROJECT_SOURCE_DIR}"
"SHELL:-Xcc -I${PROJECT_SOURCE_DIR}/src/swift/shims")
target_compile_options(swiftDispatch PUBLIC
"SHELL:-vfsoverlay ${CMAKE_BINARY_DIR}/dispatch-vfs-overlay.yaml")
set_target_properties(swiftDispatch PROPERTIES
Swift_MODULE_NAME Dispatch
Swift_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/swift
Expand All @@ -42,7 +44,6 @@ target_link_libraries(swiftDispatch PRIVATE
BlocksRuntime::BlocksRuntime)
target_link_libraries(swiftDispatch PUBLIC
dispatch)
add_dependencies(swiftDispatch module-maps)

get_swift_host_arch(swift_arch)
install(FILES
Expand Down
2 changes: 1 addition & 1 deletion tests/generic_win_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ gettimeofday(struct timeval *tp, void *tzp)
typedef void (WINAPI *QueryUnbiasedInterruptTimePreciseT)(PULONGLONG);
static QueryUnbiasedInterruptTimePreciseT QueryUnbiasedInterruptTimePrecisePtr;

static BOOL
static BOOL WINAPI
mach_absolute_time_init(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContext)
{
// QueryUnbiasedInterruptTimePrecise() is declared in the Windows headers
Expand Down