Skip to content

Commit 9e2462a

Browse files
committed
native: fix again v -os macos -experimental -b native -o hw.macos examples/hello_world.v, after the latest changes to the backend
1 parent 36bef92 commit 9e2462a

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

.github/workflows/linux_ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ jobs:
7575
run: v run ci/linux_ci.vsh test_leak_detector_tcc
7676
- name: Test leak detector not being active for normal compile
7777
run: v run ci/linux_ci.vsh test_leak_detector_not_active_tcc
78+
- name: native cross compilation to macos
79+
run: v run ci/linux_ci.vsh native_cross_compilation_to_macos
7880

7981
gcc-linux:
8082
runs-on: ubuntu-24.04
@@ -121,6 +123,8 @@ jobs:
121123
run: v run ci/linux_ci.vsh build_modules_gcc
122124
- name: native machine code generation
123125
run: v run ci/linux_ci.vsh native_machine_code_generation_gcc
126+
- name: native cross compilation to macos
127+
run: v run ci/linux_ci.vsh native_cross_compilation_to_macos
124128
- name: compile vdoctor.v with -prod
125129
run: v run ci/linux_ci.vsh compile_vdoctor_prod_gcc
126130
- name: compile vup.v with -prod
@@ -167,3 +171,5 @@ jobs:
167171
run: v run ci/linux_ci.vsh build_modules_clang
168172
- name: native machine code generation
169173
run: v run ci/linux_ci.vsh native_machine_code_generation_clang
174+
- name: native cross compilation to macos
175+
run: v run ci/linux_ci.vsh native_cross_compilation_to_macos

ci/common/runner.v

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ pub fn exec(command string) {
1414
}
1515
}
1616

17+
pub fn file_size_greater_than(fpath string, min_fsize u64) {
18+
log.info('path should exist `${fpath}` ...')
19+
if !os.exists(fpath) {
20+
exit(1)
21+
}
22+
log.info('path exists, and should be a file: `${fpath}` ...')
23+
if !os.is_file(fpath) {
24+
exit(2)
25+
}
26+
real_size := os.file_size(fpath)
27+
log.info('actual file size of `${fpath}` is ${real_size}, wanted: ${min_fsize}, diff: ${real_size - min_fsize}.')
28+
if real_size < min_fsize {
29+
exit(3)
30+
}
31+
}
32+
1733
const self_command = 'v ' +
1834
os.real_path(os.executable()).replace_once(os.real_path(@VROOT), '').trim_left('/\\') + '.vsh'
1935

ci/linux_ci.vsh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,12 @@ fn native_machine_code_generation_clang() {
363363
native_machine_code_generation_common()
364364
}
365365
366+
fn native_cross_compilation_to_macos() {
367+
exec('v -os macos -experimental -b native -o hw.macos examples/hello_world.v')
368+
common.file_size_greater_than('hw.macos', 8000)
369+
exec('rm -f hw.macos')
370+
}
371+
366372
//
367373
// Collect all tasks
368374
//
@@ -409,7 +415,6 @@ const all_tasks = {
409415
'build_option_test_autofree_gcc': Task{build_option_test_autofree_gcc, 'Build option_test.c.v with -autofree (gcc)'}
410416
'v_self_compilation_parallel_cc_gcc': Task{v_self_compilation_parallel_cc_gcc, 'V self compilation with -parallel-cc (gcc)'}
411417
'build_modules_gcc': Task{build_modules_gcc, 'Build modules (gcc)'}
412-
'native_machine_code_generation_gcc': Task{native_machine_code_generation_gcc, 'native machine code generation (gcc)'}
413418
'compile_vdoctor_prod_gcc': Task{compile_vdoctor_prod_gcc, 'compile vdoctor with -prod (gcc)'}
414419
'compile_vup_prod_gcc': Task{compile_vup_prod_gcc, 'compile vup with -prod (gcc)'}
415420
// clang tasks
@@ -429,6 +434,8 @@ const all_tasks = {
429434
'build_examples_autofree_clang': Task{build_examples_autofree_clang, 'Build examples with -autofree (clang)'}
430435
'build_modules_clang': Task{build_modules_clang, 'Build modules (clang)'}
431436
'native_machine_code_generation_clang': Task{native_machine_code_generation_clang, 'native machine code generation (clang)'}
437+
'native_machine_code_generation_gcc': Task{native_machine_code_generation_gcc, 'native machine code generation (gcc)'}
438+
'native_cross_compilation_to_macos': Task{native_cross_compilation_to_macos, 'native cross compilation to macos'}
432439
}
433440
434441
common.run(all_tasks)

vlib/v/gen/native/expr.v

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ fn (mut g Gen) extern_var_ident(var ExternVar) {
196196
g.extern_vars[g.pos()] = var.name
197197
g.code_gen.mov64(main_reg, Number(i64(0)))
198198
g.code_gen.mov_deref(main_reg, main_reg, ast.u64_type_idx)
199+
} else if g.pref.os == .macos {
200+
eprintln('## TODO, macos, extern_var_ident, var: ${var}')
199201
} else {
200202
g.n_error('${@LOCATION} unsupported os for ${var}')
201203
}

0 commit comments

Comments
 (0)