diff --git a/compiler/cgen.v b/compiler/cgen.v index 740924e6e1..708a0c9ea3 100644 --- a/compiler/cgen.v +++ b/compiler/cgen.v @@ -261,7 +261,10 @@ fn build_thirdparty_obj_file(flag string) { } } cc := if os.user_os() == 'windows' { 'gcc' } else { 'cc' } // TODO clang support on Windows - res := os.exec('$cc -fPIC -c -o $obj_path $cfiles') + res := os.exec('$cc -fPIC -c -o $obj_path $cfiles') or { + panic(err) + return // TODO remove return + } println(res) } diff --git a/compiler/main.v b/compiler/main.v index 887c9acd67..4aaa3af319 100644 --- a/compiler/main.v +++ b/compiler/main.v @@ -137,11 +137,17 @@ fn main() { println('Building vget...') os.chdir(vroot + '/tools') vexec := os.args[0] - os.exec('$vexec vget.v') + _ := os.exec('$vexec vget.v') or { + panic(err) + return // TODO remove return + } println('Done.') } println('Installing module ${mod}...') - os.exec('$vget $mod') + _ := os.exec('$vget $mod') or { + panic(err) + return // TODO remove return + } return } // TODO quit if the compiler is too old @@ -871,7 +877,19 @@ mut args := '' } // Run ticks := time.ticks() - res := os.exec(cmd) + _ := os.exec(cmd) or { + if v.pref.is_debug { + println(err) + } else { + print(err.limit(200)) + if err.len > 200 { + println('...\n(Use `v -debug` to print the entire error message)\n') + } + } + panic('C error. This should never happen. ' + + 'Please create a GitHub issue: https://github.com/vlang/v/issues/new/choose') + return // TODO remove return + } diff := time.ticks() - ticks // Print the C command if v.pref.show_c_cmd || v.pref.is_verbose { @@ -880,18 +898,6 @@ mut args := '' println('cc took $diff ms') println('=========\n') } - if res.contains('error: ') { - if v.pref.is_debug { - println(res) - } else { - print(res.limit(200)) - if res.len > 200 { - println('...\n(Use `v -debug` to print the entire error message)\n') - } - } - panic('C error. This should never happen. ' + - 'Please create a GitHub issue: https://github.com/vlang/v/issues/new/choose') - } // Link it if we are cross compiling and need an executable if v.os == .linux && !linux_host && v.pref.build_mode != .build { v.out_name = v.out_name.replace('.o', '') @@ -905,11 +911,11 @@ mut args := '' '/usr/lib/x86_64-linux-gnu/crti.o ' + obj_file + ' /usr/lib/x86_64-linux-gnu/libc.so ' + - '/usr/lib/x86_64-linux-gnu/crtn.o') - println(ress) - if ress.contains('error:') { - exit(1) + '/usr/lib/x86_64-linux-gnu/crtn.o') or { + panic(err) + return // TODO remove return } + println(ress) println('linux cross compilation done. resulting binary: "$v.out_name"') } if !v.pref.is_debug && v.out_name_c != 'v.c' && v.out_name_c != 'v_macos.c' { @@ -1315,22 +1321,13 @@ fn run_repl() []string { if line.starts_with('print') { source_code := lines.join('\n') + '\n' + line os.write_file(file, source_code) - s := os.exec('$vexe run $file -repl') - mut vals := s.split('\n') - if s.contains('panic: ') { - if !s.contains('declared and not used') { - for i:=1; i