Skip to content

Commit 2ff0f62

Browse files
committed
v: fix passing -arch arm64 to $if arm64{}
1 parent 5870751 commit 2ff0f62

File tree

8 files changed

+38
-29
lines changed

8 files changed

+38
-29
lines changed

vlib/sync/atomic2/atomic.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $if linux {
2929
#flag -L/usr/lib/gcc/x86_64-linux-gnu/10
3030
#flag -L/usr/lib/gcc/x86_64-linux-gnu/11
3131
#flag -L/usr/lib/gcc/x86_64-linux-gnu/12
32-
} $else $if aarch64 {
32+
} $else $if arm64 {
3333
#flag -L/usr/lib/gcc/aarch64-linux-gnu/6
3434
#flag -L/usr/lib/gcc/aarch64-linux-gnu/7
3535
#flag -L/usr/lib/gcc/aarch64-linux-gnu/8

vlib/sync/channels.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ $if linux {
2020
#flag -L/usr/lib/gcc/x86_64-linux-gnu/10
2121
#flag -L/usr/lib/gcc/x86_64-linux-gnu/11
2222
#flag -L/usr/lib/gcc/x86_64-linux-gnu/12
23-
} $else $if aarch64 {
23+
} $else $if arm64 {
2424
#flag -L/usr/lib/gcc/aarch64-linux-gnu/6
2525
#flag -L/usr/lib/gcc/aarch64-linux-gnu/7
2626
#flag -L/usr/lib/gcc/aarch64-linux-gnu/8

vlib/v/builder/native.v

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ pub fn (mut b Builder) build_native(v_files []string, out_file string) {
1717
pub fn (mut b Builder) compile_native() {
1818
// v.files << v.v_files_from_dir(os.join_path(v.pref.vlib_path,'builtin','bare'))
1919
files := [b.pref.path]
20-
if b.pref.arch == ._auto {
21-
b.pref.arch = pref.get_host_arch()
22-
}
2320
b.set_module_lookup_paths()
2421
b.build_native(files, b.pref.out_name)
2522
}

vlib/v/checker/checker.v

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ const (
2424
'haiku',
2525
]
2626
valid_comp_if_compilers = ['gcc', 'tinyc', 'clang', 'mingw', 'msvc', 'cplusplus']
27-
valid_comp_if_platforms = ['amd64', 'aarch64', 'arm64', 'x64', 'x32', 'little_endian',
28-
'big_endian',
29-
]
27+
valid_comp_if_platforms = ['amd64', 'i386', 'aarch64', 'arm64', 'arm32', 'rv64', 'rv32']
28+
valid_comp_if_cpu_features = ['x64', 'x32', 'little_endian', 'big_endian']
3029
valid_comp_if_other = ['js', 'debug', 'prod', 'test', 'glibc', 'prealloc',
3130
'no_bounds_checking', 'freestanding', 'threads']
3231
array_builtin_methods = ['filter', 'clone', 'repeat', 'reverse', 'map', 'slice', 'sort',
@@ -6201,28 +6200,42 @@ fn (mut c Checker) comp_if_branch(cond ast.Expr, pos token.Position) bool {
62016200
}
62026201
}
62036202
ast.Ident {
6204-
if cond.name in checker.valid_comp_if_os {
6205-
return cond.name != c.pref.os.str().to_lower() // TODO hack
6206-
} else if cond.name in checker.valid_comp_if_compilers {
6207-
return pref.cc_from_string(cond.name) != c.pref.ccompiler_type
6208-
} else if cond.name in checker.valid_comp_if_platforms {
6209-
return false // TODO
6210-
} else if cond.name in checker.valid_comp_if_other {
6211-
// TODO: This should probably be moved
6212-
match cond.name {
6203+
cname := cond.name
6204+
if cname in checker.valid_comp_if_os {
6205+
return cname != c.pref.os.str().to_lower()
6206+
} else if cname in checker.valid_comp_if_compilers {
6207+
return pref.cc_from_string(cname) != c.pref.ccompiler_type
6208+
} else if cname in checker.valid_comp_if_platforms {
6209+
if cname == 'aarch64' {
6210+
c.note('use `arm64` instead of `aarch64`', pos)
6211+
}
6212+
match cname {
6213+
'amd64' { return c.pref.arch != .amd64 }
6214+
'i386' { return c.pref.arch != .i386 }
6215+
'aarch64' { return c.pref.arch != .arm64 }
6216+
'arm64' { return c.pref.arch != .arm64 }
6217+
'arm32' { return c.pref.arch != .arm32 }
6218+
'rv64' { return c.pref.arch != .rv64 }
6219+
'rv32' { return c.pref.arch != .rv32 }
6220+
else { return false }
6221+
}
6222+
} else if cname in checker.valid_comp_if_cpu_features {
6223+
return false
6224+
} else if cname in checker.valid_comp_if_other {
6225+
match cname {
62136226
'js' { return c.pref.backend != .js }
62146227
'debug' { return !c.pref.is_debug }
62156228
'prod' { return !c.pref.is_prod }
62166229
'test' { return !c.pref.is_test }
62176230
'glibc' { return false } // TODO
62186231
'threads' { return c.table.gostmts == 0 }
62196232
'prealloc' { return !c.pref.prealloc }
6220-
'no_bounds_checking' { return cond.name !in c.pref.compile_defines_all }
6233+
'no_bounds_checking' { return cname !in c.pref.compile_defines_all }
62216234
'freestanding' { return !c.pref.is_bare || c.pref.output_cross_c }
62226235
else { return false }
62236236
}
6224-
} else if cond.name !in c.pref.compile_defines_all {
6225-
if cond.name == 'linux_or_macos' {
6237+
} else if cname !in c.pref.compile_defines_all {
6238+
if cname == 'linux_or_macos' {
62266239
c.error('linux_or_macos is deprecated, use `\$if linux || macos {` instead',
62276240
cond.pos)
62286241
return false
@@ -6231,7 +6244,7 @@ fn (mut c Checker) comp_if_branch(cond ast.Expr, pos token.Position) bool {
62316244
typ := c.expr(cond)
62326245
if cond.obj !is ast.Var && cond.obj !is ast.ConstField
62336246
&& cond.obj !is ast.GlobalField {
6234-
c.error('unknown var: `$cond.name`', pos)
6247+
c.error('unknown var: `$cname`', pos)
62356248
return false
62366249
}
62376250
expr := c.find_obj_definition(cond.obj) or {

vlib/v/gen/native/gen.v

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ pub fn (mut g Gen) gen_print_from_expr(expr ast.Expr, newline bool) {
244244
g.gen_print_reg(.rax, 3)
245245
}
246246
else {
247+
dump(typeof(expr).name)
247248
dump(expr)
248249
verror('expected string as argument for print')
249250
}
@@ -336,10 +337,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
336337
g.write8(b)
337338
}
338339
}
339-
ast.Module {
340-
eprintln('module')
341-
dump(node)
342-
}
340+
ast.Module {}
343341
ast.Return {
344342
// dump(node.exprs[0])
345343
// if in main

vlib/v/gen/native/tests/native_test.v

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ const is_verbose = os.getenv('VTEST_SHOW_CMD') != ''
66

77
// TODO some logic copy pasted from valgrind_test.v and compiler_test.v, move to a module
88
fn test_native() {
9-
$if !amd64 {
10-
return
11-
}
12-
$if aarch64 {
9+
$if arm64 {
1310
return
1411
}
1512
// some tests are running fine in macos

vlib/v/pref/default.v

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ fn (mut p Preferences) expand_lookup_paths() {
3737
}
3838

3939
pub fn (mut p Preferences) fill_with_defaults() {
40+
if p.arch == ._auto {
41+
p.arch = get_host_arch()
42+
}
4043
p.expand_lookup_paths()
4144
rpath := os.real_path(p.path)
4245
if p.out_name == '' {

vlib/v/pref/pref.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
590590
if res.is_debug {
591591
parse_define(mut res, 'debug')
592592
}
593+
593594
// res.use_cache = true
594595
if command != 'doc' && res.out_name.ends_with('.v') {
595596
eprintln('Cannot save output binary in a .v file.')

0 commit comments

Comments
 (0)