Skip to content

[libswift] Undefine IBAction/IBOutlet ObjC macros when building lib swift #39866

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 1 commit into from
Oct 28, 2021

Conversation

guitard0g
Copy link

@guitard0g guitard0g commented Oct 21, 2021

When we compile libswift with c++-interop enabled, it actually ends up compiling the project as objc++ on Darwin platforms because objc interop is necessarily enabled by default. This causes problems in the libswift bridging header because we try to expand the ObjC IBAction/IBOutlet/IBInspectable macros in inappropriate places.

This change fixes the problem by undefining these macros via -U flags passed when building libswift.

@guitard0g
Copy link
Author

@swift-ci please test

@guitard0g guitard0g added the c++ interop Feature: Interoperability with C++ label Oct 22, 2021
@guitard0g guitard0g changed the title Temporarily undefine IBAction/IBOutlet ObjC macros [libswift] Temporarily undefine IBAction/IBOutlet ObjC macros Oct 22, 2021
@@ -13,6 +13,16 @@
#ifndef SWIFT_SIL_SILBRIDGING_H
#define SWIFT_SIL_SILBRIDGING_H

// Stop these macros from being expanded in this
// file when compiling in ObjC++ mode. This is
// necessary for compiling libswift with c++-interop.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so we don't have to change the LLVM headers? Makes sense, but if we put them here we can also remove the Attr.def change, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately we seem to need this in addition to both the Attr.def change and the changes in the LLVM headers, though I'm not entirely sure why undefining it here doesn't fix those problems (might be something to do with modules...).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you put this change into include/swift/SIL/BridgedSwiftObject.h then you don't need to update the LLVM header or the other Swift header.

@guitard0g guitard0g force-pushed the temp_undef_ib_macros branch from e560741 to 40da89c Compare October 27, 2021 21:52
@guitard0g
Copy link
Author

@swift-ci please test

@guitard0g guitard0g changed the title [libswift] Temporarily undefine IBAction/IBOutlet ObjC macros [libswift] Undefine IBAction/IBOutlet ObjC macros when building lib swift Oct 27, 2021
@zoecarver
Copy link
Contributor

@swift-ci please test Windows

@guitard0g guitard0g merged commit 0f30978 into swiftlang:main Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants