Skip to content

Commit

Permalink
builder: simplify generic cc detection, rebase to resovle CI errors w…
Browse files Browse the repository at this point in the history
…ith new master pulls
  • Loading branch information
ttytm committed Apr 29, 2024
1 parent e4bbd73 commit f6a11c0
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions vlib/v/builder/cc.v
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f6a11c0

Please sign in to comment.