From a0715dc402182ffa26f8c3ac9fb975f00db8423d Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 2 Jun 2023 08:34:54 -0700 Subject: [PATCH] dispatch: install the correct modulemap when building static There is a subtle difference between libdispatch built dynamically and statically: DispatchStubs. We erroneously emit ObjC runtime calls into the build and the stubs provides a shim to provide a definition on non-ObjC runtime enabled targets. When built dynamically, this is internalised and distributed as part of dispatch.dll/libdispatch.so, however when built statically, the consumer is responsible for linking against DispatchStubs. The modulemap reflects this and we need to ensure that we correctly provide that modulemap. Thanks to @MaxDesiatov for the help with debugging and testing a fix for this! Fixes: rdar://23335318 --- dispatch/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dispatch/CMakeLists.txt b/dispatch/CMakeLists.txt index 352915d91..a7f5fc306 100644 --- a/dispatch/CMakeLists.txt +++ b/dispatch/CMakeLists.txt @@ -1,8 +1,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(DISPATCH_MODULE_MAP ${PROJECT_SOURCE_DIR}/dispatch/darwin/module.modulemap) -else() +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