[Embedded] Remove -mergeable-symbols

This option is no longer necessary, because we emit weak definitions
for any imported modules. Fixes rdar://158364032.
This commit is contained in:
Doug Gregor
2025-09-08 17:40:56 -07:00
parent 74e85c8416
commit 66a730b638
12 changed files with 24 additions and 38 deletions

View File

@@ -498,8 +498,6 @@ public:
/// Internalize symbols (static library) - do not export any public symbols.
unsigned InternalizeSymbols : 1;
unsigned MergeableSymbols : 1;
/// Emit a section with references to class_ro_t* in generic class patterns.
unsigned EmitGenericRODatas : 1;
@@ -645,7 +643,7 @@ public:
WitnessMethodElimination(false), ConditionalRuntimeRecords(false),
AnnotateCondFailMessage(false),
InternalizeAtLink(false), InternalizeSymbols(false),
MergeableSymbols(false), EmitGenericRODatas(true),
EmitGenericRODatas(true),
NoPreallocatedInstantiationCaches(false),
DisableReadonlyStaticObjects(false), CollocatedMetadataFunctions(false),
ColocateTypeDescriptors(true), UseRelativeProtocolWitnessTables(false),

View File

@@ -57,15 +57,10 @@ public:
/// be promoted to public external. Used by the LLDB expression evaluator.
bool ForcePublicDecls;
/// When true, allows duplicate external and hidden declarations by marking
/// them as linkonce / weak.
bool MergeableSymbols;
explicit UniversalLinkageInfo(IRGenModule &IGM);
UniversalLinkageInfo(const llvm::Triple &triple, bool hasMultipleIGMs,
bool forcePublicDecls, bool isStaticLibrary,
bool mergeableSymbols);
bool forcePublicDecls, bool isStaticLibrary);
/// In case of multiple llvm modules (in multi-threaded compilation) all
/// private decls must be visible from other files.

View File

@@ -3766,10 +3766,6 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
Opts.InternalizeSymbols = FrontendOpts.Static;
if (Args.hasArg(OPT_mergeable_symbols)) {
Opts.MergeableSymbols = true;
}
if (Args.hasArg(OPT_disable_preallocated_instantiation_caches)) {
Opts.NoPreallocatedInstantiationCaches = true;
}
@@ -3906,6 +3902,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
Opts.DebugCallsiteInfo |= Args.hasArg(OPT_debug_callsite_info);
if (Args.hasArg(OPT_mergeable_symbols))
Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated,
"-mergeable-symbols");
return false;
}

View File

