Skip to content

Visibility fixes for ELF. #14831

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
Feb 26, 2018
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
22 changes: 20 additions & 2 deletions stdlib/public/SwiftShims/Visibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,37 @@
// SWIFT_RUNTIME_EXPORT on the library it's exported from.

/// Attribute used to export symbols from the runtime.
#if defined(__MACH__) || defined(__ELF__)
#if defined(__MACH__)

# define SWIFT_EXPORT_ATTRIBUTE __attribute__((__visibility__("default")))

#else // FIXME: this #else should be some sort of #elif Windows
#elif defined(__ELF__)

// We make assumptions that the runtime and standard library can refer to each
// other's symbols as DSO-local, which means we can't allow the dynamic linker
// to relocate these symbols. We must give them protected visibility while
// building the standard library and runtime.
# if defined(swiftCore_EXPORTS)
# define SWIFT_EXPORT_ATTRIBUTE __attribute__((__visibility__("protected")))
# else
# define SWIFT_EXPORT_ATTRIBUTE __attribute__((__visibility__("default")))
# endif

// FIXME: this #else should be some sort of #elif Windows
#else // !__MACH__ && !__ELF__

# if defined(__CYGWIN__)
# define SWIFT_EXPORT_ATTRIBUTE
# else

# if defined(swiftCore_EXPORTS)
# define SWIFT_EXPORT_ATTRIBUTE __declspec(dllexport)
# else
# define SWIFT_EXPORT_ATTRIBUTE __declspec(dllimport)
# endif

# endif

#endif

#if defined(__cplusplus)
Expand Down
6 changes: 3 additions & 3 deletions stdlib/public/stubs/GlobalObjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ SWIFT_RUNTIME_STDLIB_INTERFACE
ClassMetadata CLASS_METADATA_SYM(s20_RawNativeSetStorage);
} // namespace swift

SWIFT_RUNTIME_STDLIB_INTERFACE
swift::_SwiftEmptyArrayStorage swift::_swiftEmptyArrayStorage = {
// HeapObject header;
{
Expand All @@ -50,8 +51,7 @@ swift::_SwiftEmptyArrayStorage swift::_swiftEmptyArrayStorage = {
}
};



SWIFT_RUNTIME_STDLIB_INTERFACE
swift::_SwiftEmptyDictionaryStorage swift::_swiftEmptyDictionaryStorage = {
// HeapObject header;
{
Expand Down Expand Up @@ -79,7 +79,7 @@ swift::_SwiftEmptyDictionaryStorage swift::_swiftEmptyDictionaryStorage = {
0 // int entries; (zero'd bits)
};


SWIFT_RUNTIME_STDLIB_INTERFACE
swift::_SwiftEmptySetStorage swift::_swiftEmptySetStorage = {
// HeapObject header;
{
Expand Down