Skip to content

Commit ea09f12

Browse files
committed
[cxx-interop] Refer to SwiftBridging module from usr/include/module.modulemap
The recent Clang compiler change makes `-fno-modulemap-allow-subdirectory-search` the default behavior. This means that projects that use C++ interop and `#include <swift/bridging>` no longer compile, since Clang won't search for the SwiftBridging module under `usr/include/swift` anymore. This change adds a new modulemap file to be installed at `toolchain/usr/include/module.modulemap`. This modulemap is under a default Clang include search path, which will make sure Clang can discover the SwiftBridging module. rdar://123334601
1 parent d302860 commit ea09f12

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

lib/ClangImporter/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@ if(SWIFT_ENABLE_CXX_INTEROP_SWIFT_BRIDGING_HEADER)
6161

6262
swift_install_in_component(FILES
6363
"${CMAKE_CURRENT_SOURCE_DIR}/bridging"
64-
"${CMAKE_CURRENT_SOURCE_DIR}/module.modulemap"
64+
"${CMAKE_CURRENT_SOURCE_DIR}/bridging.modulemap"
6565
DESTINATION "include/swift"
6666
COMPONENT compiler)
67+
swift_install_in_component(FILES
68+
"${CMAKE_CURRENT_SOURCE_DIR}/module.modulemap"
69+
DESTINATION "include"
70+
COMPONENT compiler)
6771

6872
add_dependencies(swiftClangImporter
6973
"copy_cxxInterop_support_header")

lib/ClangImporter/bridging.modulemap

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===------------------ module.modulemap - C++ and Swift module -*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
module SwiftBridging {
14+
header "bridging"
15+
16+
export *
17+
}

lib/ClangImporter/module.modulemap

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,4 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
module SwiftBridging {
14-
header "bridging"
15-
16-
export *
17-
}
13+
extern module SwiftBridging "swift/bridging.modulemap"

0 commit comments

Comments
 (0)