From 83daa49a5af63614114bcc4054e97eb89e75db55 Mon Sep 17 00:00:00 2001 From: Brian Gesiak Date: Thu, 16 Jun 2016 14:29:30 -0400 Subject: [PATCH] [CMake] Only build StdlibUnittest when SDK overlay is built On Linux it used to be possible to build only the stdlib, without the SDK overlays, like so: ``` utils/build-script -- --build-swift-stdlib --build-swift-sdk-overlay=0 ``` However this invocation now results in the following error: ``` + /usr/bin/cmake --build /home/modocache/GitHub/apple/build/Ninja-ReleaseAssert/swift-linux-x86_64 -- -j8 all swift-stdlib-linux-x86_64 ninja: error: '/home/modocache/GitHub/apple/swift/stdlib/private/SwiftPrivatePthreadExtras/swiftGlibc-linux-x86_64', needed by 'stdlib/private/SwiftPrivatePthreadExtras/linux/x86_64/SwiftPrivatePthreadExtras.o', missing and no known rule to make it utils/build-script: fatal error: command terminated with a non-zero exit status 1, aborting ``` The problem is that SwiftPrivatePthreadExtras is always built, regardless of whether the SDK overlay is built. I believe there's an explicit check against this for Darwin platforms to prevent the same error. The solution, implemented here, is to add the same check for Linux. --- stdlib/private/CMakeLists.txt | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/stdlib/private/CMakeLists.txt b/stdlib/private/CMakeLists.txt index dbd63246a0396..23aef38b732b5 100644 --- a/stdlib/private/CMakeLists.txt +++ b/stdlib/private/CMakeLists.txt @@ -2,23 +2,16 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY) add_subdirectory(SwiftPrivate) endif() -if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - if(SWIFT_BUILD_SDK_OVERLAY) - # FIXME: there is nothing Darwin-specific in StdlibUnittest, but to use - # POSIX APIs it imports the Darwin module on Apple platforms, so it can't - # be built separately from the SDK overlay. - add_subdirectory(StdlibUnittest) - add_subdirectory(StdlibCollectionUnittest) - add_subdirectory(StdlibUnittestFoundationExtras) - add_subdirectory(SwiftPrivateLibcExtras) - add_subdirectory(SwiftPrivatePthreadExtras) - add_subdirectory(SwiftReflectionTest) - endif() -endif() - -if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") +if(SWIFT_BUILD_SDK_OVERLAY) + # SwiftPrivatePthreadExtras makes use of Darwin/Glibc, which is part of the + # SDK overlay. It can't be built separately from the SDK overlay. add_subdirectory(StdlibUnittest) add_subdirectory(StdlibCollectionUnittest) add_subdirectory(SwiftPrivateLibcExtras) add_subdirectory(SwiftPrivatePthreadExtras) + + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + add_subdirectory(StdlibUnittestFoundationExtras) + add_subdirectory(SwiftReflectionTest) + endif() endif()