@@ -2332,8 +2332,6 @@ getIRLinkage(StringRef name, const UniversalLinkageInfo &info,
if (hasNonUniqueDefinition)
linkage = llvm::GlobalValue::WeakODRLinkage;
else if (info.MergeableSymbols)
linkage = llvm::GlobalValue::WeakODRLinkage;
return {linkage, PublicDefinitionVisibility,
info.Internalize ? llvm::GlobalValue::DefaultStorageClass
@@ -2352,8 +2350,6 @@ getIRLinkage(StringRef name, const UniversalLinkageInfo &info,
case SILLinkage::Hidden:
if (hasNonUniqueDefinition)
return RESULT(WeakODR, Hidden, Default);
if (info.MergeableSymbols)
return RESULT(WeakODR, Hidden, Default);
return RESULT(External, Hidden, Default);

View File

@@ -82,19 +82,16 @@ bool swift::irgen::useDllStorage(const llvm::Triple &triple) {
UniversalLinkageInfo::UniversalLinkageInfo(IRGenModule &IGM)
: UniversalLinkageInfo(IGM.Triple, IGM.IRGen.hasMultipleIGMs(),
IGM.IRGen.Opts.ForcePublicLinkage,
IGM.IRGen.Opts.InternalizeSymbols,
IGM.IRGen.Opts.MergeableSymbols) {}
IGM.IRGen.Opts.InternalizeSymbols) {}
UniversalLinkageInfo::UniversalLinkageInfo(const llvm::Triple &triple,
bool hasMultipleIGMs,
bool forcePublicDecls,
bool isStaticLibrary,
bool mergeableSymbols)
bool isStaticLibrary)
: IsELFObject(triple.isOSBinFormatELF()),
IsMSVCEnvironment(triple.isWindowsMSVCEnvironment()),
UseDLLStorage(useDllStorage(triple)), Internalize(isStaticLibrary),
HasMultipleIGMs(hasMultipleIGMs), ForcePublicDecls(forcePublicDecls),
MergeableSymbols(mergeableSymbols) {}
HasMultipleIGMs(hasMultipleIGMs), ForcePublicDecls(forcePublicDecls) {}
LinkEntity LinkEntity::forSILGlobalVariable(SILGlobalVariable *G,
IRGenModule &IGM) {

View File

@@ -124,7 +124,7 @@ public:
APIRecorder &recorder)
: DataLayoutDescription(dataLayoutString),
UniversalLinkInfo(target, opts.HasMultipleIGMs, /*forcePublic*/ false,
/*static=*/false, /*mergeableSymbols*/false),
/*static=*/false),
SwiftModule(swiftModule), Opts(opts), recorder(recorder),
previousInstallNameMap(parsePreviousModuleInstallNameMap()) {}

View File

@@ -1,5 +1,5 @@
// 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
// 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
// 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
// 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
// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_Embedded

View File

@@ -1,7 +1,7 @@
// RUN: %empty-directory(%t)
// 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
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enable-experimental-feature SymbolLinkageMarkers -module-name main -mergeable-symbols -O %s -c -o %t/a.o
// 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
// RUN: %target-swift-frontend -enable-experimental-feature Embedded -enable-experimental-feature SymbolLinkageMarkers -module-name main -O %s -c -o %t/a.o
// RUN: %target-clang %target-clang-resource-dir-opt %t/a.o -o %t/a.out -dead_strip
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | sort | %FileCheck %s --check-prefix=CHECK-NM
// RUN: %target-run %t/a.out | %FileCheck %s
@@ -16,8 +16,8 @@ public func a_this_is_unused() { }
@_used
public func b_this_is_unused_but_explicitly_retained() { }
// CHECK-IR: define weak_odr {{.*}}@"$e4main16a_this_is_unusedyyF"()
// CHECK-IR: define weak_odr {{.*}}@"$e4main40b_this_is_unused_but_explicitly_retainedyyF"()
// CHECK-IR: define {{.*}}@"$e4main16a_this_is_unusedyyF"()
// CHECK-IR: define {{.*}}@"$e4main40b_this_is_unused_but_explicitly_retainedyyF"()
// CHECK-NM-NOT: $e4main14this_is_unusedyyF
// CHECK-NM: $e4main40b_this_is_unused_but_explicitly_retainedyyF

View File

@@ -1,8 +1,8 @@
// RUN: %empty-directory(%t)
// RUN: %{python} %utils/split_file.py -o %t %s
// RUN: %target-swift-frontend -mergeable-symbols -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
// RUN: %target-swift-frontend -mergeable-symbols -c -o %t/a.o %t/Main.swift -I %t -enable-experimental-feature Embedded
// RUN: %target-swift-frontend -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
// RUN: %target-swift-frontend -c -o %t/a.o %t/Main.swift -I %t -enable-experimental-feature Embedded
// RUN: %target-clang %target-clang-resource-dir-opt %t/a.o %t/MyModule.o -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s

View File

@@ -1,8 +1,8 @@
// RUN: %empty-directory(%t)
// RUN: %{python} %utils/split_file.py -o %t %s
// RUN: %target-swift-frontend -mergeable-symbols -O -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
// RUN: %target-swift-frontend -mergeable-symbols -O -c -o %t/a.o %t/Main.swift -I %t -enable-experimental-feature Embedded
// RUN: %target-swift-frontend -O -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
// RUN: %target-swift-frontend -O -c -o %t/a.o %t/Main.swift -I %t -enable-experimental-feature Embedded
// RUN: %target-clang %target-clang-resource-dir-opt %t/a.o %t/MyModule.o -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s

View File

@@ -1,8 +1,8 @@
// RUN: %empty-directory(%t)
// RUN: %{python} %utils/split_file.py -o %t %s
// RUN: %target-swift-frontend -mergeable-symbols -num-threads 2 -O -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
// RUN: %target-swift-frontend -mergeable-symbols -num-threads 2 -O -c -o %t/MainA.o -o %t/MainB.o %t/MainA.swift %t/MainB.swift -I %t -enable-experimental-feature Embedded -parse-as-library
// RUN: %target-swift-frontend -num-threads 2 -O -c -emit-module -o %t/MyModule.o %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
// RUN: %target-swift-frontend -num-threads 2 -O -c -o %t/MainA.o -o %t/MainB.o %t/MainA.swift %t/MainB.swift -I %t -enable-experimental-feature Embedded -parse-as-library
// RUN: %target-clang %target-clang-resource-dir-opt %t/MainA.o %t/MainB.o %t/MyModule.o -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s

View File

@@ -1,5 +1,5 @@
// RUN: %target-swift-frontend %s -mergeable-symbols -enable-experimental-feature Embedded -emit-ir | %FileCheck %s
// RUN: %target-swift-frontend %s -mergeable-symbols -O -enable-experimental-feature Embedded -emit-ir | %FileCheck %s
// RUN: %target-swift-frontend %s -enable-experimental-feature Embedded -emit-ir | %FileCheck %s
// RUN: %target-swift-frontend %s -O -enable-experimental-feature Embedded -emit-ir | %FileCheck %s
// REQUIRES: swift_in_compiler
// REQUIRES: swift_feature_Embedded