From dc0991a4666d6ce50cc10c4f39fa0d52145615d8 Mon Sep 17 00:00:00 2001 From: Turiiya Date: Mon, 29 Apr 2024 16:19:58 +0200 Subject: [PATCH 1/2] builder: simplify generic cc detection --- vlib/v/builder/cc.v | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 803fcf6c400917..0087e223d36d39 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -180,21 +180,18 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) { ccoptions.debug_mode = v.pref.is_debug ccoptions.guessed_compiler = v.pref.ccompiler if ccoptions.guessed_compiler == 'cc' { - if cc_ver := os.execute_opt('cc --version') { - if cc_ver.output.replace('\n', '').contains('Free Software Foundation, Inc.This is free software;') { - // Also covers `g++`, `g++-9`, `g++-11` etc. - ccoptions.cc = .gcc - } else if cc_ver.output.contains('clang version ') { - ccoptions.cc = .clang - } else { - if v.pref.is_verbose { - eprintln('failed to detect C compiler from version info `${cc_ver.output}`') - } - eprintln('Compilation with unknown C compiler') - ccoptions.cc = .unknown - } + cc_ver := os.execute_opt('cc --version') or { panic('unknown C compiler') } + if cc_ver.output.replace('\n', '').contains('Free Software Foundation, Inc.This is free software;') { + // Also covers `g++`, `g++-9`, `g++-11` etc. + ccoptions.cc = .gcc + } else if cc_ver.output.contains('clang version ') { + ccoptions.cc = .clang } else { - panic('unknown C compiler') + if v.pref.is_verbose { + eprintln('failed to detect C compiler from version info `${cc_ver.output}`') + } + eprintln('Compilation with unknown C compiler') + ccoptions.cc = .unknown } } else { cc_file_name := os.file_name(ccompiler) From 8ee55e4585d412118f81066e9826aa0d7ac28ce1 Mon Sep 17 00:00:00 2001 From: Turiiya Date: Mon, 29 Apr 2024 21:05:47 +0200 Subject: [PATCH 2/2] update, rebase on master --- vlib/v/builder/cc.v | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vlib/v/builder/cc.v b/vlib/v/builder/cc.v index 0087e223d36d39..e3c7bc79726bed 100644 --- a/vlib/v/builder/cc.v +++ b/vlib/v/builder/cc.v @@ -180,15 +180,15 @@ fn (mut v Builder) setup_ccompiler_options(ccompiler string) { ccoptions.debug_mode = v.pref.is_debug ccoptions.guessed_compiler = v.pref.ccompiler if ccoptions.guessed_compiler == 'cc' { - cc_ver := os.execute_opt('cc --version') or { panic('unknown C compiler') } - if cc_ver.output.replace('\n', '').contains('Free Software Foundation, Inc.This is free software;') { + cc_ver := os.execute('cc --version').output + if cc_ver.replace('\n', '').contains('Free Software Foundation, Inc.This is free software;') { // Also covers `g++`, `g++-9`, `g++-11` etc. ccoptions.cc = .gcc - } else if cc_ver.output.contains('clang version ') { + } else if cc_ver.contains('clang version ') { ccoptions.cc = .clang } else { if v.pref.is_verbose { - eprintln('failed to detect C compiler from version info `${cc_ver.output}`') + eprintln('failed to detect C compiler from version info `${cc_ver}`') } eprintln('Compilation with unknown C compiler') ccoptions.cc = .unknown