Skip to content
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
2 changes: 0 additions & 2 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ ERROR(error_immediate_mode_missing_library,none,
(unsigned, StringRef))
ERROR(error_immediate_mode_primary_file,none,
"immediate mode is incompatible with -primary-file", ())
WARNING(warning_immediate_mode_cannot_load_foundation,none,
"immediate mode failed to load Foundation: %0", (StringRef))
ERROR(error_missing_frontend_action,none,
"no frontend action was selected", ())
ERROR(error_invalid_source_location_str,none,
Expand Down
4 changes: 0 additions & 4 deletions include/swift/Immediate/Immediate.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

namespace swift {
class CompilerInstance;
class DiagnosticEngine;
class IRGenOptions;
class SILOptions;
class SILModule;
Expand All @@ -45,9 +44,6 @@ namespace swift {

int RunImmediatelyFromAST(CompilerInstance &CI);

/// On platforms that support ObjC bridging from the Foundation framework,
/// ensure that Foundation is loaded early enough. Otherwise does nothing.
void loadFoundationIfNeeded(DiagnosticEngine &Diags);
} // end namespace swift

#endif // SWIFT_IMMEDIATE_IMMEDIATE_H
7 changes: 0 additions & 7 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1955,13 +1955,6 @@ int swift::performFrontend(ArrayRef<const char *> Args,
return finishDiagProcessing(1, /*verifierEnabled*/ false);
}

// Scripts that use the Foundation framework need it loaded early for bridging
// to work correctly on Darwin platforms. On other platforms this is a no-op.
if (Invocation.getFrontendOptions().RequestedAction ==
FrontendOptions::ActionType::Immediate) {
loadFoundationIfNeeded(Instance->getDiags());
}

// Don't ask clients to report bugs when running a script in immediate mode.
// When a script asserts the compiler reports the error with the same
// stacktrace as a compiler crash. From here we can't tell which is which,
Expand Down
27 changes: 0 additions & 27 deletions lib/Immediate/Immediate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,30 +432,3 @@ int swift::RunImmediatelyFromAST(CompilerInstance &CI) {

return *Result;
}

void swift::loadFoundationIfNeeded(DiagnosticEngine &Diags) {
#if defined(__APPLE__)
const char *FoundationPath =
"/System/Library/Frameworks/Foundation.framework/Foundation";
void *handle = dlopen(FoundationPath, RTLD_NOLOAD);
if (handle) {
// Foundation is already loaded. Use dlclose to release the ref-count that
// was incremented by dlopen and return.
dlclose(handle);
return;
} else {
// Foundation is not yet loaded. Load it now and leak the handle.
// FIXME: it is fragile to load here, as there is no guarantee the swift
// runtime has not initialized already. As the compiler adds more swift code
// we may need to move this or find another solution.
handle = dlopen(FoundationPath, RTLD_LAZY | RTLD_GLOBAL);
if (!handle)
Diags.diagnose(SourceLoc(),
diag::warning_immediate_mode_cannot_load_foundation,
dlerror());
}

#else
// Nothing to do.
#endif
}
25 changes: 0 additions & 25 deletions test/Interpreter/foundation-bridge-error.swift

This file was deleted.