Skip to content

Commit 66a730b

Browse files
committed
[Embedded] Remove -mergeable-symbols
This option is no longer necessary, because we emit weak definitions for any imported modules. Fixes rdar://158364032.
1 parent 74e85c8 commit 66a730b

12 files changed

+24
-38
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,6 @@ class IRGenOptions {
498498
/// Internalize symbols (static library) - do not export any public symbols.
499499
unsigned InternalizeSymbols : 1;
500500

501-
unsigned MergeableSymbols : 1;
502-
503501
/// Emit a section with references to class_ro_t* in generic class patterns.
504502
unsigned EmitGenericRODatas : 1;
505503

@@ -645,7 +643,7 @@ class IRGenOptions {
645643
WitnessMethodElimination(false), ConditionalRuntimeRecords(false),
646644
AnnotateCondFailMessage(false),
647645
InternalizeAtLink(false), InternalizeSymbols(false),
648-
MergeableSymbols(false), EmitGenericRODatas(true),
646+
EmitGenericRODatas(true),
649647
NoPreallocatedInstantiationCaches(false),
650648
DisableReadonlyStaticObjects(false), CollocatedMetadataFunctions(false),
651649
ColocateTypeDescriptors(true), UseRelativeProtocolWitnessTables(false),

include/swift/IRGen/Linking.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,10 @@ class UniversalLinkageInfo {
5757
/// be promoted to public external. Used by the LLDB expression evaluator.
5858
bool ForcePublicDecls;
5959

60-
/// When true, allows duplicate external and hidden declarations by marking
61-
/// them as linkonce / weak.
62-
bool MergeableSymbols;
63-
6460
explicit UniversalLinkageInfo(IRGenModule &IGM);
6561

6662
UniversalLinkageInfo(const llvm::Triple &triple, bool hasMultipleIGMs,
67-
bool forcePublicDecls, bool isStaticLibrary,
68-
bool mergeableSymbols);
63+
bool forcePublicDecls, bool isStaticLibrary);
6964

7065
/// In case of multiple llvm modules (in multi-threaded compilation) all
7166
/// private decls must be visible from other files.

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3766,10 +3766,6 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
37663766

37673767
Opts.InternalizeSymbols = FrontendOpts.Static;
37683768

3769-
if (Args.hasArg(OPT_mergeable_symbols)) {
3770-
Opts.MergeableSymbols = true;
3771-
}
3772-
37733769
if (Args.hasArg(OPT_disable_preallocated_instantiation_caches)) {
37743770
Opts.NoPreallocatedInstantiationCaches = true;
37753771
}
@@ -3906,6 +3902,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
39063902

39073903
Opts.DebugCallsiteInfo |= Args.hasArg(OPT_debug_callsite_info);
39083904

3905+
if (Args.hasArg(OPT_mergeable_symbols))
3906+
Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated,
3907+
"-mergeable-symbols");
3908+
39093909
return false;
39103910
}
39113911

