Skip to content

Commit 5b14bf9

Browse files
authored
Merge pull request #38720 from nkcsgexi/remove-ld-add
Frontend: remove -emit-ldadd-cfile-path. NFC
2 parents b7a4822 + 9a7ac2c commit 5b14bf9

File tree

8 files changed

+3
-105
lines changed

8 files changed

+3
-105
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,6 @@ ERROR(tbd_not_supported_with_cmo,none,
251251
"Test-Based InstallAPI (TBD) is not support with cross-module-optimization",
252252
())
253253

254-
WARNING(linker_directives_choice_confusion,none,
255-
"only one of -emit-ldadd-cfile-path and -module-installname-map-file can be specified;"
256-
"the c file won't be generated",
257-
())
258-
259254
ERROR(previous_installname_map_missing,none,
260255
"cannot open previous install name map from %0",
261256
(StringRef))

include/swift/Basic/SupplementaryOutputPaths.h

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,16 +140,6 @@ struct SupplementaryOutputPaths {
140140
/// \sa ModuleInterfaceOutputPath
141141
std::string PrivateModuleInterfaceOutputPath;
142142

143-
/// The path to a .c file where we should declare $ld$add symbols for those
144-
/// symbols moved to the current module.
145-
/// When symbols are moved to this module, this module declares them as HIDE
146-
/// for the OS versions prior to when the move happened. On the other hand, the
147-
/// original module should ADD them for these OS versions. An executable
148-
/// can choose the right library to link against depending on the deployment target.
149-
/// This is a walk-around that linker directives cannot specify other install
150-
/// name per symbol, we should eventually remove this.
151-
std::string LdAddCFilePath;
152-
153143
/// The path to which we should emit module summary file.
154144
std::string ModuleSummaryOutputPath;
155145

@@ -182,8 +172,6 @@ struct SupplementaryOutputPaths {
182172
fn(ModuleInterfaceOutputPath);
183173
if (!PrivateModuleInterfaceOutputPath.empty())
184174
fn(PrivateModuleInterfaceOutputPath);
185-
if (!LdAddCFilePath.empty())
186-
fn(LdAddCFilePath);
187175
if (!ModuleSummaryOutputPath.empty())
188176
fn(ModuleSummaryOutputPath);
189177
}
@@ -194,7 +182,7 @@ struct SupplementaryOutputPaths {
194182
ReferenceDependenciesFilePath.empty() &&
195183
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
196184
TBDPath.empty() && ModuleInterfaceOutputPath.empty() &&
197-
ModuleSourceInfoOutputPath.empty() && LdAddCFilePath.empty();
185+
ModuleSourceInfoOutputPath.empty();
198186
}
199187
};
200188
} // namespace swift

