Skip to content

Potential fix for --xcode build on M1. #58957

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 3 commits into from
May 21, 2022
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
15 changes: 6 additions & 9 deletions SwiftCompilerSources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
15 changes: 15 additions & 0 deletions SwiftCompilerSources/force_lib.c
Original file line number Diff line number Diff line change
@@ -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.