Files
swift-mirror/stdlib/linker-support/magic-symbols-for-install-name.c
Egor Zhdan 84a1ffcb33 [Shims] Include SwiftShims headers without ../
This replaces a number of `#include`-s like this:
```
#include "../../../stdlib/public/SwiftShims/Visibility.h"
```
with this:
```
#include "swift/shims/Visibility.h"
```

This is needed to allow SwiftCompilerSources to use C++ headers which include SwiftShims headers. Currently trying to do that results in errors:
```
swift/swift/include/swift/Demangling/../../../stdlib/public/SwiftShims/module.modulemap:1:8: error: redefinition of module 'SwiftShims'
module SwiftShims {
       ^
Builds.noindex/swift/swift/bootstrapping0/lib/swift/shims/module.modulemap:1:8: note: previously defined here
module SwiftShims {
       ^
```
This happens because the headers in both the source dir and the build dir refer to SwiftShims headers by relative path, and both the source root and the build root contain SwiftShims headers (which are equivalent, but since they are located in different dirs, Clang treats them as different modules).
2022-09-14 11:14:50 +01:00

93 lines
3.4 KiB
C

//===--- magic-symbols-for-install-name.c - Magic linker directive symbols ===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// A file containing magic symbols that instruct the linker to use a
// different install name when targeting older OSes. This file gets
// compiled into all of the libraries that are embedded for backward
// deployment.
//
//===----------------------------------------------------------------------===//
#if defined(__APPLE__) && defined(__MACH__) && SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT
#include <Availability.h>
#include <TargetConditionals.h>
#include "swift/shims/Visibility.h"
#define RPATH_INSTALL_NAME_DIRECTIVE_IMPL2(name, major, minor) \
SWIFT_RUNTIME_EXPORT const char install_name_ ## major ## _ ## minor \
__asm("$ld$install_name$os" #major "." #minor "$@rpath/lib" #name ".dylib"); \
const char install_name_ ## major ## _ ## minor = 0;
#define RPATH_INSTALL_NAME_DIRECTIVE_IMPL(name, major, minor) \
RPATH_INSTALL_NAME_DIRECTIVE_IMPL2(name, major, minor)
#define RPATH_INSTALL_NAME_DIRECTIVE(major, minor) \
RPATH_INSTALL_NAME_DIRECTIVE_IMPL(SWIFT_TARGET_LIBRARY_NAME, major, minor)
#if TARGET_OS_WATCH
// Check watchOS first, because TARGET_OS_IPHONE includes watchOS.
RPATH_INSTALL_NAME_DIRECTIVE( 2, 0)
RPATH_INSTALL_NAME_DIRECTIVE( 2, 1)
RPATH_INSTALL_NAME_DIRECTIVE( 2, 2)
RPATH_INSTALL_NAME_DIRECTIVE( 3, 0)
RPATH_INSTALL_NAME_DIRECTIVE( 3, 1)
RPATH_INSTALL_NAME_DIRECTIVE( 3, 2)
RPATH_INSTALL_NAME_DIRECTIVE( 4, 0)
RPATH_INSTALL_NAME_DIRECTIVE( 4, 1)
RPATH_INSTALL_NAME_DIRECTIVE( 4, 2)
RPATH_INSTALL_NAME_DIRECTIVE( 4, 3)
RPATH_INSTALL_NAME_DIRECTIVE( 5, 0)
RPATH_INSTALL_NAME_DIRECTIVE( 5, 1)
#elif TARGET_OS_IPHONE
RPATH_INSTALL_NAME_DIRECTIVE( 7, 0)
RPATH_INSTALL_NAME_DIRECTIVE( 7, 1)
RPATH_INSTALL_NAME_DIRECTIVE( 8, 0)
RPATH_INSTALL_NAME_DIRECTIVE( 8, 1)
RPATH_INSTALL_NAME_DIRECTIVE( 8, 2)
RPATH_INSTALL_NAME_DIRECTIVE( 8, 3)
RPATH_INSTALL_NAME_DIRECTIVE( 8, 4)
RPATH_INSTALL_NAME_DIRECTIVE( 9, 0)
RPATH_INSTALL_NAME_DIRECTIVE( 9, 1)
RPATH_INSTALL_NAME_DIRECTIVE( 9, 2)
RPATH_INSTALL_NAME_DIRECTIVE( 9, 3)
RPATH_INSTALL_NAME_DIRECTIVE(10, 0)
RPATH_INSTALL_NAME_DIRECTIVE(10, 1)
RPATH_INSTALL_NAME_DIRECTIVE(10, 2)
RPATH_INSTALL_NAME_DIRECTIVE(10, 3)
RPATH_INSTALL_NAME_DIRECTIVE(11, 0)
RPATH_INSTALL_NAME_DIRECTIVE(11, 1)
RPATH_INSTALL_NAME_DIRECTIVE(11, 2)
RPATH_INSTALL_NAME_DIRECTIVE(11, 3)
RPATH_INSTALL_NAME_DIRECTIVE(11, 4)
RPATH_INSTALL_NAME_DIRECTIVE(12, 0)
RPATH_INSTALL_NAME_DIRECTIVE(12, 1)
#elif TARGET_OS_OSX
RPATH_INSTALL_NAME_DIRECTIVE(10, 9)
RPATH_INSTALL_NAME_DIRECTIVE(10, 10)
RPATH_INSTALL_NAME_DIRECTIVE(10, 11)
RPATH_INSTALL_NAME_DIRECTIVE(10, 12)
RPATH_INSTALL_NAME_DIRECTIVE(10, 13)
// When building with a deployment target of < macOS 10.14,
// treat macOS 10.14 as an "older OS."
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_14
RPATH_INSTALL_NAME_DIRECTIVE(10, 14)
#endif
#else
#error Unknown target.
#endif
#endif // defined(__APPLE__) && defined(__MACH__) && SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT