Skip to content

Commit 9ebe2bc

Browse files
author
Daniel Kroening
committed
goto-cc now reports version of installed gcc
1 parent 276fbde commit 9ebe2bc

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/goto-cc/gcc_mode.cpp

+25-8
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ int gcc_modet::doit()
339339
base_name=="bcc" ||
340340
base_name.find("goto-bcc")!=std::string::npos;
341341

342+
// if we are gcc or bcc, then get the version number
343+
if(!act_as_ld)
344+
gcc_version.get(native_tool_name);
345+
342346
if((cmdline.isset('v') && cmdline.have_infile_arg()) ||
343347
(cmdline.isset("version") && !produce_hybrid_binary))
344348
{
@@ -349,9 +353,16 @@ int gcc_modet::doit()
349353
std::cout << "GNU ld version 2.16.91 20050610 (goto-cc " CBMC_VERSION
350354
<< ")\n";
351355
else if(act_as_bcc)
352-
std::cout << "bcc: version 0.16.17 (goto-cc " CBMC_VERSION ")\n";
356+
std::cout << "bcc: version " << gcc_version
357+
<< " (goto-cc " CBMC_VERSION ")\n";
353358
else
354-
std::cout << "gcc version 3.4.4 (goto-cc " CBMC_VERSION ")\n";
359+
{
360+
if(gcc_version.flavor == gcc_versiont::flavort::CLANG)
361+
std::cout << "clang version " << gcc_version
362+
<< " (goto-cc " CBMC_VERSION ")\n";
363+
else
364+
std::cout << "gcc (goto-cc " CBMC_VERSION ") " << gcc_version << '\n';
365+
}
355366
}
356367

357368
compilet compiler(cmdline,
@@ -365,11 +376,17 @@ int gcc_modet::doit()
365376
if(produce_hybrid_binary)
366377
return run_gcc(compiler);
367378

368-
std::cout << '\n' <<
369-
"Copyright (C) 2006-2014 Daniel Kroening, Christoph Wintersteiger\n" <<
370-
"CBMC version: " CBMC_VERSION << '\n' <<
371-
"Architecture: " << config.this_architecture() << '\n' <<
372-
"OS: " << config.this_operating_system() << '\n';
379+
std::cout
380+
<< '\n'
381+
<< "Copyright (C) 2006-2018 Daniel Kroening, Christoph Wintersteiger\n"
382+
<< "CBMC version: " CBMC_VERSION << '\n'
383+
<< "Architecture: " << config.this_architecture() << '\n'
384+
<< "OS: " << config.this_operating_system() << '\n';
385+
386+
if(gcc_version.flavor == gcc_versiont::flavort::CLANG)
387+
std::cout << "clang: " << gcc_version << '\n';
388+
else
389+
std::cout << "gcc: " << gcc_version << '\n';
373390

374391
return EX_OK; // Exit!
375392
}
@@ -387,7 +404,7 @@ int gcc_modet::doit()
387404
if(cmdline.isset("dumpmachine"))
388405
std::cout << config.this_architecture() << '\n';
389406
else if(cmdline.isset("dumpversion"))
390-
std::cout << "3.4.4\n";
407+
std::cout << gcc_version << '\n';
391408

392409
// we don't have any meaningful output for the other options, and GCC
393410
// 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>
@@ -62,6 +63,8 @@ class gcc_modet:public goto_cc_modet
6263
const compilet &compiler);
6364

6465
static bool needs_preprocessing(const std::string &);
66+
67+
gcc_versiont gcc_version;
6568
};
6669

6770
#endif // CPROVER_GOTO_CC_GCC_MODE_H

0 commit comments

Comments
 (0)