Skip to content

Commit dac3e2b

Browse files
authored
Merge pull request swiftlang#39400 from DougGregor/rpath-install-name-back-deployed-concurrency
2 parents 22c2889 + 3c21857 commit dac3e2b

File tree

3 files changed

+153
-0
lines changed

3 files changed

+153
-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
AsyncStream.cpp
101101
Deque.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: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
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( 2, 0)
44+
RPATH_INSTALL_NAME_DIRECTIVE( 2, 1)
45+
RPATH_INSTALL_NAME_DIRECTIVE( 2, 2)
46+
RPATH_INSTALL_NAME_DIRECTIVE( 3, 0)
47+
RPATH_INSTALL_NAME_DIRECTIVE( 3, 1)
48+
RPATH_INSTALL_NAME_DIRECTIVE( 3, 2)
49+
RPATH_INSTALL_NAME_DIRECTIVE( 4, 0)
50+
RPATH_INSTALL_NAME_DIRECTIVE( 4, 1)
51+
RPATH_INSTALL_NAME_DIRECTIVE( 4, 2)
52+
RPATH_INSTALL_NAME_DIRECTIVE( 4, 3)
53+
RPATH_INSTALL_NAME_DIRECTIVE( 5, 0)
54+
RPATH_INSTALL_NAME_DIRECTIVE( 5, 1)
55+
RPATH_INSTALL_NAME_DIRECTIVE( 5, 2)
56+
RPATH_INSTALL_NAME_DIRECTIVE( 5, 3)
57+
RPATH_INSTALL_NAME_DIRECTIVE( 6, 0)
58+
RPATH_INSTALL_NAME_DIRECTIVE( 6, 1)
59+
RPATH_INSTALL_NAME_DIRECTIVE( 6, 2)
60+
RPATH_INSTALL_NAME_DIRECTIVE( 6, 3)
61+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 0)
62+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 1)
63+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 2)
64+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 3)
65+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 4)
66+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 5)
67+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 6)
68+
#elif TARGET_OS_IPHONE
69+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 0)
70+
RPATH_INSTALL_NAME_DIRECTIVE( 7, 1)
71+
RPATH_INSTALL_NAME_DIRECTIVE( 8, 0)
72+
RPATH_INSTALL_NAME_DIRECTIVE( 8, 1)
73+
RPATH_INSTALL_NAME_DIRECTIVE( 8, 2)
74+
RPATH_INSTALL_NAME_DIRECTIVE( 8, 3)
75+
RPATH_INSTALL_NAME_DIRECTIVE( 8, 4)
76+
RPATH_INSTALL_NAME_DIRECTIVE( 9, 0)
77+
RPATH_INSTALL_NAME_DIRECTIVE( 9, 1)
78+
RPATH_INSTALL_NAME_DIRECTIVE( 9, 2)
79+
RPATH_INSTALL_NAME_DIRECTIVE( 9, 3)
80+
RPATH_INSTALL_NAME_DIRECTIVE(10, 0)
81+
RPATH_INSTALL_NAME_DIRECTIVE(10, 1)
82+
RPATH_INSTALL_NAME_DIRECTIVE(10, 2)
83+
RPATH_INSTALL_NAME_DIRECTIVE(10, 3)
84+
RPATH_INSTALL_NAME_DIRECTIVE(11, 0)
85+
RPATH_INSTALL_NAME_DIRECTIVE(11, 1)
86+
RPATH_INSTALL_NAME_DIRECTIVE(11, 2)
87+
RPATH_INSTALL_NAME_DIRECTIVE(11, 3)
88+
RPATH_INSTALL_NAME_DIRECTIVE(11, 4)
89+
RPATH_INSTALL_NAME_DIRECTIVE(12, 0)
90+
RPATH_INSTALL_NAME_DIRECTIVE(12, 1)
91+
RPATH_INSTALL_NAME_DIRECTIVE(12, 2)
92+
RPATH_INSTALL_NAME_DIRECTIVE(12, 3)
93+
RPATH_INSTALL_NAME_DIRECTIVE(12, 4)
94+
RPATH_INSTALL_NAME_DIRECTIVE(12, 5)
95+
RPATH_INSTALL_NAME_DIRECTIVE(13, 0)
96+
RPATH_INSTALL_NAME_DIRECTIVE(13, 1)
97+
RPATH_INSTALL_NAME_DIRECTIVE(13, 2)
98+
RPATH_INSTALL_NAME_DIRECTIVE(13, 3)
99+
RPATH_INSTALL_NAME_DIRECTIVE(13, 4)
100+
RPATH_INSTALL_NAME_DIRECTIVE(13, 5)
101+
RPATH_INSTALL_NAME_DIRECTIVE(13, 6)
102+
RPATH_INSTALL_NAME_DIRECTIVE(13, 7)
103+
RPATH_INSTALL_NAME_DIRECTIVE(14, 0)
104+
RPATH_INSTALL_NAME_DIRECTIVE(14, 1)
105+
RPATH_INSTALL_NAME_DIRECTIVE(14, 2)
106+
RPATH_INSTALL_NAME_DIRECTIVE(14, 3)
107+
RPATH_INSTALL_NAME_DIRECTIVE(14, 4)
108+
RPATH_INSTALL_NAME_DIRECTIVE(14, 5)
109+
RPATH_INSTALL_NAME_DIRECTIVE(14, 6)
110+
RPATH_INSTALL_NAME_DIRECTIVE(14, 7)
111+
RPATH_INSTALL_NAME_DIRECTIVE(14, 8)
112+
#elif TARGET_OS_OSX
113+
RPATH_INSTALL_NAME_DIRECTIVE(10, 9)
114+
RPATH_INSTALL_NAME_DIRECTIVE(10, 10)
115+
RPATH_INSTALL_NAME_DIRECTIVE(10, 11)
116+
RPATH_INSTALL_NAME_DIRECTIVE(10, 12)
117+
RPATH_INSTALL_NAME_DIRECTIVE(10, 13)
118+
RPATH_INSTALL_NAME_DIRECTIVE(10, 15)
119+
RPATH_INSTALL_NAME_DIRECTIVE(10, 14)
120+
RPATH_INSTALL_NAME_DIRECTIVE(11, 0)
121+
RPATH_INSTALL_NAME_DIRECTIVE(11, 1)
122+
RPATH_INSTALL_NAME_DIRECTIVE(11, 2)
123+
RPATH_INSTALL_NAME_DIRECTIVE(11, 3)
124+
RPATH_INSTALL_NAME_DIRECTIVE(11, 4)
125+
RPATH_INSTALL_NAME_DIRECTIVE(11, 5)
126+
RPATH_INSTALL_NAME_DIRECTIVE(11, 6)
127+
#else
128+
#error Unknown target.
129+
#endif
130+
131+
#endif // defined(__APPLE__) && defined(__MACH__)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift -target x86_64-apple-macosx12 %s -o %t/linking_direct
3+
// RUN: %target-build-swift -target x86_64-apple-macosx11 %s -o %t/linking_rpath
4+
// RUN: %target-build-swift -target x86_64-apple-macosx10.10 %s -o %t/linking_rpath_old
5+
6+
// RUN: otool -L %t/linking_direct | %FileCheck -check-prefix CHECK-DIRECT %s
7+
// RUN: otool -L %t/linking_rpath | %FileCheck -check-prefix CHECK-RPATH %s
8+
// RUN: otool -L %t/linking_rpath_old | %FileCheck -check-prefix CHECK-RPATH %s
9+
10+
// REQUIRES: OS=macosx
11+
12+
// CHECK-DIRECT: /usr/lib/swift/libswift_Concurrency.dylib
13+
// CHECK-RPATH: @rpath/libswift_Concurrency.dylib
14+
15+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
16+
public struct X {
17+
public func f() async -> Int { return 0 }
18+
public func g() async -> Int {
19+
await f()
20+
}
21+
}

0 commit comments

Comments
 (0)