cgen: fix for prev commit - get usecache working with clang (fix duplicate symbols)
							parent
							
								
									6fc654821f
								
							
						
					
					
						commit
						07b15a209a
					
				| 
						 | 
					@ -4308,8 +4308,7 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) {
 | 
				
			||||||
		(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