lib/IRGen/GenDecl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2332,8 +2332,6 @@ getIRLinkage(StringRef name, const UniversalLinkageInfo &info,
23322332

23332333
if (hasNonUniqueDefinition)
23342334
linkage = llvm::GlobalValue::WeakODRLinkage;
2335-
else if (info.MergeableSymbols)
2336-
linkage = llvm::GlobalValue::WeakODRLinkage;
23372335

23382336
return {linkage, PublicDefinitionVisibility,
23392337
info.Internalize ? llvm::GlobalValue::DefaultStorageClass
@@ -2352,8 +2350,6 @@ getIRLinkage(StringRef name, const UniversalLinkageInfo &info,
23522350
case SILLinkage::Hidden:
23532351
if (hasNonUniqueDefinition)
23542352
return RESULT(WeakODR, Hidden, Default);
2355-
if (info.MergeableSymbols)
2356-
return RESULT(WeakODR, Hidden, Default);
23572353

23582354
return RESULT(External, Hidden, Default);
23592355

lib/IRGen/Linking.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,16 @@ bool swift::irgen::useDllStorage(const llvm::Triple &triple) {
8282
UniversalLinkageInfo::UniversalLinkageInfo(IRGenModule &IGM)
8383
: UniversalLinkageInfo(IGM.Triple, IGM.IRGen.hasMultipleIGMs(),
8484
IGM.IRGen.Opts.ForcePublicLinkage,
85-
IGM.IRGen.Opts.InternalizeSymbols,
86-
IGM.IRGen.Opts.MergeableSymbols) {}
85+
IGM.IRGen.Opts.InternalizeSymbols) {}
8786

8887
UniversalLinkageInfo::UniversalLinkageInfo(const llvm::Triple &triple,
8988
bool hasMultipleIGMs,
9089
bool forcePublicDecls,
91-
bool isStaticLibrary,
92-
bool mergeableSymbols)
90+
bool isStaticLibrary)
9391
: IsELFObject(triple.isOSBinFormatELF()),
9492
IsMSVCEnvironment(triple.isWindowsMSVCEnvironment()),
9593
UseDLLStorage(useDllStorage(triple)), Internalize(isStaticLibrary),
96-
HasMultipleIGMs(hasMultipleIGMs), ForcePublicDecls(forcePublicDecls),
97-
MergeableSymbols(mergeableSymbols) {}
94+
HasMultipleIGMs(hasMultipleIGMs), ForcePublicDecls(forcePublicDecls) {}
9895

9996
LinkEntity LinkEntity::forSILGlobalVariable(SILGlobalVariable *G,
10097
IRGenModule &IGM) {

lib/IRGen/TBDGenVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class TBDGenVisitor : public IRSymbolVisitor {
124124
APIRecorder &recorder)
125125
: DataLayoutDescription(dataLayoutString),
126126
UniversalLinkInfo(target, opts.HasMultipleIGMs, /*forcePublic*/ false,
127-
/*static=*/false, /*mergeableSymbols*/false),
127+
/*static=*/false),
128128
SwiftModule(swiftModule), Opts(opts), recorder(recorder),
129129
previousInstallNameMap(parsePreviousModuleInstallNameMap()) {}
130130

test/embedded/linkage-custom-entry-point.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-frontend %s -module-name Application -parse-as-library -entry-point-function-name Application_main -mergeable-symbols -enable-experimental-feature Embedded -emit-ir | %FileCheck %s
2-
// RUN: %target-swift-frontend %s -module-name Application -parse-as-library -entry-point-function-name Application_main -mergeable-symbols -O -enable-experimental-feature Embedded -emit-ir | %FileCheck %s
1+
// RUN: %target-swift-frontend %s -module-name Application -parse-as-library -entry-point-function-name Application_main -enable-experimental-feature Embedded -emit-ir | %FileCheck %s
2+
// RUN: %target-swift-frontend %s -module-name Application -parse-as-library -entry-point-function-name Application_main -O -enable-experimental-feature Embedded -emit-ir | %FileCheck %s
33

44
// REQUIRES: swift_in_compiler
55
// REQUIRES: swift_feature_Embedded

test/embedded/linkage-mergeable-dead-strip.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %empty-directory(%t)
22

3-
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enable-experimental-feature SymbolLinkageMarkers -module-name main -mergeable-symbols -O %s -emit-ir | %FileCheck %s --check-prefix=CHECK-IR
4-
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enable-experimental-feature SymbolLinkageMarkers -module-name main -mergeable-symbols -O %s -c -o %t/a.o
3+
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enable-experimental-feature SymbolLinkageMarkers -module-name main -O %s -emit-ir | %FileCheck %s --check-prefix=CHECK-IR
4+
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enable-experimental-feature SymbolLinkageMarkers -module-name main -O %s -c -o %t/a.o
55
// RUN: %target-clang %target-clang-resource-dir-opt %t/a.o -o %t/a.out -dead_strip
66
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | sort | %FileCheck %s --check-prefix=CHECK-NM
77
// RUN: %target-run %t/a.out | %FileCheck %s
@@ -16,8 +16,8 @@ public func a_this_is_unused() { }
1616
@_used
1717
public func b_this_is_unused_but_explicitly_retained() { }
1818

19-
// CHECK-IR: define weak_odr {{.*}}@"$e4main16a_this_is_unusedyyF"()
20-
// CHECK-IR: define weak_odr {{.*}}@"$e4main40b_this_is_unused_but_explicitly_retainedyyF"()
19+
// CHECK-IR: define {{.*}}@"$e4main16a_this_is_unusedyyF"()
20+
// CHECK-IR: define {{.*}}@"$e4main40b_this_is_unused_but_explicitly_retainedyyF"()
2121

2222
// CHECK-NM-NOT: $e4main14this_is_unusedyyF
2323
// CHECK-NM: $e4main40b_this_is_unused_but_explicitly_retainedyyF

test/embedded/linkage-mergeable.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %{python} %utils/split_file.py -o %t %s
33

4-
// RUN: %target-swift-frontend -mergeable-symbols -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
5-
// RUN: %target-swift-frontend -mergeable-symbols -c -o %t/a.o %t/Main.swift -I %t -enable-experimental-feature Embedded
4+
// RUN: %target-swift-frontend -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
5+
// RUN: %target-swift-frontend -c -o %t/a.o %t/Main.swift -I %t -enable-experimental-feature Embedded
66
// RUN: %target-clang %target-clang-resource-dir-opt %t/a.o %t/MyModule.o -o %t/a.out
77
// RUN: %target-run %t/a.out | %FileCheck %s
88

test/embedded/linkage-mergeable2.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %{python} %utils/split_file.py -o %t %s
33

4-
// RUN: %target-swift-frontend -mergeable-symbols -O -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
5-
// RUN: %target-swift-frontend -mergeable-symbols -O -c -o %t/a.o %t/Main.swift -I %t -enable-experimental-feature Embedded
4+
// RUN: %target-swift-frontend -O -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
5+
// RUN: %target-swift-frontend -O -c -o %t/a.o %t/Main.swift -I %t -enable-experimental-feature Embedded
66
// RUN: %target-clang %target-clang-resource-dir-opt %t/a.o %t/MyModule.o -o %t/a.out
77
// RUN: %target-run %t/a.out | %FileCheck %s
88

0 commit comments

Comments
 (0)