@@ -681,7 +681,8 @@ 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 = Args.hasArg (OPT_experimental_package_bypass_resilience) ||
685+ Opts.hasFeature (Feature::ClientBypassResilientAccessInPackage);
685686
686687 Opts.DisableAvailabilityChecking |=
687688 Args.hasArg (OPT_disable_availability_checking);
@@ -1111,7 +1112,49 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
11111112 Opts.EnableIndexingSystemModuleRemarks = Args.hasArg (OPT_remark_indexing_system_module);
11121113
11131114 Opts.EnableSkipExplicitInterfaceModuleBuildRemarks = Args.hasArg (OPT_remark_skip_explicit_interface_build);
1114-
1115+
1116+ if (Args.hasArg (OPT_enable_library_evolution)) {
1117+ Opts.SkipNonExportableDecls |=
1118+ Args.hasArg (OPT_experimental_skip_non_exportable_decls);
1119+
1120+ Opts.SkipNonExportableDecls |=
1121+ Args.hasArg (OPT_experimental_skip_non_inlinable_function_bodies) &&
1122+ Args.hasArg (OPT_experimental_skip_non_inlinable_function_bodies_is_lazy);
1123+ } else {
1124+ if (Args.hasArg (OPT_experimental_skip_non_exportable_decls))
1125+ Diags.diagnose (SourceLoc (), diag::ignoring_option_requires_option,
1126+ " -experimental-skip-non-exportable-decls" ,
1127+ " -enable-library-evolution" );
1128+ }
1129+
1130+ Opts.AllowNonResilientAccess = Args.hasArg (OPT_experimental_allow_non_resilient_access) ||
1131+ Opts.hasFeature (Feature::AllowNonResilientAccessInPackage);
1132+ if (Opts.AllowNonResilientAccess ) {
1133+ // Override the option to skip non-exportable decls.
1134+ if (Opts.SkipNonExportableDecls ) {
1135+ Diags.diagnose (SourceLoc (), diag::warn_ignore_option_overriden_by,
1136+ " -experimental-skip-non-exportable-decls" ,
1137+ " -experimental-allow-non-resilient-access" );
1138+ Opts.SkipNonExportableDecls = false ;
1139+ }
1140+ // If built from interface, non-resilient access should not be allowed.
1141+ if (Opts.AllowNonResilientAccess &&
1142+ (FrontendOpts.RequestedAction == FrontendOptions::ActionType::CompileModuleFromInterface ||
1143+ FrontendOpts.RequestedAction == FrontendOptions::ActionType::TypecheckModuleFromInterface)) {
1144+ Diags.diagnose (SourceLoc (), diag::warn_ignore_option_overriden_by,
1145+ " -experimental-allow-non-resilient-access" ,
1146+ " -compile-module-from-interface or -typecheck-module-from-interface" );
1147+ Opts.AllowNonResilientAccess = false ;
1148+ }
1149+ }
1150+
1151+ // HACK: The driver currently erroneously passes all flags to module interface
1152+ // verification jobs. -experimental-skip-non-exportable-decls is not
1153+ // appropriate for verification tasks and should be ignored, though.
1154+ if (FrontendOpts.RequestedAction ==
1155+ FrontendOptions::ActionType::TypecheckModuleFromInterface)
1156+ Opts.SkipNonExportableDecls = false ;
1157+
11151158 llvm::Triple Target = Opts.Target ;
11161159 StringRef TargetArg;
11171160 std::string TargetArgScratch;
@@ -2101,7 +2144,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
21012144 const FrontendOptions &FEOpts,
21022145 const TypeCheckerOptions &TCOpts,
21032146 DiagnosticEngine &Diags,
2104- const llvm::Triple &Triple ,
2147+ LangOptions &LangOpts ,
21052148 ClangImporterOptions &ClangOpts) {
21062149 using namespace options ;
21072150
@@ -2139,7 +2182,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
21392182 Opts.SkipFunctionBodies = TCOpts.SkipFunctionBodies ;
21402183
21412184 // Propagate -experimental-skip-non-exportable-decls to SIL.
2142- Opts.SkipNonExportableDecls = FEOpts .SkipNonExportableDecls ;
2185+ Opts.SkipNonExportableDecls = LangOpts .SkipNonExportableDecls ;
21432186
21442187 // Parse the optimization level.
21452188 // Default to Onone settings if no option is passed.
@@ -2346,8 +2389,9 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
23462389 Opts.CMOMode = CrossModuleOptimizationMode::Everything;
23472390 }
23482391
2349- if (Args.hasArg (OPT_ExperimentalPackageCMO)) {
2350- if (!FEOpts.AllowNonResilientAccess ) {
2392+ if (Args.hasArg (OPT_ExperimentalPackageCMO) ||
2393+ LangOpts.hasFeature (Feature::PackageCMO)) {
2394+ if (!LangOpts.AllowNonResilientAccess ) {
23512395 Diags.diagnose (SourceLoc (), diag::ignoring_option_requires_option,
23522396 " -experimental-package-cmo" ,
23532397 " -experimental-allow-non-resilient-access" );
@@ -2439,7 +2483,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
24392483
24402484 if (const Arg *A = Args.getLastArg (options::OPT_sanitize_EQ)) {
24412485 Opts.Sanitizers = parseSanitizerArgValues (
2442- Args, A, Triple , Diags,
2486+ Args, A, LangOpts. Target , Diags,
24432487 /* sanitizerRuntimeLibExists= */ [](StringRef libName, bool shared) {
24442488
24452489 // The driver has checked the existence of the library
@@ -3289,7 +3333,7 @@ bool CompilerInvocation::parseArgs(
32893333
32903334 if (ParseSILArgs (SILOpts, ParsedArgs, IRGenOpts, FrontendOpts,
32913335 TypeCheckerOpts, Diags,
3292- LangOpts. Target , ClangImporterOpts)) {
3336+ LangOpts, ClangImporterOpts)) {
32933337 return true ;
32943338 }
32953339
0 commit comments