Skip to content

Commit 5408593

Browse files
committed
Runtime: simplify SWIFT_LIBRARY_VISIBILITY
This removes the GNUC version check as the runtime does require ABI support which is not present in GCC. Remove the unnecessary check and simplify the condition by checking the file format that the visibility attribute is being applied to and limit it to the ones supporting it.
1 parent bab23d8 commit 5408593

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

stdlib/public/SwiftShims/Visibility.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,6 @@
116116
#endif
117117

118118

119-
#ifndef SWIFT_GNUC_PREREQ
120-
# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
121-
# define SWIFT_GNUC_PREREQ(maj, min, patch) \
122-
((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \
123-
((maj) << 20) + ((min) << 10) + (patch))
124-
# elif defined(__GNUC__) && defined(__GNUC_MINOR__)
125-
# define SWIFT_GNUC_PREREQ(maj, min, patch) \
126-
((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10))
127-
# else
128-
# define SWIFT_GNUC_PREREQ(maj, min, patch) 0
129-
# endif
130-
#endif
131-
132119
/// Attributes for runtime-stdlib interfaces.
133120
/// Use these for C implementations that are imported into Swift via SwiftShims
134121
/// and for C implementations of Swift @_silgen_name declarations
@@ -151,9 +138,8 @@
151138

152139
// Match the definition of LLVM_LIBRARY_VISIBILITY from LLVM's
153140
// Compiler.h. That header requires C++ and this needs to work in C.
154-
#if (__has_attribute(visibility) || SWIFT_GNUC_PREREQ(4, 0, 0)) && \
155-
!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32)
156-
#define SWIFT_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden")))
141+
#if __has_attribute(visibility) && (defined(__ELF__) || defined(__MACH__))
142+
#define SWIFT_LIBRARY_VISIBILITY __attribute__ ((__visibility__("hidden")))
157143
#else
158144
#define SWIFT_LIBRARY_VISIBILITY
159145
#endif

0 commit comments

Comments
 (0)