Skip to content

Commit f8caa15

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.
1 parent ccdf530 commit f8caa15

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/goto-cc/gcc_cmdline.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ const char *gcc_options_without_argument[]=
163163
"-print-multi-directory",
164164
"-print-multi-lib",
165165
"-print-search-dirs",
166+
"-print-sysroot",
167+
"-print-sysroot-headers-suffix",
166168
"-Q",
167169
"-Qn",
168170
"-Qy",

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)