@@ -3,29 +3,24 @@ use info;
3
3
use libloading:: Library ;
4
4
use rustc_ast as ast;
5
5
use rustc_codegen_ssa:: traits:: CodegenBackend ;
6
- use rustc_data_structures:: fx:: FxHashMap ;
7
6
#[ cfg( parallel_compiler) ]
8
7
use rustc_data_structures:: sync;
9
- use rustc_errors:: registry:: Registry ;
10
8
use rustc_parse:: validate_attr;
11
9
use 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 } ;
15
11
use rustc_session:: filesearch:: sysroot_candidates;
16
12
use rustc_session:: lint:: { self , BuiltinLintDiagnostics , LintBuffer } ;
17
13
use rustc_session:: { filesearch, output, Session } ;
18
14
use rustc_span:: edit_distance:: find_best_match_for_name;
19
15
use rustc_span:: edition:: Edition ;
20
- use rustc_span:: source_map:: FileLoader ;
21
16
use rustc_span:: symbol:: { sym, Symbol } ;
22
- use session:: { CompilerIO , EarlyErrorHandler } ;
17
+ use session:: EarlyErrorHandler ;
23
18
use std:: env;
24
19
use std:: env:: consts:: { DLL_PREFIX , DLL_SUFFIX } ;
25
20
use std:: mem;
26
21
use std:: path:: { Path , PathBuf } ;
27
22
use std:: sync:: atomic:: { AtomicBool , Ordering } ;
28
- use std:: sync:: { Arc , OnceLock } ;
23
+ use std:: sync:: OnceLock ;
29
24
use std:: thread;
30
25
31
26
/// 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
52
47
}
53
48
}
54
49
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
-
131
50
const STACK_SIZE : usize = 8 * 1024 * 1024 ;
132
51
133
52
fn get_stack_size ( ) -> Option < usize > {
0 commit comments