Skip to content

Commit cc3fd53

Browse files
authored
builder: print tcc output, when the system C compiler also failed (#8835)
1 parent c704a49 commit cc3fd53

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

vlib/v/builder/cc.v

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ fn (mut v Builder) cc() {
520520
vexe := pref.vexe_path()
521521
vdir := os.dir(vexe)
522522
mut tried_compilation_commands := []string{}
523+
mut tcc_output := os.Result{}
523524
original_pwd := os.getwd()
524525
for {
525526
// try to compile with the choosen compiler
@@ -659,6 +660,7 @@ fn (mut v Builder) cc() {
659660
exit(101)
660661
}
661662
if v.pref.retry_compilation {
663+
tcc_output = res
662664
v.pref.ccompiler = pref.default_c_compiler()
663665
if v.pref.is_verbose {
664666
eprintln('Compilation with tcc failed. Retrying with $v.pref.ccompiler ...')
@@ -676,7 +678,14 @@ fn (mut v Builder) cc() {
676678
}
677679
}
678680
if !v.pref.show_c_output {
679-
v.post_process_c_compiler_output(res)
681+
// if tcc failed once, and the system C compiler has failed as well,
682+
// print the tcc error instead since it may contain more useful information
683+
// see https://discord.com/channels/592103645835821068/592115457029308427/811956304314761228
684+
if res.exit_code != 0 && tcc_output.output != '' {
685+
v.post_process_c_compiler_output(tcc_output)
686+
} else {
687+
v.post_process_c_compiler_output(res)
688+
}
680689
}
681690
// Print the C command
682691
if v.pref.is_verbose {

0 commit comments

Comments
 (0)