mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix for prev commit - get usecache working with clang (fix duplicate symbols)
This commit is contained in:
parent
6fc654821f
commit
07b15a209a
@ -4305,11 +4305,10 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
|
|||||||
// 'extern' was used to fix the duplicate symbols with usecache && clang
|
// 'extern' was used to fix the duplicate symbols with usecache && clang
|
||||||
// visibility_kw := if g.pref.build_mode == .build_module && g.is_builtin_mod { 'static ' }
|
// visibility_kw := if g.pref.build_mode == .build_module && g.is_builtin_mod { 'static ' }
|
||||||
visibility_kw := if
|
visibility_kw := if
|
||||||
(g.pref.use_cache || (g.pref.build_mode == .build_module && g.module_built != node.mod))
|
(g.pref.use_cache || (g.pref.build_mode == .build_module && g.module_built != node.mod))
|
||||||
&& !util.should_bundle_module(node.mod) {
|
&& !util.should_bundle_module(node.mod) {
|
||||||
'extern '
|
'extern '
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
''
|
''
|
||||||
}
|
}
|
||||||
mut attributes := ''
|
mut attributes := ''
|
||||||
@ -4331,20 +4330,21 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
|
|||||||
g.definitions.write_string('$visibility_kw$styp $attributes $field.name')
|
g.definitions.write_string('$visibility_kw$styp $attributes $field.name')
|
||||||
if field.has_expr {
|
if field.has_expr {
|
||||||
if field.expr.is_literal() && should_init {
|
if field.expr.is_literal() && should_init {
|
||||||
g.definitions.write_string(' = ${g.expr_string(field.expr)}; // global')
|
g.definitions.write_string(' = ${g.expr_string(field.expr)}')
|
||||||
} else {
|
} else {
|
||||||
g.global_init.writeln('\t$field.name = ${g.expr_string(field.expr)}; // global')
|
g.global_init.writeln('\t$field.name = ${g.expr_string(field.expr)}; // global')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
default_initializer := g.type_default(field.typ)
|
default_initializer := g.type_default(field.typ)
|
||||||
if default_initializer == '{0}' && should_init {
|
if default_initializer == '{0}' && should_init {
|
||||||
g.definitions.writeln(' = {0}; // global')
|
g.definitions.write_string(' = {0}')
|
||||||
} else {
|
} else {
|
||||||
if field.name !in ['as_cast_type_indexes', 'g_memory_block', 'global_allocator'] {
|
if field.name !in ['as_cast_type_indexes', 'g_memory_block', 'global_allocator'] {
|
||||||
g.global_init.writeln('\t$field.name = *($styp*)&(($styp[]){${g.type_default(field.typ)}}[0]); // global')
|
g.global_init.writeln('\t$field.name = *($styp*)&(($styp[]){${g.type_default(field.typ)}}[0]); // global')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g.definitions.writeln('; // global')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user