Skip to content

Fix Swift Compiler Modules support in Debug mode #73506

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 2 commits into from
May 8, 2024
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
18 changes: 15 additions & 3 deletions SwiftCompilerSources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,20 @@ function(add_swift_compiler_modules_library name)
endforeach()
endif()

set(module_obj_file "${build_dir}/${module}.o")
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
# swift-driver when non-optimizing in not Mach-O platforms adds an extra
# job wrapmodule that uses the {module-name}.o as output, which clashes
# with the name chosen here. Use a different name in those cases.
set(module_obj_file "${build_dir}/${module}.object.o")
set(output_obj_files "${module_obj_file}" "${build_dir}/${module}.o")
else()
set(module_obj_file "${build_dir}/${module}.o")
set(output_obj_files "${module_obj_file}")
endif()
set(module_file "${build_dir}/${module}.swiftmodule")
list(APPEND all_module_files ${module_file})

set(all_obj_files ${all_obj_files} ${module_obj_file})
list(APPEND all_obj_files ${output_obj_files})
set(c_include_paths
# LLVM modules and headers.
"${LLVM_MAIN_INCLUDE_DIR}"
Expand Down Expand Up @@ -237,7 +246,7 @@ function(add_swift_compiler_modules_library name)
${c_include_paths_args}
# Generated swift modules.
"-I" "${build_dir}"
OUTPUT ${module_obj_file}
OUTPUT ${output_obj_files}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${sources} ${deps} ${ALS_DEPENDS}
importedHeaderDependencies
Expand All @@ -260,6 +269,9 @@ function(add_swift_compiler_modules_library name)
add_library(${name} STATIC ${all_obj_files})
add_dependencies(${name} ${all_module_targets})
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_libraries(${name} PUBLIC swiftSwiftOnoneSupport)
endif()

# Downstream linking should include the swiftmodule in debug builds to allow lldb to
# work correctly. Only do this on Darwin since neither gold (currently used by default
Expand Down
3 changes: 3 additions & 0 deletions include/swift/SILOptimizer/OptimizerBridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ void SILCombine_registerInstructionPass(BridgedStringRef instClassName,
#ifndef PURE_BRIDGING_MODE
// In _not_ PURE_BRIDGING_MODE, briding functions are inlined and therefore inluded in the header file.
#include "OptimizerBridgingImpl.h"
#else
// For fflush and stdout
#include <stdio.h>
#endif

SWIFT_END_NULLABILITY_ANNOTATIONS
Expand Down