Skip to content

Frontend: remove -emit-ldadd-cfile-path. NFC #38720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,6 @@ ERROR(tbd_not_supported_with_cmo,none,
"Test-Based InstallAPI (TBD) is not support with cross-module-optimization",
())

WARNING(linker_directives_choice_confusion,none,
"only one of -emit-ldadd-cfile-path and -module-installname-map-file can be specified;"
"the c file won't be generated",
())

ERROR(previous_installname_map_missing,none,
"cannot open previous install name map from %0",
(StringRef))
Expand Down
14 changes: 1 addition & 13 deletions include/swift/Basic/SupplementaryOutputPaths.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,6 @@ struct SupplementaryOutputPaths {
/// \sa ModuleInterfaceOutputPath
std::string PrivateModuleInterfaceOutputPath;

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

/// The path to which we should emit module summary file.
std::string ModuleSummaryOutputPath;

Expand Down Expand Up @@ -182,8 +172,6 @@ struct SupplementaryOutputPaths {
fn(ModuleInterfaceOutputPath);
if (!PrivateModuleInterfaceOutputPath.empty())
fn(PrivateModuleInterfaceOutputPath);
if (!LdAddCFilePath.empty())
fn(LdAddCFilePath);
if (!ModuleSummaryOutputPath.empty())
fn(ModuleSummaryOutputPath);
}
Expand All @@ -194,7 +182,7 @@ struct SupplementaryOutputPaths {
ReferenceDependenciesFilePath.empty() &&
SerializedDiagnosticsPath.empty() && LoadedModuleTracePath.empty() &&
TBDPath.empty() && ModuleInterfaceOutputPath.empty() &&
ModuleSourceInfoOutputPath.empty() && LdAddCFilePath.empty();
ModuleSourceInfoOutputPath.empty();
}
};
} // namespace swift
Expand Down
2 changes: 0 additions & 2 deletions include/swift/Frontend/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ class CompilerInvocation {
std::string getModuleInterfaceOutputPathForWholeModule() const;
std::string getPrivateModuleInterfaceOutputPathForWholeModule() const;

std::string getLdAddCFileOutputPathForWholeModule() const;

public:
/// Given the current configuration of this frontend invocation, a set of
/// supplementary output paths, and a module, compute the appropriate set of
Expand Down
4 changes: 0 additions & 4 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,6 @@ def type_info_dump_filter_EQ : Joined<["-"], "type-info-dump-filter=">,
Flags<[FrontendOption]>,
HelpText<"One of 'all', 'resilient' or 'fragile'">;

def emit_ldadd_cfile_path
: Separate<["-"], "emit-ldadd-cfile-path">, MetaVarName<"<path>">,
HelpText<"Generate .c file defining symbols to add back">;

def previous_module_installname_map_file
: Separate<["-"], "previous-module-installname-map-file">, MetaVarName<"<path>">,
HelpText<"Path to a Json file indicating module name to installname map for @_originallyDefinedIn">;
Expand Down
9 changes: 2 additions & 7 deletions lib/Frontend/ArgsToFrontendOutputsConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,13 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
options::OPT_emit_private_module_interface_path);
auto moduleSourceInfoOutput = getSupplementaryFilenamesFromArguments(
options::OPT_emit_module_source_info_path);
auto ldAddCFileOutput = getSupplementaryFilenamesFromArguments(
options::OPT_emit_ldadd_cfile_path);
auto moduleSummaryOutput = getSupplementaryFilenamesFromArguments(
options::OPT_emit_module_summary_path);
if (!objCHeaderOutput || !moduleOutput || !moduleDocOutput ||
!dependenciesFile || !referenceDependenciesFile ||
!serializedDiagnostics || !fixItsOutput || !loadedModuleTrace || !TBD ||
!moduleInterfaceOutput || !privateModuleInterfaceOutput ||
!moduleSourceInfoOutput || !ldAddCFileOutput || !moduleSummaryOutput) {
!moduleSourceInfoOutput || !moduleSummaryOutput) {
return None;
}
std::vector<SupplementaryOutputPaths> result;
Expand All @@ -366,7 +364,6 @@ SupplementaryOutputPathsComputer::getSupplementaryOutputPathsFromArguments()
sop.ModuleInterfaceOutputPath = (*moduleInterfaceOutput)[i];
sop.PrivateModuleInterfaceOutputPath = (*privateModuleInterfaceOutput)[i];
sop.ModuleSourceInfoOutputPath = (*moduleSourceInfoOutput)[i];
sop.LdAddCFilePath = (*ldAddCFileOutput)[i];
sop.ModuleSummaryOutputPath = (*moduleSummaryOutput)[i];
result.push_back(sop);
}
Expand Down Expand Up @@ -490,7 +487,6 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
sop.ModuleInterfaceOutputPath = ModuleInterfaceOutputPath;
sop.PrivateModuleInterfaceOutputPath = PrivateModuleInterfaceOutputPath;
sop.ModuleSourceInfoOutputPath = moduleSourceInfoOutputPath;
sop.LdAddCFilePath = pathsFromArguments.LdAddCFilePath;
sop.ModuleSummaryOutputPath = moduleSummaryOutputPath;
return sop;
}
Expand Down Expand Up @@ -596,8 +592,7 @@ SupplementaryOutputPathsComputer::readSupplementaryOutputFileMap() const {
options::OPT_emit_module_interface_path,
options::OPT_emit_private_module_interface_path,
options::OPT_emit_module_source_info_path,
options::OPT_emit_tbd_path,
options::OPT_emit_ldadd_cfile_path)) {
options::OPT_emit_tbd_path)) {
Diags.diagnose(SourceLoc(),
diag::error_cannot_have_supplementary_outputs,
A->getSpelling(), "-supplementary-output-file-map");
Expand Down
8 changes: 0 additions & 8 deletions lib/Frontend/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ std::string CompilerInvocation::getTBDPathForWholeModule() const {
.SupplementaryOutputs.TBDPath;
}

std::string
CompilerInvocation::getLdAddCFileOutputPathForWholeModule() const {
assert(getFrontendOptions().InputsAndOutputs.isWholeModule() &&
"LdAdd cfile only makes sense when the whole module can be seen");
return getPrimarySpecificPathsForAtMostOnePrimary()
.SupplementaryOutputs.LdAddCFilePath;
}

std::string
CompilerInvocation::getModuleInterfaceOutputPathForWholeModule() const {
assert(getFrontendOptions().InputsAndOutputs.isWholeModule() &&
Expand Down
60 changes: 0 additions & 60 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -682,63 +682,6 @@ static bool writeTBDIfNeeded(CompilerInstance &Instance) {
return writeTBD(Instance.getMainModule(), TBDPath, tbdOpts);
}

static std::string changeToLdAdd(StringRef ldHide) {
SmallString<64> SymbolBuffer;
llvm::raw_svector_ostream OS(SymbolBuffer);
auto Parts = ldHide.split("$hide$");
assert(!Parts.first.empty());
assert(!Parts.second.empty());
OS << Parts.first << "$add$" << Parts.second;
return OS.str().str();
}

static bool writeLdAddCFileIfNeeded(CompilerInstance &Instance) {
const auto &Invocation = Instance.getInvocation();
const auto &frontendOpts = Invocation.getFrontendOptions();
if (!frontendOpts.InputsAndOutputs.isWholeModule())
return false;
auto Path = Invocation.getLdAddCFileOutputPathForWholeModule();
if (Path.empty())
return false;
if (!frontendOpts.InputsAndOutputs.isWholeModule()) {
Instance.getDiags().diagnose(SourceLoc(),
diag::tbd_only_supported_in_whole_module);
return true;
}
if (!Invocation.getTBDGenOptions().ModuleInstallNameMapPath.empty()) {
Instance.getDiags().diagnose(SourceLoc(),
diag::linker_directives_choice_confusion);
return true;
}
auto tbdOpts = Invocation.getTBDGenOptions();
tbdOpts.LinkerDirectivesOnly = true;
auto *module = Instance.getMainModule();
auto ldSymbols =
getPublicSymbols(TBDGenDescriptor::forModule(module, tbdOpts));
std::error_code EC;
llvm::raw_fd_ostream OS(Path, EC, llvm::sys::fs::F_None);
if (EC) {
Instance.getDiags().diagnose(SourceLoc(), diag::error_opening_output, Path,
EC.message());
return true;
}
OS << "// Automatically generated C source file from the Swift compiler \n"
<< "// to add removed symbols back to the high-level framework for deployment\n"
<< "// targets prior to the OS version when these symbols were moved to\n"
<< "// a low-level framework " << module->getName().str() << ".\n\n";
unsigned Idx = 0;
for (auto &S: ldSymbols) {
SmallString<32> NameBuffer;
llvm::raw_svector_ostream NameOS(NameBuffer);
NameOS << "ldAdd_" << Idx;
OS << "extern const char " << NameOS.str() << " __asm(\"" <<
changeToLdAdd(S) << "\");\n";
OS << "const char " << NameOS.str() << " = 0;\n";
++ Idx;
}
return false;
}

static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
std::unique_ptr<SILModule> SM,
ModuleOrSourceFile MSF,
Expand Down Expand Up @@ -882,9 +825,6 @@ static bool emitAnyWholeModulePostTypeCheckSupplementaryOutputs(
{
hadAnyError |= writeTBDIfNeeded(Instance);
}
{
hadAnyError |= writeLdAddCFileIfNeeded(Instance);
}

return hadAnyError;
}
Expand Down
6 changes: 0 additions & 6 deletions test/TBD/linker-directives.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,3 @@ public func toast() {}

// CHECK-HAS-NOT-NOT: $ld$hide$os10.15$_$s10ToasterKit5toastyyF
// CHECK-HAS-NOT-NOT: $ld$hide$os10.7$_$s10ToasterKit5toastyyF

// 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
// RUN: %FileCheck %s --check-prefix CHECK-C-SYMBOL < %t/ldAdd.c

// CHECK-C-SYMBOL: $ld$add$os10.8$_$s10ToasterKit5toastyyF
// CHECK-C-SYMBOL: $ld$add$os10.14$_$s10ToasterKit5toastyyF