Skip to content

Commit c8909db

Browse files
author
Daniel Kroening
committed
goto-cc now reports version of installed gcc
1 parent 5b3030a commit c8909db

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

src/goto-cc/gcc_mode.cpp

+24-8
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,26 @@ int gcc_modet::doit()
336336
base_name=="bcc" ||
337337
base_name.find("goto-bcc")!=std::string::npos;
338338

339+
// if we are gcc or bcc, then get the version number
340+
gcc_version.get(native_tool_name);
341+
339342
if((cmdline.isset('v') && cmdline.have_infile_arg()) ||
340343
(cmdline.isset("version") && !produce_hybrid_binary))
341344
{
342345
// "-v" a) prints the version and b) increases verbosity.
343346
// Compilation continues, don't exit!
344347

345348
if(act_as_bcc)
346-
std::cout << "bcc: version 0.16.17 (goto-cc " CBMC_VERSION ")\n";
349+
std::cout << "bcc: version " << gcc_version
350+
<< " (goto-cc " CBMC_VERSION ")\n";
347351
else
348-
std::cout << "gcc version 3.4.4 (goto-cc " CBMC_VERSION ")\n";
352+
{
353+
if(gcc_version.flavor == gcc_versiont::flavort::CLANG)
354+
std::cout << "clang version " << gcc_version
355+
<< " (goto-cc " CBMC_VERSION ")\n";
356+
else
357+
std::cout << "gcc (goto-cc " CBMC_VERSION ") " << gcc_version << '\n';
358+
}
349359
}
350360

351361
compilet compiler(cmdline,
@@ -359,11 +369,17 @@ int gcc_modet::doit()
359369
if(produce_hybrid_binary)
360370
return run_gcc(compiler);
361371

362-
std::cout << '\n' <<
363-
"Copyright (C) 2006-2014 Daniel Kroening, Christoph Wintersteiger\n" <<
364-
"CBMC version: " CBMC_VERSION << '\n' <<
365-
"Architecture: " << config.this_architecture() << '\n' <<
366-
"OS: " << config.this_operating_system() << '\n';
372+
std::cout
373+
<< '\n'
374+
<< "Copyright (C) 2006-2018 Daniel Kroening, Christoph Wintersteiger\n"
375+
<< "CBMC version: " CBMC_VERSION << '\n'
376+
<< "Architecture: " << config.this_architecture() << '\n'
377+
<< "OS: " << config.this_operating_system() << '\n';
378+
379+
if(gcc_version.flavor == gcc_versiont::flavort::CLANG)
380+
std::cout << "clang: " << gcc_version << '\n';
381+
else
382+
std::cout << "gcc: " << gcc_version << '\n';
367383

368384
return EX_OK; // Exit!
369385
}
@@ -381,7 +397,7 @@ int gcc_modet::doit()
381397
if(cmdline.isset("dumpmachine"))
382398
std::cout << config.this_architecture() << '\n';
383399
else if(cmdline.isset("dumpversion"))
384-
std::cout << "3.4.4\n";
400+
std::cout << gcc_version << '\n';
385401

386402
// we don't have any meaningful output for the other options, and GCC
387403
// doesn't necessarily produce non-empty output either

src/goto-cc/gcc_mode.h

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Date: June 2006
1515
#define CPROVER_GOTO_CC_GCC_MODE_H
1616

1717
#include "compile.h"
18+
#include "gcc_version.h"
1819
#include "goto_cc_mode.h"
1920

2021
#include <util/cout_message.h>
@@ -61,6 +62,8 @@ class gcc_modet:public goto_cc_modet
6162
const compilet &compiler);
6263

6364
static bool needs_preprocessing(const std::string &);
65+
66+
gcc_versiont gcc_version;
6467
};
6568

6669
#endif // CPROVER_GOTO_CC_GCC_MODE_H

0 commit comments

Comments
 (0)