Skip to content

Commit a0f1a53

Browse files
authored
Merge pull request #3326 from compnerd/dependent-libs
2 parents 2ed1770 + 53b9eb4 commit a0f1a53

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

include/swift/Option/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ def Xlinker : Separate<["-"], "Xlinker">,
272272
Flags<[DoesNotAffectIncrementalBuild]>,
273273
HelpText<"Specifies an option which should be passed to the linker">;
274274

275+
def autolink_library : Joined<["-"], "autolink-library=">,
276+
HelpText<"Add dependent library">, Flags<[FrontendOption]>;
277+
275278
// Optimization levels
276279

277280
def O_Group : OptionGroup<"<optimization level options>">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,9 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
12851285
Opts.EnableReflectionNames = false;
12861286
}
12871287

1288+
for (const auto &Lib : Args.getAllArgValues(options::OPT_autolink_library))
1289+
Opts.LinkLibraries.push_back(LinkLibrary(Lib, LibraryKind::Library));
1290+
12881291
return false;
12891292
}
12901293

test/IRGen/dependent-library.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %swift -target i686-unknown-windows-msvc -emit-ir -parse-as-library -parse-stdlib -module-name dependent -autolink-library=oldnames -autolink-library=msvcrt %s -o - | FileCheck %s
2+
3+
// CHECK: !{i32 6, !"Linker Options", ![[options:[0-9]+]]}
4+
// CHECK: ![[options]] = !{![[oldnames:[0-9]+]], ![[msvcrtd:[0-9]+]]}
5+
// CHECK: ![[oldnames]] = !{!"/DEFAULTLIB:oldnames.lib"}
6+
// CHECK: ![[msvcrtd]] = !{!"/DEFAULTLIB:msvcrt.lib"}
7+

0 commit comments

Comments
 (0)