Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builder: simplify generic cc detection #21380

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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('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.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}`')
}
eprintln('Compilation with unknown C compiler')
ccoptions.cc = .unknown
}
} else {
cc_file_name := os.file_name(ccompiler)
Expand Down