Skip to content

Cleanup uses of SWIFT_RT_ENTRY_VISBILITY #7103

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
Jan 31, 2017
Merged

Cleanup uses of SWIFT_RT_ENTRY_VISBILITY #7103

merged 1 commit into from
Jan 31, 2017

Conversation

hughbe
Copy link
Contributor

@hughbe hughbe commented Jan 27, 2017

And clang-format the effected method signatures - previously there was extern "C", so signatures flow differently

@swiftix
Copy link
Contributor

swiftix commented Jan 27, 2017

@hughbe How you decide when you can remove those SWIFT_RT_ENTRY_VISBILITY specifiers?

@hughbe
Copy link
Contributor Author

hughbe commented Jan 27, 2017

Sorry, I was about to fill in some info. Basically, in #6820 there was a discussion with @gparker42

Summary is, I identified all cases where SWIFT_RT_ENTRY_VISBILITY was used unecessarily, according to this comment from Greg:

SWIFT_RUNTIME_EXPORT has both extern "C" and __declspec as appropriate
every export has a header declaration
header declarations of exports all use SWIFT_RUNTIME_EXPORT
non-header definitions do not use SWIFT_RUNTIME_EXPORT or extern "C" or __declspec.

@hughbe
Copy link
Contributor Author

hughbe commented Jan 27, 2017

@swift-ci please smoke test

@swiftix
Copy link
Contributor

swiftix commented Jan 27, 2017

@hughbe I'm not 100% about this. It was me who added those SWIFT_RT_ENTRY_VISBILITY when I was working on the new calling convention for the Swift runtime functions. The idea of using a macro was useful, because it allows you to easily flip the visibility of a function based on the configuration in Config.h.

If you remove these specifiers now, how one can easily change the visibility of symbols without touching a lot of places in the source code?

@hughbe
Copy link
Contributor Author

hughbe commented Jan 27, 2017

Also, quick Q for @gparker42 or anyone else with the knowledge

Functions defined in RuntimeFunctions.def: https://github.com/apple/swift/blob/adc54c8a4d13fbebfeb68244bac401ef2528d6d0/include/swift/Runtime/RuntimeFunctions.def

are declared extern "C" in the header without any visibility or declspec attributes. However, they are implemented in terms of extern C declspec(dllexport).

E.g.
// bool swift_isClassType(type*);

Definition: https://github.com/apple/swift/blob/adc54c8a4d13fbebfeb68244bac401ef2528d6d0/include/swift/Runtime/RuntimeFunctions.def#L1003
Implementation: https://github.com/apple/swift/blob/master/stdlib/public/runtime/Casting.cpp#L3234

What should we do in these cases?
Maybe we change the definition here: https://github.com/apple/swift/blob/ac57b66c99f9e5f8dd023245a28447613f74d08d/stdlib/public/runtime/RuntimeEntrySymbols.cpp#L49

@hughbe
Copy link
Contributor Author

hughbe commented Jan 27, 2017

If you remove these specifiers now, how one can easily change the visibility of symbols without touching a lot of places in the source code?

The whole point is that this reduces the number of places we actually need to change the visibility of symbols. Basically, the issue right now is that we define a method as SWIFT_RT_ENTRY_VISIBILITY in the header. Then, in the implementation, we repeat SWIFT_RT_ENTRY_VISIBILITY.

This is unnecessary and we don't need to duplicate the visbiility in the cpp file as well as the .h file

@swiftix
Copy link
Contributor

swiftix commented Jan 27, 2017

Oh, I missed the point that the symbols have the same specifier in the header. Sorry. No objections then.

@hughbe
Copy link
Contributor Author

hughbe commented Jan 27, 2017

Messed up on OSX (objc specific method)

@hughbe
Copy link
Contributor Author

hughbe commented Jan 27, 2017

@swift-ci please smoke test

@hughbe
Copy link
Contributor Author

hughbe commented Jan 31, 2017

@gparker42 @swiftix good to merge?

@swiftix
Copy link
Contributor

swiftix commented Jan 31, 2017

@hugbe LGTM

@gparker42 gparker42 merged commit d030ae4 into swiftlang:master Jan 31, 2017
@hughbe hughbe deleted the swift-rt-entry branch January 31, 2017 23:59
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.

3 participants