@@ -87,7 +87,7 @@ pub fn (mut b Builder) build(files []string) {
8787
8888 // Transform AST (flag enum desugaring, etc.)
8989 transform_start := sw.elapsed ()
90- mut trans := transformer.Transformer.new (b.files, b.env)
90+ mut trans := transformer.Transformer.new_with_pref (b.files, b.env, b.pref )
9191 b.files = trans.transform_files (b.files)
9292 transform_time := time.Duration (sw.elapsed () - transform_start)
9393 print_time ('Transform' , transform_time)
@@ -223,8 +223,13 @@ fn (b &Builder) is_cmd_v2_self_build() bool {
223223 if b.user_files.len != 1 {
224224 return false
225225 }
226+ // Avoid path normalization here: during bootstraps, some intermediate
227+ // compilers can still have unstable path helpers.
226228 path := b.user_files[0 ].replace ('\\ ' , '/' )
227- return path.ends_with ('/cmd/v2/v2.v' ) || path.ends_with ('cmd/v2/v2.v' ) || path == 'v2.v'
229+ if path == 'v2.v' || path.ends_with ('/v2.v' ) {
230+ return true
231+ }
232+ return path.ends_with ('/cmd/v2/v2.v' ) || path.ends_with ('cmd/v2/v2.v' )
228233}
229234
230235fn (mut b Builder) gen_ssa_c () {
@@ -247,7 +252,11 @@ fn (mut b Builder) gen_ssa_c() {
247252 print_time ('SSA Build' , time.Duration (sw.elapsed () - stage_start))
248253
249254 stage_start = sw.elapsed ()
250- if os.getenv ('V2_SSA_OPT' ) != '0' {
255+ mut use_ssa_opt := os.getenv ('V2_SSA_OPT' ) != '0'
256+ if b.is_cmd_v2_self_build () {
257+ use_ssa_opt = false
258+ }
259+ if use_ssa_opt {
251260 optimize.optimize (mut mod)
252261 }
253262 print_time ('SSA Optimize' , time.Duration (sw.elapsed () - stage_start))
@@ -299,54 +308,13 @@ fn (mut b Builder) gen_ssa_c() {
299308 }
300309 cc_res := os.execute (cc_cmd)
301310 if cc_res.exit_code != 0 {
302- eprintln ('warning: ssa c backend compilation failed, falling back to cleanc backend' )
303- ssa_snapshot := output_name + '.ssa.c'
304- os.cp (c_file, ssa_snapshot) or {}
311+ eprintln ('error: ssa c backend compilation failed' )
305312 lines := cc_res.output.split_into_lines ()
306313 limit := if lines.len < 20 { lines.len } else { 20 }
307314 for line in lines[..limit] {
308315 eprintln (line)
309316 }
310- mut fallback_args := []string {}
311- fallback_args << os.quoted_path (os.args[0 ])
312- fallback_args << '-backend cleanc'
313- fallback_args << '-nomarkused'
314- fallback_args << '-nocache'
315- if b.pref.show_cc {
316- fallback_args << '-showcc'
317- }
318- if b.pref.stats {
319- fallback_args << '-stats'
320- }
321- if b.pref.print_parsed_files {
322- fallback_args << '-print-parsed-files'
323- }
324- if b.pref.skip_builtin {
325- fallback_args << '--skip-builtin'
326- }
327- if b.pref.skip_imports {
328- fallback_args << '--skip-imports'
329- }
330- if b.pref.skip_type_check {
331- fallback_args << '--skip-type-check'
332- }
333- if output_name.len > 0 {
334- fallback_args << '-o ${os .quoted_path (output_name )}'
335- }
336- for user_file in b.user_files {
337- fallback_args << os.quoted_path (user_file)
338- }
339- fallback_cmd := fallback_args.join (' ' )
340- fallback_res := os.execute (fallback_cmd)
341- if fallback_res.exit_code != 0 {
342- eprintln ('error: cleanc fallback failed' )
343- eprintln (fallback_res.output)
344- exit (1 )
345- }
346- if fallback_res.output.len > 0 {
347- println (fallback_res.output)
348- }
349- return
317+ exit (1 )
350318 }
351319 print_time ('CC' , time.Duration (sw.elapsed () - cc_start))
352320
0 commit comments