builder: print tcc output, when the system C compiler also failed (#8835)

pull/8862/head
spaceface 2021-02-20 17:52:54 +01:00 committed by GitHub
parent c704a49283
commit cc3fd5333b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -520,6 +520,7 @@ fn (mut v Builder) cc() {
vexe := pref.vexe_path()
vdir := os.dir(vexe)
mut tried_compilation_commands := []string{}
mut tcc_output := os.Result{}
original_pwd := os.getwd()
for {
// try to compile with the choosen compiler
@ -659,6 +660,7 @@ fn (mut v Builder) cc() {
exit(101)
}
if v.pref.retry_compilation {
tcc_output = res
v.pref.ccompiler = pref.default_c_compiler()
if v.pref.is_verbose {
eprintln('Compilation with tcc failed. Retrying with $v.pref.ccompiler ...')
@ -676,7 +678,14 @@ fn (mut v Builder) cc() {
}
}
if !v.pref.show_c_output {
v.post_process_c_compiler_output(res)
// if tcc failed once, and the system C compiler has failed as well,
// print the tcc error instead since it may contain more useful information
// see https://discord.com/channels/592103645835821068/592115457029308427/811956304314761228
if res.exit_code != 0 && tcc_output.output != '' {
v.post_process_c_compiler_output(tcc_output)
} else {
v.post_process_c_compiler_output(res)
}
}
// Print the C command
if v.pref.is_verbose {