Skip to content
Permalink
Browse files
Merge pull request #58957 from johnno1962/bootstrap-fix
Potential fix for --xcode build on M1.
  • Loading branch information
LucianoPAlmeida committed May 21, 2022
2 parents ac74b84 + 5381466 commit c9d9226d7298b934116a1ba7255317c33d61e8a6
Showing 2 changed files with 21 additions and 9 deletions.
@@ -171,19 +171,16 @@ function(add_swift_compiler_modules_library name)
endforeach()

# Create a static library containing all module object files.
if (XCODE)
# Xcode does not compile libraries that contain only object files.
# Therefore, it fails to create the static library. As a workaround,
# we add an empty source file force_lib.c to the target.
set(all_obj_files force_lib.c ${all_obj_files})
endif()
add_library(${name} STATIC ${all_obj_files})
add_dependencies(${name} ${all_module_targets})
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
set_property(GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS ${name})

# Xcode does not compile libraries that contain only object files.
# Therefore, it fails to create the static library. As a workaround,
# we add a dummy script phase to the target.
if (XCODE)
add_custom_command(TARGET ${name} POST_BUILD
COMMAND ""
COMMENT "Dummy script phase to force building this target")
endif()
endfunction()


@@ -0,0 +1,15 @@
//===--- force_lib.c ------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

/// Dummy source file to force CMake generated SwiftInTheCompiler.xcodeproj
/// to sucessfully build static libraries conatining only object files used
/// during "bootstrap" process to link Swift sources into the compiler.

0 comments on commit c9d9226

Please sign in to comment.