Skip to content

[Runtime] Remove dependency on Compiler.h from Config.h. #17702

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
Jul 3, 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
30 changes: 28 additions & 2 deletions include/swift/Runtime/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,34 @@
#ifndef SWIFT_RUNTIME_CONFIG_H
#define SWIFT_RUNTIME_CONFIG_H

// Bring in visibility attribute macros for library visibility.
#include "llvm/Support/Compiler.h"
/// \macro SWIFT_RUNTIME_GNUC_PREREQ
/// Extend the default __GNUC_PREREQ even if glibc's features.h isn't
/// available.
#ifndef SWIFT_RUNTIME_GNUC_PREREQ
# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we up to the point where the runtime is always built with the just-built Clang? If so, we can drop all this too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, we always use the just-built Clang to build the runtime. We've discussed changes to allow building the stdlib and runtime separately (where there may not be a just-built Clang), but in that case, if someone chooses to use that option (in some future version where it is supported), I think we will then require the system compiler to be a suitably recent version of Clang.

# define SWIFT_RUNTIME_GNUC_PREREQ(maj, min, patch) \
((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \
((maj) << 20) + ((min) << 10) + (patch))
# elif defined(__GNUC__) && defined(__GNUC_MINOR__)
# define SWIFT_RUNTIME_GNUC_PREREQ(maj, min, patch) \
((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10))
# else
# define SWIFT_RUNTIME_GNUC_PREREQ(maj, min, patch) 0
# endif
#endif

/// SWIFT_RUNTIME_LIBRARY_VISIBILITY - If a class marked with this attribute is
/// linked into a shared library, then the class should be private to the
/// library and not accessible from outside it. Can also be used to mark
/// variables and functions, making them private to any shared library they are
/// linked into.
/// On PE/COFF targets, library visibility is the default, so this isn't needed.
#if (__has_attribute(visibility) || SWIFT_RUNTIME_GNUC_PREREQ(4, 0, 0)) && \
!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32)
#define SWIFT_RUNTIME_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden")))
#else
#define SWIFT_RUNTIME_LIBRARY_VISIBILITY
#endif

/// Does the current Swift platform support "unbridged" interoperation
/// with Objective-C? If so, the implementations of various types must
Expand Down
2 changes: 1 addition & 1 deletion stdlib/private/StdlibUnittest/GetOSVersion.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "swift/Runtime/Config.h"

SWIFT_CC(swift) LLVM_LIBRARY_VISIBILITY extern "C"
SWIFT_CC(swift) SWIFT_RUNTIME_LIBRARY_VISIBILITY extern "C"
const char *
getSystemVersionPlistProperty(const char *PropertyName) {
// This function is implemented in Objective-C because Swift does not support
Expand Down
2 changes: 1 addition & 1 deletion stdlib/private/StdlibUnittest/InterceptTraps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void CrashCatcher(int Sig) {
_exit(0);
}

SWIFT_CC(swift) LLVM_LIBRARY_VISIBILITY extern "C"
SWIFT_CC(swift) SWIFT_RUNTIME_LIBRARY_VISIBILITY extern "C"
void installTrapInterceptor() {
// Disable buffering on stdout so that everything is printed before crashing.
setbuf(stdout, 0);
Expand Down
2 changes: 1 addition & 1 deletion stdlib/private/StdlibUnittest/OpaqueIdentityFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@

#include "swift/Runtime/Config.h"

SWIFT_CC(swift) LLVM_LIBRARY_VISIBILITY extern "C"
SWIFT_CC(swift) SWIFT_RUNTIME_LIBRARY_VISIBILITY extern "C"
void *getPointer(void *x) { return x; }

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <Foundation/Foundation.h>
#include "swift/Runtime/Config.h"

SWIFT_CC(swift) LLVM_LIBRARY_VISIBILITY
SWIFT_CC(swift) SWIFT_RUNTIME_LIBRARY_VISIBILITY
extern "C" void
NSArray_getObjects(NSArray SWIFT_NS_RELEASES_ARGUMENT *_Nonnull nsArray,
id *objects, NSUInteger rangeLocation,
Expand All @@ -22,7 +22,7 @@
SWIFT_CC_PLUSONE_GUARD([nsArray release]);
}

SWIFT_CC(swift) LLVM_LIBRARY_VISIBILITY
SWIFT_CC(swift) SWIFT_RUNTIME_LIBRARY_VISIBILITY
extern "C" void
NSDictionary_getObjects(NSDictionary *_Nonnull nsDictionary,
id *objects, id *keys) {
Expand Down