Skip to content

Commit 083cb11

Browse files
authored
Merge pull request #82065 from compnerd/import-shims
ClangImporter: import SwiftShims properly for static linking
2 parents aa92bcf + 43b2b59 commit 083cb11

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ namespace swift {
321321
/// Flags for use by tests
322322
///
323323

324+
bool UseStaticStandardLibrary = false;
325+
324326
/// Enable Objective-C Runtime interop code generation and build
325327
/// configuration options.
326328
bool EnableObjCInterop = true;

lib/ClangImporter/ClangImporter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,9 @@ void importer::getNormalInvocationArguments(
682682
}
683683
}
684684

685+
if (LangOpts.UseStaticStandardLibrary)
686+
invocationArgStrs.push_back("-DSWIFT_STATIC_STDLIB");
687+
685688
// If we support SendingArgsAndResults, set the -D flag to signal that it
686689
// is supported.
687690
if (LangOpts.hasFeature(Feature::SendingArgsAndResults))

lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,7 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
15731573
ModuleInterfaceOpts.PublicFlags.IgnorableFlags +=
15741574
" " + printFormalCxxInteropVersion(Opts);
15751575

1576+
Opts.UseStaticStandardLibrary = Args.hasArg(OPT_use_static_resource_dir);
15761577
Opts.EnableObjCInterop =
15771578
Args.hasFlag(OPT_enable_objc_interop, OPT_disable_objc_interop,
15781579
Target.isOSDarwin() && !Opts.hasFeature(Feature::Embedded));
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %swift_frontend_plain -parse-stdlib -typecheck %s -dump-clang-diagnostics 2>&1 | %FileCheck %s -check-prefix CHECK-DYNAMIC
2+
// RUN: %swift_frontend_plain -parse-stdlib -use-static-resource-dir -typecheck %s -dump-clang-diagnostics 2>&1 | %FileCheck %s -check-prefix CHECK-STATIC
3+
4+
// CHECK-DYNAMIC-NOT: clang importer cc1 args: {{.*}} '-D' 'SWIFT_STATIC_STDLIB'
5+
// CHECK-STATIC: clang importer cc1 args: {{.*}} '-D' 'SWIFT_STATIC_STDLIB'

0 commit comments

Comments
 (0)