Skip to content

IRGen: don't proceed to IRGen if collecting linker directives failed #29369

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
Jan 23, 2020
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
3 changes: 3 additions & 0 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,9 @@ static bool performCompileStepsPostSILGen(

llvm::StringSet<> LinkerDirectives;
collectLinkerDirectives(Invocation, MSF, LinkerDirectives);
// Don't proceed to IRGen if collecting linker directives failed.
if (Context.hadError())
return true;
StringRef OutputFilename = PSPs.OutputFilename;
std::vector<std::string> ParallelOutputFilenames =
Invocation.getFrontendOptions().InputsAndOutputs.copyOutputFilenames();
Expand Down
22 changes: 22 additions & 0 deletions test/IRGen/original-defined-attr-linker-directives-fail.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// REQUIRES: OS=macosx
// RUN: %empty-directory(%t)
// RUN: echo '[ { "module": "OriginalModule", "platforms": ["macOS"], "install_name": "/System/OriginalModule.dylib"} ]' > %t/install-name.json
// RUN: %target-swift-frontend -swift-version 4 -enforce-exclusivity=checked %s -emit-ir -module-name CurrentModule -D CURRENT_MODULE -previous-module-installname-map-file %t/install-name.json | %FileCheck %s -check-prefix=CHECK-SYMBOLS

// RUN: NOT %target-swift-frontend -swift-version 4 -enforce-exclusivity=checked %s -emit-ir -module-name CurrentModule -D CURRENT_MODULE -previous-module-installname-map-file %t/nil.json >& %t/error.txt
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR < %t/error.txt

@available(OSX 10.8, *)
@_originallyDefinedIn(module: "OriginalModule", macOS 10.10)
public struct Entity {
public func addEntity(_ e: Entity) {}
public func removeEntity(_ e: Entity) {}
}

// CHECK-SYMBOLS: $ld$previous$/System/OriginalModule.dylib$$1$10.8$10.10$_$s14OriginalModule6EntityVMn$
// CHECK-SYMBOLS: $ld$previous$/System/OriginalModule.dylib$$1$10.8$10.10$_$s14OriginalModule6EntityV03addC0yyACF$
// CHECK-SYMBOLS: $ld$previous$/System/OriginalModule.dylib$$1$10.8$10.10$_$s14OriginalModule6EntityVN$
// CHECK-SYMBOLS: $ld$previous$/System/OriginalModule.dylib$$1$10.8$10.10$_$s14OriginalModule6EntityVMa$
// CHECK-SYMBOLS: $ld$previous$/System/OriginalModule.dylib$$1$10.8$10.10$_$s14OriginalModule6EntityV06removeC0yyACF$

// CHECK-ERROR: cannot open previous install name map