Skip to content

Commit ac96c2d

Browse files
committed
pref: fix cross compiling to windows
1 parent 17b5eb5 commit ac96c2d

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎vlib/v/pref/default.v‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ fn (mut p Preferences) find_cc_if_cross_compiling() {
242242
return
243243
}
244244
if p.ccompiler_set_by_flag {
245-
// tcc cannot cross-compile for Windows (no Windows headers),
246-
// so override it with the proper cross-compiler.
247-
if p.os == .windows && p.ccompiler.contains('tcc') {
245+
// Only mingw compilers can cross-compile for Windows (others lack Windows headers),
246+
// so override any non-mingw compiler with the proper cross-compiler.
247+
if p.os == .windows && !p.ccompiler.contains('mingw') {
248248
p.ccompiler = p.vcross_compiler_name()
249249
return
250250
}

‎vlib/v2/gen/cleanc/expr.v‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,11 @@ fn (mut g Gen) expr(node ast.Expr) {
14921492
lhs_expr := sel.lhs
14931493
rhs_name := sel.rhs.name
14941494
lhs_name := if lhs_expr is ast.Ident { sel.lhs.name() } else { '' }
1495+
if lhs_name == 'c' && rhs_name in ['a', 'r', 'g', 'b'] && g.cur_module == 'gg' {
1496+
eprintln('[debug-sel] c.${rhs_name} in ${g.cur_module}::${g.cur_fn_name}, is_known_var=${g.local_var_c_type_for_expr(lhs_expr) != none}, local_type=${g.get_local_var_c_type('c') or {
1497+
'NONE'
1498+
}}')
1499+
}
14951500
// C.<ident> references C macros/constants directly (e.g. C.EOF -> EOF).
14961501
if lhs_expr is ast.Ident {
14971502
if lhs_name == 'C' {

‎vlib/v2/gen/cleanc/fn.v‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,11 +1171,19 @@ fn (mut g Gen) gen_call_arg(fn_name string, idx int, arg ast.Expr) {
11711171
// Selector/index expressions can be smartcast-narrowed in the checker env,
11721172
// while still evaluating to the original sum value representation.
11731173
// If the raw (declared) type already matches the sum param type, pass it through.
1174+
// But verify with get_expr_type: if it returns a known variant, the raw type
1175+
// lookup hit the wrong scope entry (e.g. struct field vs. local variable).
11741176
if raw := g.get_raw_type(base_arg) {
11751177
raw_c := g.types_type_to_c(raw)
11761178
if raw_c == param_type {
1177-
g.expr(base_arg)
1178-
return
1179+
expr_type := g.get_expr_type(base_arg)
1180+
if expr_type == param_type || expr_type == '' || expr_type == 'int'
1181+
|| expr_type !in variants {
1182+
g.expr(base_arg)
1183+
return
1184+
}
1185+
// expr_type is a known variant but raw_type says sum type:
1186+
// raw_type lookup was wrong, fall through to wrapping
11791187
}
11801188
}
11811189
mut arg_type := g.get_expr_type(base_arg)

0 commit comments

Comments
 (0)