@@ -681,7 +681,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
681681 Opts.EnablePackageInterfaceLoad = Args.hasArg (OPT_experimental_package_interface_load) ||
682682 ::getenv (" SWIFT_ENABLE_PACKAGE_INTERFACE_LOAD" );
683683
684- Opts.EnableBypassResilienceInPackage = Args.hasArg (OPT_experimental_package_bypass_resilience);
684+ Opts.EnableBypassResilienceInPackage =
685+ Args.hasArg (OPT_experimental_package_bypass_resilience) ||
686+ Opts.hasFeature (Feature::ClientBypassResilientAccessInPackage);
685687
686688 Opts.DisableAvailabilityChecking |=
687689 Args.hasArg (OPT_disable_availability_checking);
@@ -1111,7 +1113,54 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
11111113 Opts.EnableIndexingSystemModuleRemarks = Args.hasArg (OPT_remark_indexing_system_module);
11121114
11131115 Opts.EnableSkipExplicitInterfaceModuleBuildRemarks = Args.hasArg (OPT_remark_skip_explicit_interface_build);
1114-
1116+
1117+ if (Args.hasArg (OPT_enable_library_evolution)) {
1118+ Opts.SkipNonExportableDecls |=
1119+ Args.hasArg (OPT_experimental_skip_non_exportable_decls);
1120+
1121+ Opts.SkipNonExportableDecls |=
1122+ Args.hasArg (OPT_experimental_skip_non_inlinable_function_bodies) &&
1123+ Args.hasArg (
1124+ OPT_experimental_skip_non_inlinable_function_bodies_is_lazy);
1125+ } else {
1126+ if (Args.hasArg (OPT_experimental_skip_non_exportable_decls))
1127+ Diags.diagnose (SourceLoc (), diag::ignoring_option_requires_option,
1128+ " -experimental-skip-non-exportable-decls" ,
1129+ " -enable-library-evolution" );
1130+ }
1131+
1132+ Opts.AllowNonResilientAccess =
1133+ Args.hasArg (OPT_experimental_allow_non_resilient_access) ||
1134+ Opts.hasFeature (Feature::AllowNonResilientAccessInPackage);
1135+ if (Opts.AllowNonResilientAccess ) {
1136+ // Override the option to skip non-exportable decls.
1137+ if (Opts.SkipNonExportableDecls ) {
1138+ Diags.diagnose (SourceLoc (), diag::warn_ignore_option_overriden_by,
1139+ " -experimental-skip-non-exportable-decls" ,
1140+ " -experimental-allow-non-resilient-access" );
1141+ Opts.SkipNonExportableDecls = false ;
1142+ }
1143+ // If built from interface, non-resilient access should not be allowed.
1144+ if (Opts.AllowNonResilientAccess &&
1145+ (FrontendOpts.RequestedAction ==
1146+ FrontendOptions::ActionType::CompileModuleFromInterface ||
1147+ FrontendOpts.RequestedAction ==
1148+ FrontendOptions::ActionType::TypecheckModuleFromInterface)) {
1149+ Diags.diagnose (
1150+ SourceLoc (), diag::warn_ignore_option_overriden_by,
1151+ " -experimental-allow-non-resilient-access" ,
1152+ " -compile-module-from-interface or -typecheck-module-from-interface" );
1153+ Opts.AllowNonResilientAccess = false ;
1154+ }
1155+ }
1156+
1157+ // HACK: The driver currently erroneously passes all flags to module interface
1158+ // verification jobs. -experimental-skip-non-exportable-decls is not
1159+ // appropriate for verification tasks and should be ignored, though.
1160+ if (FrontendOpts.RequestedAction ==
1161+ FrontendOptions::ActionType::TypecheckModuleFromInterface)
1162+ Opts.SkipNonExportableDecls = false ;
1163+
11151164 llvm::Triple Target = Opts.Target ;
11161165 StringRef TargetArg;
11171166 std::string TargetArgScratch;
@@ -2097,11 +2146,9 @@ void parseExclusivityEnforcementOptions(const llvm::opt::Arg *A,
20972146}
20982147
20992148static bool ParseSILArgs (SILOptions &Opts, ArgList &Args,
2100- IRGenOptions &IRGenOpts,
2101- const FrontendOptions &FEOpts,
2149+ IRGenOptions &IRGenOpts, const FrontendOptions &FEOpts,
21022150 const TypeCheckerOptions &TCOpts,
2103- DiagnosticEngine &Diags,
2104- const llvm::Triple &Triple,
2151+ DiagnosticEngine &Diags, LangOptions &LangOpts,
21052152 ClangImporterOptions &ClangOpts) {
21062153 using namespace options ;
21072154
@@ -2139,7 +2186,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
21392186 Opts.SkipFunctionBodies = TCOpts.SkipFunctionBodies ;
21402187
21412188 // Propagate -experimental-skip-non-exportable-decls to SIL.
2142- Opts.SkipNonExportableDecls = FEOpts .SkipNonExportableDecls ;
2189+ Opts.SkipNonExportableDecls = LangOpts .SkipNonExportableDecls ;
21432190
21442191 // Parse the optimization level.
21452192 // Default to Onone settings if no option is passed.
@@ -2346,8 +2393,9 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
23462393 Opts.CMOMode = CrossModuleOptimizationMode::Everything;
23472394 }
23482395
2349- if (Args.hasArg (OPT_ExperimentalPackageCMO)) {
2350- if (!FEOpts.AllowNonResilientAccess ) {
2396+ if (Args.hasArg (OPT_ExperimentalPackageCMO) ||
2397+ LangOpts.hasFeature (Feature::PackageCMO)) {
2398+ if (!LangOpts.AllowNonResilientAccess ) {
23512399 Diags.diagnose (SourceLoc (), diag::ignoring_option_requires_option,
23522400 " -experimental-package-cmo" ,
23532401 " -experimental-allow-non-resilient-access" );
@@ -2439,8 +2487,8 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
24392487
24402488 if (const Arg *A = Args.getLastArg (options::OPT_sanitize_EQ)) {
24412489 Opts.Sanitizers = parseSanitizerArgValues (
2442- Args, A, Triple , Diags,
2443- /* sanitizerRuntimeLibExists= */ [](StringRef libName, bool shared) {
2490+ Args, A, LangOpts. Target , Diags,
2491+ /* sanitizerRuntimeLibExists= */ [](StringRef libName, bool shared) {
24442492
24452493 // The driver has checked the existence of the library
24462494 // already.
@@ -3288,8 +3336,7 @@ bool CompilerInvocation::parseArgs(
32883336 }
32893337
32903338 if (ParseSILArgs (SILOpts, ParsedArgs, IRGenOpts, FrontendOpts,
3291- TypeCheckerOpts, Diags,
3292- LangOpts.Target , ClangImporterOpts)) {
3339+ TypeCheckerOpts, Diags, LangOpts, ClangImporterOpts)) {
32933340 return true ;
32943341 }
32953342
0 commit comments