include/swift/Frontend/Frontend.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,6 @@ class CompilerInvocation {
391391
std::string getModuleInterfaceOutputPathForWholeModule() const;
392392
std::string getPrivateModuleInterfaceOutputPathForWholeModule() const;
393393

394-
std::string getLdAddCFileOutputPathForWholeModule() const;
395-
396394
public:
397395
/// Given the current configuration of this frontend invocation, a set of
398396
/// supplementary output paths, and a module, compute the appropriate set of

include/swift/Option/FrontendOptions.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,6 @@ def type_info_dump_filter_EQ : Joined<["-"], "type-info-dump-filter=">,
787787
Flags<[FrontendOption]>,
788788
HelpText<"One of 'all', 'resilient' or 'fragile'">;
789789

790-
def emit_ldadd_cfile_path
791-
: Separate<["-"], "emit-ldadd-cfile-path">, MetaVarName<"<path>">,
792-
HelpText<"Generate .c file defining symbols to add back">;
793-
794790
def previous_module_installname_map_file
795791
: Separate<["-"], "previous-module-installname-map-file">, MetaVarName<"<path>">,
796792
HelpText<"Path to a Json file indicating module name to installname map for @_originallyDefinedIn">;

lib/Frontend/ArgsToFrontendOutputsConverter.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,13 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
337337
options::OPT_emit_private_module_interface_path);
338338
auto moduleSourceInfoOutput = getSupplementaryFilenamesFromArguments(
339339
options::OPT_emit_module_source_info_path);
340-
auto ldAddCFileOutput = getSupplementaryFilenamesFromArguments(
341-
options::OPT_emit_ldadd_cfile_path);
342340
auto moduleSummaryOutput = getSupplementaryFilenamesFromArguments(
343341
options::OPT_emit_module_summary_path);
344342
if (!objCHeaderOutput || !moduleOutput || !moduleDocOutput ||
345343
!dependenciesFile || !referenceDependenciesFile ||
346344
!serializedDiagnostics || !fixItsOutput || !loadedModuleTrace || !TBD ||
347345
!moduleInterfaceOutput || !privateModuleInterfaceOutput ||
348-
!moduleSourceInfoOutput || !ldAddCFileOutput || !moduleSummaryOutput) {
346+
!moduleSourceInfoOutput || !moduleSummaryOutput) {
349347
return None;
350348
}
351349
std::vector<SupplementaryOutputPaths> result;
@@ -366,7 +364,6 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
366364
sop.ModuleInterfaceOutputPath = (*moduleInterfaceOutput)[i];
367365
sop.PrivateModuleInterfaceOutputPath = (*privateModuleInterfaceOutput)[i];
368366
sop.ModuleSourceInfoOutputPath = (*moduleSourceInfoOutput)[i];
369-
sop.LdAddCFilePath = (*ldAddCFileOutput)[i];
370367
sop.ModuleSummaryOutputPath = (*moduleSummaryOutput)[i];
371368
result.push_back(sop);
372369
}
@@ -490,7 +487,6 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
490487
sop.ModuleInterfaceOutputPath = ModuleInterfaceOutputPath;
491488
sop.PrivateModuleInterfaceOutputPath = PrivateModuleInterfaceOutputPath;
492489
sop.ModuleSourceInfoOutputPath = moduleSourceInfoOutputPath;
493-
sop.LdAddCFilePath = pathsFromArguments.LdAddCFilePath;
494490
sop.ModuleSummaryOutputPath = moduleSummaryOutputPath;
495491
return sop;
496492
}
@@ -596,8 +592,7 @@ SupplementaryOutputPathsComputer::readSupplementaryOutputFileMap() const {
596592
options::OPT_emit_module_interface_path,
597593
options::OPT_emit_private_module_interface_path,
598594
options::OPT_emit_module_source_info_path,
599-
options::OPT_emit_tbd_path,
600-
options::OPT_emit_ldadd_cfile_path)) {
595+
options::OPT_emit_tbd_path)) {
601596
Diags.diagnose(SourceLoc(),
602597
diag::error_cannot_have_supplementary_outputs,
603598
A->getSpelling(), "-supplementary-output-file-map");

lib/Frontend/Frontend.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,6 @@ std::string CompilerInvocation::getTBDPathForWholeModule() const {
116116
.SupplementaryOutputs.TBDPath;
117117
}
118118

119-
std::string
120-
CompilerInvocation::getLdAddCFileOutputPathForWholeModule() const {
121-
assert(getFrontendOptions().InputsAndOutputs.isWholeModule() &&
122-
"LdAdd cfile only makes sense when the whole module can be seen");
123-
return getPrimarySpecificPathsForAtMostOnePrimary()
124-
.SupplementaryOutputs.LdAddCFilePath;
125-
}
126-
127119
std::string
128120
CompilerInvocation::getModuleInterfaceOutputPathForWholeModule() const {
129121
assert(getFrontendOptions().InputsAndOutputs.isWholeModule() &&

lib/FrontendTool/FrontendTool.cpp

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -682,63 +682,6 @@ static bool writeTBDIfNeeded(CompilerInstance &Instance) {
682682
return writeTBD(Instance.getMainModule(), TBDPath, tbdOpts);
683683
}
684684

685-
static std::string changeToLdAdd(StringRef ldHide) {
686-
SmallString<64> SymbolBuffer;
687-
llvm::raw_svector_ostream OS(SymbolBuffer);
688-
auto Parts = ldHide.split("$hide$");
689-
assert(!Parts.first.empty());
690-
assert(!Parts.second.empty());
691-
OS << Parts.first << "$add$" << Parts.second;
692-
return OS.str().str();
693-
}
694-
695-
static bool writeLdAddCFileIfNeeded(CompilerInstance &Instance) {
696-
const auto &Invocation = Instance.getInvocation();
697-
const auto &frontendOpts = Invocation.getFrontendOptions();
698-
if (!frontendOpts.InputsAndOutputs.isWholeModule())
699-
return false;
700-
auto Path = Invocation.getLdAddCFileOutputPathForWholeModule();
701-
if (Path.empty())
702-
return false;
703-
if (!frontendOpts.InputsAndOutputs.isWholeModule()) {
704-
Instance.getDiags().diagnose(SourceLoc(),
705-
diag::tbd_only_supported_in_whole_module);
706-
return true;
707-
}
708-
if (!Invocation.getTBDGenOptions().ModuleInstallNameMapPath.empty()) {
709-
Instance.getDiags().diagnose(SourceLoc(),
710-
diag::linker_directives_choice_confusion);
711-
return true;
712-
}
713-
auto tbdOpts = Invocation.getTBDGenOptions();
714-
tbdOpts.LinkerDirectivesOnly = true;
715-
auto *module = Instance.getMainModule();
716-
auto ldSymbols =
717-
getPublicSymbols(TBDGenDescriptor::forModule(module, tbdOpts));
718-
std::error_code EC;
719-
llvm::raw_fd_ostream OS(Path, EC, llvm::sys::fs::F_None);
720-
if (EC) {
721-
Instance.getDiags().diagnose(SourceLoc(), diag::error_opening_output, Path,
722-
EC.message());
723-
return true;
724-
}
725-
OS << "// Automatically generated C source file from the Swift compiler \n"
726-
<< "// to add removed symbols back to the high-level framework for deployment\n"
727-
<< "// targets prior to the OS version when these symbols were moved to\n"
728-
<< "// a low-level framework " << module->getName().str() << ".\n\n";
729-
unsigned Idx = 0;
730-
for (auto &S: ldSymbols) {
731-
SmallString<32> NameBuffer;
732-
llvm::raw_svector_ostream NameOS(NameBuffer);
733-
NameOS << "ldAdd_" << Idx;
734-
OS << "extern const char " << NameOS.str() << " __asm(\"" <<
735-
changeToLdAdd(S) << "\");\n";
736-
OS << "const char " << NameOS.str() << " = 0;\n";
737-
++ Idx;
738-
}
739-
return false;
740-
}
741-
742685
static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
743686
std::unique_ptr<SILModule> SM,
744687
ModuleOrSourceFile MSF,
@@ -882,9 +825,6 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
882825
{
883826
hadAnyError |= writeTBDIfNeeded(Instance);
884827
}
885-
{
886-
hadAnyError |= writeLdAddCFileIfNeeded(Instance);
887-
}
888828

889829
return hadAnyError;
890830
}

test/TBD/linker-directives.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,3 @@ public func toast() {}
1717

1818
// CHECK-HAS-NOT-NOT: $ld$hide$os10.15$_$s10ToasterKit5toastyyF
1919
// CHECK-HAS-NOT-NOT: $ld$hide$os10.7$_$s10ToasterKit5toastyyF
20-
21-
// RUN: %target-swift-frontend -typecheck %s -emit-tbd -emit-tbd-path %t/linker_directives.tbd -emit-ldadd-cfile-path %t/ldAdd.c -module-name AppKit
22-
// RUN: %FileCheck %s --check-prefix CHECK-C-SYMBOL < %t/ldAdd.c
23-
24-
// CHECK-C-SYMBOL: $ld$add$os10.8$_$s10ToasterKit5toastyyF
25-
// CHECK-C-SYMBOL: $ld$add$os10.14$_$s10ToasterKit5toastyyF

0 commit comments

Comments
 (0)