1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix chained ./v -usecache -o v cmd/v (and all other V programs that use maps)

This commit is contained in:
Delyan Angelov 2021-12-29 17:57:04 +02:00
parent cc577e1bfb
commit cb34309f6f
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 15 additions and 4 deletions

View File

@ -276,9 +276,9 @@ jobs:
- name: usecache
run: |
./v -usecache examples/hello_world.v && examples/hello_world
# ./v -o v2 -usecache cmd/v
# ./v2 -o v3 -usecache cmd/v
# ./v3 -usecache examples/tetris/tetris.v
./v -o v2 -usecache cmd/v
./v2 -o v3 -usecache cmd/v
./v3 -o tetris -usecache examples/tetris/tetris.v
- name: Test symlink
run: ./v symlink
# - name: Set up pg database

View File

@ -5008,7 +5008,18 @@ fn (mut g Gen) const_decl(node ast.ConstDecl) {
}
}
else {
if g.pref.build_mode != .build_module {
// NB: -usecache uses prebuilt modules, each compiled with:
// `v build-module vlib/module`
// combined with a top level program, that is compiled with:
// `v -usecache toplevel`
// For it to work, the consts optimisations should be identical, because
// only the top level program will have the const initialisation code for
// all the modules.
// TODO: encapsulate const initialisation for each module in a separate function,
// that is just called by the top level program in _vinit, instead of generating
// all the code inside _vinit for each module.
use_cache_mode := g.pref.build_mode == .build_module || g.pref.use_cache
if !use_cache_mode {
if ct_value := field.comptime_expr_value() {
if g.const_decl_precomputed(field.mod, name, ct_value, field.typ) {
continue