@@ -1581,18 +1581,39 @@ toolchains::Windows::constructInvocation(const LinkJobAction &job,
1581
1581
Arguments.push_back (context.Args .MakeArgString (Target));
1582
1582
}
1583
1583
1584
+
1584
1585
SmallString<128 > SharedRuntimeLibPath;
1585
1586
getRuntimeLibraryPath (SharedRuntimeLibPath, context.Args , *this );
1586
-
1587
- // Add the runtime library link path, which is platform-specific and found
1588
- // relative to the compiler.
1587
+
1588
+ // Link the standard library.
1589
1589
Arguments.push_back (" -L" );
1590
- Arguments.push_back (context.Args .MakeArgString (SharedRuntimeLibPath + " /"
1590
+ if (context.Args .hasFlag (options::OPT_static_stdlib,
1591
+ options::OPT_no_static_stdlib,
1592
+ false )) {
1593
+ SmallString<128 > StaticRuntimeLibPath;
1594
+ getRuntimeStaticLibraryPath (StaticRuntimeLibPath, context.Args , *this );
1595
+
1596
+ // Since Windows has separate libraries per architecture, link against the
1597
+ // architecture specific version of the static library.
1598
+ Arguments.push_back (context.Args .MakeArgString (StaticRuntimeLibPath + " /"
1599
+ + getTriple ().getArchName ()));
1600
+
1601
+ Arguments.push_back (" -Xlinker" );
1602
+ Arguments.push_back (" /NODEFAULTLIB:libcmt" );
1603
+ } else {
1604
+ Arguments.push_back (context.Args .MakeArgString (SharedRuntimeLibPath + " /"
1591
1605
+ getTriple ().getArchName ()));
1606
+ }
1592
1607
1608
+ SmallString<128 > swiftrtPath = SharedRuntimeLibPath;
1609
+ llvm::sys::path::append (swiftrtPath,
1610
+ swift::getMajorArchitectureName (getTriple ()));
1611
+ llvm::sys::path::append (swiftrtPath, " swiftrt.o" );
1612
+ Arguments.push_back (context.Args .MakeArgString (swiftrtPath));
1613
+
1593
1614
addPrimaryInputsOfType (Arguments, context.Inputs , types::TY_Object);
1594
1615
addInputsOfType (Arguments, context.InputActions , types::TY_Object);
1595
-
1616
+
1596
1617
for (const Arg *arg : context.Args .filtered (options::OPT_F,
1597
1618
options::OPT_Fsystem)) {
1598
1619
if (arg->getOption ().matches (options::OPT_Fsystem))
0 commit comments