Skip to content

🍒 [next] [swift/cxx-interop] Move swift/bridging header to clang resource dir and suffix it with .h#13298

Open
j-hui wants to merge 2 commits into
swiftlang:nextfrom
j-hui:j-hui/next/move-swift-bridging
Open

🍒 [next] [swift/cxx-interop] Move swift/bridging header to clang resource dir and suffix it with .h#13298
j-hui wants to merge 2 commits into
swiftlang:nextfrom
j-hui:j-hui/next/move-swift-bridging

Conversation

@j-hui

@j-hui j-hui commented Jul 2, 2026

Copy link
Copy Markdown

Place the swift/bridging header in Clang's resource directory, so that it is automatically discoverable by both clang and swift. Also, add .h suffix to the file so that headers can #include <swift/bridging.h>.

Cherry-picked from #12861 and #13083

rdar://136716355
rdar://150298665

j-hui added 2 commits July 1, 2026 23:05
The swift/bridging header provides annotation macros (e.g.,
SWIFT_SHARED_REFERENCE, SWIFT_COMPUTED_PROPERTY) for C++ code that
interoperate with Swift. Previously, this header was shipped in the
Swift toolchain's usr/include, which is not part of Clang's default
search paths in the OSS toolchain, which forced users to manually pass
-I flags to find the header.

By placing it in Clang's resource directory, the header is automatically
discoverable by both clang and swift (via its embedded Clang instance),
since both already search <clang-resource-dir>/include by default.

rdar://136716355
(cherry picked from commit c19415a)
Some SWIFT_* annotation macros are usable from C and ObjC, not just C++.
Rename the extensionless header to swift/bridging.h, and keep around
swift/bridging as a compatibility alias for existing users.

rdar://150298665
(cherry picked from commit 117199f)
@j-hui j-hui requested a review from egorzhdan July 2, 2026 06:21
@j-hui

j-hui commented Jul 2, 2026

Copy link
Copy Markdown
Author

@swift-ci please test llvm

@j-hui

j-hui commented Jul 3, 2026

Copy link
Copy Markdown
Author

Failures seem unrelated:

01:47:35  ********************
01:47:35  Failed Tests (23):
01:47:35    Clang :: BoundsSafety-legacy-checks/CodeGen/dynamic-inout-count-calls-O2.c
01:47:35    Clang :: BoundsSafety-legacy-checks/CodeGen/sized_by_or_null_call-O2.c
01:47:35    Clang :: BoundsSafety/CodeGen/bounds-attributed-return-O2.c
01:47:35    Clang :: BoundsSafety/CodeGen/compound-literal-counted_by-O2-disabled-checks.c
01:47:35    Clang :: BoundsSafety/CodeGen/compound-literal-counted_by_or_null-O2-disabled-checks.c
01:47:35    Clang :: BoundsSafety/CodeGen/compound-literal-counted_by_or_null-O2.c
01:47:35    Clang :: BoundsSafety/CodeGen/compound-literal-ended_by-O2-disabled-checks.c
01:47:35    Clang :: BoundsSafety/CodeGen/compound-literal-sized_by-O2-disabled-checks.c
01:47:35    Clang :: BoundsSafety/CodeGen/compound-literal-sized_by_or_null-O2-disabled-checks.c
01:47:35    Clang :: BoundsSafety/CodeGen/compound-literal-sized_by_or_null-O2.c
01:47:35    Clang :: BoundsSafety/CodeGen/counted-by-nested-assignments-O2.c
01:47:35    Clang :: BoundsSafety/CodeGen/ended-by-nested-assignments-O2.c
01:47:35    Clang :: BoundsSafety/CodeGen/range-check-optimizations-constexpr-geps.c
01:47:35    Clang :: BoundsSafety/CodeGen/soft-traps/call_minimal.c
01:47:35    Clang :: BoundsSafety/CodeGen/soft-traps/call_minimal_custom_func.c
01:47:35    Clang :: BoundsSafety/CodeGen/soft-traps/call_minimal_with_ubsan.c
01:47:35    Clang :: BoundsSafety/CodeGen/soft-traps/call_with_str.c
01:47:35    Clang :: BoundsSafety/CodeGen/soft-traps/call_with_str_custom_func.c
01:47:35    Clang :: BoundsSafety/CodeGen/soft-traps/call_with_str_with_ubsan.c
01:47:35    Clang :: BoundsSafety/CodeGen/unique-traps-O0-O2-opt-disabled.c
01:47:35    Clang :: BoundsSafety/CodeGen/unique-traps-O2.c
01:47:35    Clang :: BoundsSafety/CodeGen/unique-traps-disabled-O0-O2-opt-disabled.c
01:47:35    Clang :: CodeGen/attr-counted-by-issue200014.c

They appear to also be happening elsewhere: https://ci.swift.org/job/swiftlang-clang-stage1-RA/job/next/128/

@j-hui

j-hui commented Jul 7, 2026

Copy link
Copy Markdown
Author

@swift-ci please test llvm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants