@@ -3,29 +3,24 @@ use info;
33use libloading:: Library ;
44use rustc_ast as ast;
55use rustc_codegen_ssa:: traits:: CodegenBackend ;
6- use rustc_data_structures:: fx:: FxHashMap ;
76#[ cfg( parallel_compiler) ]
87use rustc_data_structures:: sync;
9- use rustc_errors:: registry:: Registry ;
108use rustc_parse:: validate_attr;
119use rustc_session as session;
12- use rustc_session:: config:: {
13- self , Cfg , CheckCfg , CrateType , OutFileName , OutputFilenames , OutputTypes ,
14- } ;
10+ use rustc_session:: config:: { self , Cfg , CrateType , OutFileName , OutputFilenames , OutputTypes } ;
1511use rustc_session:: filesearch:: sysroot_candidates;
1612use rustc_session:: lint:: { self , BuiltinLintDiagnostics , LintBuffer } ;
1713use rustc_session:: { filesearch, output, Session } ;
1814use rustc_span:: edit_distance:: find_best_match_for_name;
1915use rustc_span:: edition:: Edition ;
20- use rustc_span:: source_map:: FileLoader ;
2116use rustc_span:: symbol:: { sym, Symbol } ;
22- use session:: { CompilerIO , EarlyErrorHandler } ;
17+ use session:: EarlyErrorHandler ;
2318use std:: env;
2419use std:: env:: consts:: { DLL_PREFIX , DLL_SUFFIX } ;
2520use std:: mem;
2621use std:: path:: { Path , PathBuf } ;
2722use std:: sync:: atomic:: { AtomicBool , Ordering } ;
28- use std:: sync:: { Arc , OnceLock } ;
23+ use std:: sync:: OnceLock ;
2924use std:: thread;
3025
3126/// Function pointer type that constructs a new CodegenBackend.
@@ -52,82 +47,6 @@ pub fn add_configuration(cfg: &mut Cfg, sess: &mut Session, codegen_backend: &dy
5247 }
5348}
5449
55- pub fn create_session (
56- handler : & EarlyErrorHandler ,
57- sopts : config:: Options ,
58- cfg : Cfg ,
59- mut check_cfg : CheckCfg ,
60- locale_resources : & ' static [ & ' static str ] ,
61- file_loader : Option < Box < dyn FileLoader + Send + Sync + ' static > > ,
62- io : CompilerIO ,
63- lint_caps : FxHashMap < lint:: LintId , lint:: Level > ,
64- make_codegen_backend : Option <
65- Box < dyn FnOnce ( & config:: Options ) -> Box < dyn CodegenBackend > + Send > ,
66- > ,
67- descriptions : Registry ,
68- ice_file : Option < PathBuf > ,
69- using_internal_features : Arc < AtomicBool > ,
70- expanded_args : Vec < String > ,
71- ) -> ( Session , Box < dyn CodegenBackend > ) {
72- let codegen_backend = if let Some ( make_codegen_backend) = make_codegen_backend {
73- make_codegen_backend ( & sopts)
74- } else {
75- get_codegen_backend (
76- handler,
77- & sopts. maybe_sysroot ,
78- sopts. unstable_opts . codegen_backend . as_deref ( ) ,
79- )
80- } ;
81-
82- // target_override is documented to be called before init(), so this is okay
83- let target_override = codegen_backend. target_override ( & sopts) ;
84-
85- let bundle = match rustc_errors:: fluent_bundle (
86- sopts. maybe_sysroot . clone ( ) ,
87- sysroot_candidates ( ) . to_vec ( ) ,
88- sopts. unstable_opts . translate_lang . clone ( ) ,
89- sopts. unstable_opts . translate_additional_ftl . as_deref ( ) ,
90- sopts. unstable_opts . translate_directionality_markers ,
91- ) {
92- Ok ( bundle) => bundle,
93- Err ( e) => {
94- handler. early_error ( format ! ( "failed to load fluent bundle: {e}" ) ) ;
95- }
96- } ;
97-
98- let mut locale_resources = Vec :: from ( locale_resources) ;
99- locale_resources. push ( codegen_backend. locale_resource ( ) ) ;
100-
101- let mut sess = session:: build_session (
102- handler,
103- sopts,
104- io,
105- bundle,
106- descriptions,
107- locale_resources,
108- lint_caps,
109- file_loader,
110- target_override,
111- rustc_version_str ( ) . unwrap_or ( "unknown" ) ,
112- ice_file,
113- using_internal_features,
114- expanded_args,
115- ) ;
116-
117- codegen_backend. init ( & sess) ;
118-
119- let mut cfg = config:: build_configuration ( & sess, cfg) ;
120- add_configuration ( & mut cfg, & mut sess, & * codegen_backend) ;
121-
122- check_cfg. fill_well_known ( & sess. target ) ;
123-
124- // These configs use symbols, rather than strings.
125- sess. parse_sess . config = cfg;
126- sess. parse_sess . check_config = check_cfg;
127-
128- ( sess, codegen_backend)
129- }
130-
13150const STACK_SIZE : usize = 8 * 1024 * 1024 ;
13251
13352fn get_stack_size ( ) -> Option < usize > {
0 commit comments