Skip to content

Commit 00fadc0

Browse files
authored
Merge pull request #423 from swiftwasm/master
[pull] swiftwasm from master
2 parents f50c25d + 270f734 commit 00fadc0

File tree

19 files changed

+255
-55
lines changed

19 files changed

+255
-55
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ set(SWIFT_ANALYZE_CODE_COVERAGE FALSE CACHE STRING
137137
# SWIFT_VERSION is deliberately /not/ cached so that an existing build directory
138138
# can be reused when a new version of Swift comes out (assuming the user hasn't
139139
# manually set it as part of their own CMake configuration).
140-
set(SWIFT_VERSION "5.2")
140+
set(SWIFT_VERSION "5.3")
141141

142142
set(SWIFT_VENDOR "" CACHE STRING
143143
"The vendor name of the Swift compiler")

include/swift/AST/Builtins.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ BUILTIN_CAST_OR_BITCAST_OPERATION(SExtOrBitCast, "sextOrBitCast", "n")
105105
#endif
106106

107107
#ifndef BUILTIN_BINARY_OPERATION_POLYMORPHIC
108-
#define BUILTIN_BINARY_OPERATION_POLYMORPHIC(Id, Name, Attrs) \
109-
BUILTIN_BINARY_OPERATION(Id, Name, Attrs)
108+
#define BUILTIN_BINARY_OPERATION_POLYMORPHIC(Id, Name) \
109+
BUILTIN_BINARY_OPERATION(Id, Name, "")
110110
#endif
111111

112112
// TODO: This needs a better name. We stringify generic_ in *_{OVERLOADED_STATIC,POLYMORPHIC}
113113
#ifndef BUILTIN_BINARY_OPERATION_ALL
114114
#define BUILTIN_BINARY_OPERATION_ALL(Id, Name, Attrs, Overload) \
115115
BUILTIN_BINARY_OPERATION_OVERLOADED_STATIC(Id, BUILTIN_BINARY_OPERATION_GENERIC_HELPER_STR(Name), Attrs, Overload) \
116-
BUILTIN_BINARY_OPERATION_POLYMORPHIC(Generic##Id, BUILTIN_BINARY_OPERATION_GENERIC_HELPER_STR(generic_##Name), Attrs)
116+
BUILTIN_BINARY_OPERATION_POLYMORPHIC(Generic##Id, BUILTIN_BINARY_OPERATION_GENERIC_HELPER_STR(generic_##Name))
117117
#endif
118118

119119
// NOTE: Here we need our name field to be bare. We stringify them as

lib/AST/Builtins.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ static const OverloadedBuiltinKind OverloadedBuiltinKinds[] = {
12141214
OverloadedBuiltinKind::Special,
12151215
#define BUILTIN_BINARY_OPERATION_OVERLOADED_STATIC(id, name, attrs, overload) \
12161216
OverloadedBuiltinKind::overload,
1217-
#define BUILTIN_BINARY_OPERATION_POLYMORPHIC(id, name, attrs) \
1217+
#define BUILTIN_BINARY_OPERATION_POLYMORPHIC(id, name) \
12181218
OverloadedBuiltinKind::Special,
12191219
#define BUILTIN_BINARY_OPERATION_WITH_OVERFLOW(id, name, _, attrs, overload) \
12201220
OverloadedBuiltinKind::overload,
@@ -1821,7 +1821,7 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
18211821

18221822
#define BUILTIN(id, name, attrs)
18231823
#define BUILTIN_BINARY_OPERATION(id, name, attrs)
1824-
#define BUILTIN_BINARY_OPERATION_POLYMORPHIC(id, name, attrs) \
1824+
#define BUILTIN_BINARY_OPERATION_POLYMORPHIC(id, name) \
18251825
case BuiltinValueKind::id:
18261826
#include "swift/AST/Builtins.def"
18271827
if (!Types.empty())
@@ -2096,7 +2096,7 @@ bool swift::isPolymorphicBuiltin(BuiltinValueKind id) {
20962096
#define BUILTIN(Id, Name, Attrs) \
20972097
case BuiltinValueKind::Id: \
20982098
return false;
2099-
#define BUILTIN_BINARY_OPERATION_POLYMORPHIC(Id, Name, Attrs) \
2099+
#define BUILTIN_BINARY_OPERATION_POLYMORPHIC(Id, Name) \
21002100
case BuiltinValueKind::Id: \
21012101
return true;
21022102
#include "swift/AST/Builtins.def"

lib/Driver/ToolChains.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,8 @@ class LLVM_LIBRARY_VISIBILITY GenericUnix : public ToolChain {
131131
/// platforms.
132132
virtual std::string getTargetForLinker() const;
133133

134-
/// Whether to specify a linker -rpath to the Swift runtime library path.
135-
/// -rpath is not supported on all platforms, and subclasses may override
136-
/// this method to return false on platforms that don't support it. The
137-
/// default is to return true (and so specify an -rpath).
138-
virtual bool shouldProvideRPathToLinker() const;
134+
bool addRuntimeRPath(const llvm::Triple &T,
135+
const llvm::opt::ArgList &Args) const;
139136

140137
InvocationInfo constructInvocation(const DynamicLinkJobAction &job,
141138
const JobContext &context) const override;
@@ -154,8 +151,6 @@ class LLVM_LIBRARY_VISIBILITY Android : public GenericUnix {
154151
protected:
155152
std::string getTargetForLinker() const override;
156153

157-
bool shouldProvideRPathToLinker() const override;
158-
159154
public:
160155
Android(const Driver &D, const llvm::Triple &Triple)
161156
: GenericUnix(D, Triple) {}

lib/Driver/UnixToolChains.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,30 @@ std::string toolchains::GenericUnix::getTargetForLinker() const {
110110
return getTriple().str();
111111
}
112112

113-
bool toolchains::GenericUnix::shouldProvideRPathToLinker() const {
114-
return true;
113+
bool toolchains::GenericUnix::addRuntimeRPath(const llvm::Triple &T,
114+
const llvm::opt::ArgList &Args) const {
115+
// If we are building a static executable, do not add a rpath for the runtime
116+
// as it is a static binary and the loader will not be invoked.
117+
if (Args.hasFlag(options::OPT_static_executable,
118+
options::OPT_no_static_executable, false))
119+
return false;
120+
121+
// If we are building with a static standard library, do not add a rpath for
122+
// the runtime because the runtime will be part of the binary and the rpath is
123+
// no longer necessary.
124+
if (Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
125+
false))
126+
return false;
127+
128+
// FIXME: We probably shouldn't be adding an rpath here unless we know ahead
129+
// of time the standard library won't be copied.
130+
131+
// Honour the user's request to add a rpath to the binary. This defaults to
132+
// `true` on non-android and `false` on android since the library must be
133+
// copied into the bundle.
134+
return Args.hasFlag(options::OPT_toolchain_stdlib_rpath,
135+
options::OPT_no_toolchain_stdlib_rpath,
136+
!T.isAndroid());
115137
}
116138

117139
ToolChain::InvocationInfo
@@ -209,9 +231,7 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
209231
getRuntimeLibraryPaths(RuntimeLibPaths, context.Args, context.OI.SDKPath,
210232
/*Shared=*/!(staticExecutable || staticStdlib));
211233

212-
if (!(staticExecutable || staticStdlib) && shouldProvideRPathToLinker()) {
213-
// FIXME: We probably shouldn't be adding an rpath here unless we know
214-
// ahead of time the standard library won't be copied.
234+
if (addRuntimeRPath(getTriple(), context.Args)) {
215235
for (auto path : RuntimeLibPaths) {
216236
Arguments.push_back("-Xlinker");
217237
Arguments.push_back("-rpath");
@@ -381,8 +401,6 @@ std::string toolchains::Android::getTargetForLinker() const {
381401
}
382402
}
383403

384-
bool toolchains::Android::shouldProvideRPathToLinker() const { return false; }
385-
386404
std::string toolchains::Cygwin::getDefaultLinker() const {
387405
// Cygwin uses the default BFD linker, even on ARM.
388406
return "";

lib/IRGen/GenBuiltin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
314314
llvm::Value *v = IGF.Builder.Create##id(lhs, rhs); \
315315
return out.add(v); \
316316
}
317-
#define BUILTIN_BINARY_OPERATION_POLYMORPHIC(id, name, attrs) \
317+
#define BUILTIN_BINARY_OPERATION_POLYMORPHIC(id, name) \
318318
if (Builtin.ID == BuiltinValueKind::id) { \
319319
/* This builtin must be guarded so that dynamically it is never called. */ \
320320
IGF.emitTrap("invalid use of polymorphic builtin", /*Unreachable*/ false); \

test/Driver/linker.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
// RUN: %swiftc_driver -driver-print-jobs -target thumbv7-unknown-linux-gnueabihf -Ffoo -Fsystem car -F cdr -framework bar -Lbaz -lboo -Xlinker -undefined %s 2>&1 > %t.linux.txt
2828
// RUN: %FileCheck -check-prefix LINUX-thumbv7 %s < %t.linux.txt
2929

30-
// RUN: %swiftc_driver -driver-print-jobs -target armv7-none-linux-androideabi -Ffoo -Fsystem car -F cdr -framework bar -Lbaz -lboo -Xlinker -undefined %s 2>&1 > %t.android.txt
30+
// RUN: %swiftc_driver_plain -driver-print-jobs -target armv7-none-linux-androideabi -Ffoo -Fsystem car -F cdr -framework bar -Lbaz -lboo -Xlinker -undefined %s 2>&1 > %t.android.txt
3131
// RUN: %FileCheck -check-prefix ANDROID-armv7 %s < %t.android.txt
3232
// RUN: %FileCheck -check-prefix ANDROID-armv7-NEGATIVE %s < %t.android.txt
3333

@@ -63,6 +63,12 @@
6363

6464
// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 -g %s | %FileCheck -check-prefix DEBUG %s
6565

66+
// RUN: %swiftc_driver_plain -driver-print-jobs -target x86_64-unknown-linux-gnu -toolchain-stdlib-rpath %s 2>&1 | %FileCheck -check-prefix LINUX-STDLIB-RPATH %s
67+
// RUN: %swiftc_driver_plain -driver-print-jobs -target x86_64-unknown-linux-gnu -no-toolchain-stdlib-rpath %s 2>&1 | %FileCheck -check-prefix LINUX-NO-STDLIB-RPATH %s
68+
69+
// RUN: %swiftc_driver_plain -driver-print-jobs -target armv7-unknown-linux-androideabi -toolchain-stdlib-rpath %s 2>&1 | %FileCheck -check-prefix ANDROID-STDLIB-RPATH %s
70+
// RUN: %swiftc_driver_plain -driver-print-jobs -target armv7-unknown-linux-androideabi -no-toolchain-stdlib-rpath %s 2>&1 | %FileCheck -check-prefix ANDROID-NO-STDLIB-RPATH %s
71+
6672
// RUN: %empty-directory(%t)
6773
// RUN: touch %t/a.o
6874
// RUN: touch %t/a.swiftmodule
@@ -428,6 +434,11 @@
428434
// RELATIVE_ARCLITE: {{/|\\\\}}DISTINCTIVE-PATH{{/|\\\\}}usr{{/|\\\\}}lib{{/|\\\\}}arc{{/|\\\\}}libarclite_macosx.a
429435
// RELATIVE_ARCLITE: -o {{[^ ]+}}
430436

437+
// LINUX-STDLIB-RPATH: -Xlinker -rpath -Xlinker [[STDLIB_PATH:[^ ]+(/|\\\\)lib(/|\\\\)swift(/|\\\\)linux]]
438+
// LINUX-NO-STDLIB-RPATH-NOT: -Xlinker -rpath -Xlinker [[STDLIB_PATH:[^ ]+(/|\\\\)lib(/|\\\\)swift(/|\\\\)linux]]
439+
440+
// ANDROID-STDLIB-RPATH: -Xlinker -rpath -Xlinker [[STDLIB_PATH:[^ ]+(/|\\\\)lib(/|\\\\)swift(/|\\\\)android]]
441+
// ANDROID-NO-STDLIB-RPATH-NOT: -Xlinker -rpath -Xlinker [[STDLIB_PATH:[^ ]+(/|\\\\)lib(/|\\\\)swift(/|\\\\)android]]
431442

432443
// Clean up the test executable because hard links are expensive.
433444
// RUN: rm -rf %t/DISTINCTIVE-PATH/usr/bin/swiftc

test/IRGen/objc.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class WeakObjC {
145145
// CHECK: i32 1, !"Objective-C Version", i32 2}
146146
// CHECK: i32 1, !"Objective-C Image Info Version", i32 0}
147147
// CHECK: i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"}
148-
// 84018944 == (5 << 24) | (2 << 16) | (7 << 8).
149-
// 5 and 2 is the current major.minor version. 7 is the Swift ABI version.
150-
// CHECK: i32 4, !"Objective-C Garbage Collection", i32 84018944}
148+
// 84084480 == (5 << 24) | (3 << 16) | (7 << 8).
149+
// 5 and 3 is the current major.minor version. 7 is the Swift ABI version.
150+
// CHECK: i32 4, !"Objective-C Garbage Collection", i32 84084480}
151151
// CHECK: i32 1, !"Swift Version", i32 7}

test/SILOptimizer/mandatory_combiner.sil

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,3 +888,33 @@ bb0:
888888
return %13 : $MyInt
889889
} // end sil function 'mixed_nocapture_mixedargs_ossa'
890890

891+
892+
// CHECK-LABEL: sil [ossa] @dont_remove_polymorphic_builtin
893+
// CHECK: builtin "generic_add"
894+
// CHECK-LABEL: end sil function 'dont_remove_polymorphic_builtin'
895+
sil [ossa] @dont_remove_polymorphic_builtin : $@convention(thin) (@guaranteed Klass, @guaranteed Klass, @guaranteed Klass) -> () {
896+
bb0(%0 : @guaranteed $Klass, %1 : @guaranteed $Klass, %2 : @guaranteed $Klass):
897+
%3 = alloc_stack $Klass
898+
%4 = copy_value %0 : $Klass
899+
store %4 to [init] %3 : $*Klass
900+
901+
%6 = alloc_stack $Klass
902+
%7 = copy_value %0 : $Klass
903+
store %7 to [init] %6 : $*Klass
904+
905+
%9 = alloc_stack $Klass
906+
%10 = copy_value %0 : $Klass
907+
store %10 to [init] %9 : $*Klass
908+
909+
// builtin "add" is maked read none so it could be removed below. However,
910+
// builtin "generic_add" does modify memory so, it cannot be removed.
911+
// Make sure we don't remove it.
912+
%12 = builtin "generic_add"<Klass>(%3 : $*Klass, %6 : $*Klass, %9 : $*Klass) : $()
913+
914+
dealloc_stack %9 : $*Klass
915+
dealloc_stack %6 : $*Klass
916+
dealloc_stack %3 : $*Klass
917+
918+
%9999 = tuple ()
919+
return %9999 : $()
920+
}

test/Serialization/Recovery/types-5-to-4.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import Lib
1616
func requiresConformance(_: B_RequiresConformance<B_ConformsToProto>) {}
1717
func requiresConformance(_: B_RequiresConformance<C_RelyOnConformanceImpl.Assoc>) {}
1818

19-
class Sub: Base {} // expected-error {{cannot inherit from class 'Base' (compiled with Swift 5.2) because it has overridable members that could not be loaded in Swift 4.1.50}}
20-
class Impl: Proto {} // expected-error {{type 'Impl' cannot conform to protocol 'Proto' (compiled with Swift 5.2) because it has requirements that could not be loaded in Swift 4.1.50}}
19+
class Sub: Base {} // expected-error {{cannot inherit from class 'Base' (compiled with Swift 5.3) because it has overridable members that could not be loaded in Swift 4.1.50}}
20+
class Impl: Proto {} // expected-error {{type 'Impl' cannot conform to protocol 'Proto' (compiled with Swift 5.3) because it has requirements that could not be loaded in Swift 4.1.50}}
2121

2222
#else // TEST
2323

0 commit comments

Comments
 (0)