Skip to content

Commit 8b498bf

Browse files
committed
stdlib: COFF variant of "visibility" macro
Currently, LLVM supports the current three common object file formats (COFF, ELF, MachO). Unfortunately, COFF does not provide a compiler macro to identify the object file format. If neither `__MACH__` nor `__ELF__` is defined, then assume that the object file format being used is COFF. Within the COFF target handling, do not use `__declspec(dllexport)` for cygwin targets.
1 parent c404785 commit 8b498bf

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

stdlib/public/SwiftShims/Visibility.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@
5959
# define SWIFT_RUNTIME_EXPORT __attribute__((__visibility__("default")))
6060
#endif
6161

62-
#elif __CYGWIN__
63-
# define SWIFT_RUNTIME_EXPORT
6462
#else
65-
// __dllexport/__dllimport for Windows?
66-
# error "Unimplemented object format"
63+
# if defined(__CYGWIN__)
64+
# define SWIFT_RUNTIME_EXPORT
65+
# else
66+
# if defined(__SWIFT_CURRENT_DYLIB)
67+
# define SWIFT_RUNTIME_EXPORT __declspec(dllexport)
68+
# else
69+
# define SWIFT_RUNTIME_EXPORT
70+
# endif
71+
# endif
6772
#endif
6873

6974
/// Attribute for runtime-stdlib SPI interfaces.

0 commit comments

Comments
 (0)