Skip to content

Commit a0a8324

Browse files
committed
ci: fix v -o v2 -usecache cmd/v after ad5b829
1 parent 0a50715 commit a0a8324

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎cmd/v/v.v‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved.
22
// Use of this source code is governed by an MIT license
33
// that can be found in the LICENSE file.
4-
@[has_globals]
54
module main
65

76
import os
@@ -60,7 +59,15 @@ const external_tools = [
6059
]
6160
const list_of_flags_that_allow_duplicates = ['cc', 'd', 'define', 'cf', 'cflags']
6261

63-
__global timers = &util.Timers(unsafe { nil })
62+
@[unsafe]
63+
fn timers_pointer(p &util.Timers) &util.Timers {
64+
// TODO: the static variable here is used as a workaround for the current incompatibility of -usecache and globals in the main module:
65+
mut static ptimers := unsafe { &util.Timers(nil) }
66+
if p != unsafe { nil } {
67+
ptimers = p
68+
}
69+
return ptimers
70+
}
6471

6572
fn main() {
6673
unbuffer_stdout()
@@ -71,12 +78,18 @@ fn main() {
7178
if '-show-timings' in os.args {
7279
timers_should_print = true
7380
}
74-
timers = util.new_timers(should_print: timers_should_print, label: 'main')
81+
mut timers := unsafe {
82+
timers_pointer(util.new_timers(
83+
should_print: timers_should_print
84+
label: 'main'
85+
))
86+
}
7587
timers.start('v start')
7688
timers.show('v start')
7789
timers.start('TOTAL')
7890
// use at_exit here, instead of defer, since some code paths later do early exit(0) or exit(1), for showing errors, or after `v run`
7991
at_exit(fn () {
92+
mut timers := unsafe { timers_pointer(nil) }
8093
timers.show('TOTAL')
8194
})!
8295
timers.start('v parsing CLI args')

0 commit comments

Comments
 (0)