Skip to content

Commit c5aec28

Browse files
varungandhi-appleDougGregor
authored andcommitted
Add magic symbols for concurrency.
(cherry picked from commit 5743040)
1 parent 9279139 commit c5aec28

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

stdlib/public/Concurrency/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I
100100
Deque.swift
101101
YieldingContinuation.swift
102102
${swift_concurrency_extra_sources}
103+
linker-support/magic-symbols-for-install-name.c
103104

104105
SWIFT_MODULE_DEPENDS_LINUX Glibc
105106
SWIFT_MODULE_DEPENDS_FREEBSD Glibc
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//===--- magic-symbols-for-install-name.c - Magic linker directive symbols ===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2021 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// A file containing magic symbols that instruct the linker to use a
14+
// different install name when targeting older OSes. This file gets
15+
// compiled into all of the libraries that are embedded for backward
16+
// deployment.
17+
//
18+
// This file is specific to the Concurrency library; there is a matching file
19+
// for the standard library with the same name.
20+
//
21+
//===----------------------------------------------------------------------===//
22+
23+
#if defined(__APPLE__) && defined(__MACH__)
24+
25+
#include <Availability.h>
26+
#include <TargetConditionals.h>
27+
#include "../../SwiftShims/Visibility.h"
28+
29+
#define RPATH_INSTALL_NAME_DIRECTIVE_IMPL2(name, major, minor) \
30+
SWIFT_RUNTIME_EXPORT const char install_name_ ## major ## _ ## minor \
31+
__asm("$ld$install_name$os" #major "." #minor "$@rpath/lib" #name ".dylib"); \
32+
const char install_name_ ## major ## _ ## minor = 0;
33+
34+
#define RPATH_INSTALL_NAME_DIRECTIVE_IMPL(name, major, minor) \
35+
RPATH_INSTALL_NAME_DIRECTIVE_IMPL2(name, major, minor)
36+
37+
#define RPATH_INSTALL_NAME_DIRECTIVE(major, minor) \
38+
RPATH_INSTALL_NAME_DIRECTIVE_IMPL(SWIFT_TARGET_LIBRARY_NAME, major, minor)
39+
40+
41+
#if TARGET_OS_WATCH
42+
// Check watchOS first, because TARGET_OS_IPHONE includes watchOS.
43+
RPATH_INSTALL_NAME_DIRECTIVE( 6, 0)
44+
RPATH_INSTALL_NAME_DIRECTIVE( 6, 1)
45+
RPATH_INSTALL_NAME_DIRECTIVE( 6, 2)
46+
RPATH_INSTALL_NAME_DIRECTIVE( 6, 3)
47+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 0)
48+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 1)
49+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 2)
50+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 3)
51+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 4)
52+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 5)
53+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 6)
54+
#elif TARGET_OS_IPHONE
55+
RPATH_INSTALL_NAME_DIRECTIVE(13, 0)
56+
RPATH_INSTALL_NAME_DIRECTIVE(13, 1)
57+
RPATH_INSTALL_NAME_DIRECTIVE(13, 2)
58+
RPATH_INSTALL_NAME_DIRECTIVE(13, 3)
59+
RPATH_INSTALL_NAME_DIRECTIVE(13, 4)
60+
RPATH_INSTALL_NAME_DIRECTIVE(13, 5)
61+
RPATH_INSTALL_NAME_DIRECTIVE(13, 6)
62+
RPATH_INSTALL_NAME_DIRECTIVE(13, 7)
63+
RPATH_INSTALL_NAME_DIRECTIVE(14, 0)
64+
RPATH_INSTALL_NAME_DIRECTIVE(14, 1)
65+
RPATH_INSTALL_NAME_DIRECTIVE(14, 2)
66+
RPATH_INSTALL_NAME_DIRECTIVE(14, 3)
67+
RPATH_INSTALL_NAME_DIRECTIVE(14, 4)
68+
RPATH_INSTALL_NAME_DIRECTIVE(14, 5)
69+
RPATH_INSTALL_NAME_DIRECTIVE(14, 6)
70+
RPATH_INSTALL_NAME_DIRECTIVE(14, 7)
71+
#elif TARGET_OS_OSX
72+
RPATH_INSTALL_NAME_DIRECTIVE(10, 15)
73+
RPATH_INSTALL_NAME_DIRECTIVE(11, 0)
74+
RPATH_INSTALL_NAME_DIRECTIVE(11, 1)
75+
RPATH_INSTALL_NAME_DIRECTIVE(11, 2)
76+
RPATH_INSTALL_NAME_DIRECTIVE(11, 3)
77+
RPATH_INSTALL_NAME_DIRECTIVE(11, 4)
78+
RPATH_INSTALL_NAME_DIRECTIVE(11, 5)
79+
#else
80+
#error Unknown target.
81+
#endif
82+
83+
#endif // defined(__APPLE__) && defined(__MACH__)

0 commit comments

Comments
 (0)