Skip to content

Commit e80008e

Browse files
committed
goto-cc: support GCC's print-sysroot* options
Hand these over to an underlying native compiler, and do the same for all dump* options. Includes clean-up of documentation placement and disable clang-format for the collection of options.
1 parent 38e6fa5 commit e80008e

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/goto-cc/gcc_cmdline.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ Author: CM Wintersteiger, 2006
1818

1919
#include <util/prefix.h>
2020

21-
/// parses the command line options into a cmdlinet
22-
/// \par parameters: argument count, argument strings
23-
/// \return none
21+
// clang-format off
2422
// non-gcc options
2523
const char *goto_cc_options_with_separated_argument[]=
2624
{
@@ -163,6 +161,8 @@ const char *gcc_options_without_argument[]=
163161
"-print-multi-directory",
164162
"-print-multi-lib",
165163
"-print-search-dirs",
164+
"-print-sysroot",
165+
"-print-sysroot-headers-suffix",
166166
"-Q",
167167
"-Qn",
168168
"-Qy",
@@ -211,7 +211,11 @@ const char *gcc_options_without_argument[]=
211211
"-fast", // Apple only
212212
nullptr
213213
};
214+
// clang-format on
214215

216+
/// parses the command line options into a cmdlinet
217+
/// \par parameters: argument count, argument strings
218+
/// \return none
215219
bool gcc_cmdlinet::parse(int argc, const char **argv)
216220
{
217221
assert(argc>0);

src/goto-cc/gcc_mode.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,24 @@ int gcc_modet::doit()
380380
return EX_OK; // Exit!
381381
}
382382

383-
if(cmdline.isset("dumpversion"))
383+
if(
384+
cmdline.isset("dumpmachine") || cmdline.isset("dumpspecs") ||
385+
cmdline.isset("dumpversion") || cmdline.isset("print-sysroot") ||
386+
cmdline.isset("print-sysroot-headers-suffix"))
384387
{
385388
if(produce_hybrid_binary)
386389
return run_gcc(compiler);
387390

388-
std::cout << "3.4.4\n";
391+
// GCC will only print one of these, even when multiple arguments are
392+
// passed, so we do the same
393+
if(cmdline.isset("dumpmachine"))
394+
std::cout << config.this_architecture() << '\n';
395+
else if(cmdline.isset("dumpversion"))
396+
std::cout << "3.4.4\n";
397+
398+
// we don't have any meaningful output for the other options, and GCC
399+
// doesn't necessarily produce non-empty output either
400+
389401
return EX_OK;
390402
}
391403

0 commit comments

Comments
 (0)