aboutsummaryrefslogtreecommitdiff
path: root/build2/cc/gcc.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'build2/cc/gcc.cxx')
-rw-r--r--build2/cc/gcc.cxx66
1 files changed, 26 insertions, 40 deletions
diff --git a/build2/cc/gcc.cxx b/build2/cc/gcc.cxx
index ce1450e..0ce4c4f 100644
--- a/build2/cc/gcc.cxx
+++ b/build2/cc/gcc.cxx
@@ -180,57 +180,43 @@ namespace build2
if (verb >= 3)
print_process (args);
+ process pr (run_start (xc, args.data (), -1)); // Open pipe to stdout.
+
string l;
try
{
- process pr (xc, args.data (), 0, -1); // Open pipe to stdout.
-
- try
+ ifdstream is (
+ move (pr.in_ofd), fdstream_mode::skip, ifdstream::badbit);
+
+ // The output of -print-search-dirs are a bunch of lines that start
+ // with "<name>: =" where name can be "install", "programs", or
+ // "libraries". If you have English locale, that is. If you set your
+ // LC_ALL="tr_TR", then it becomes "kurulum", "programlar", and
+ // "kitapl?klar". Also, Clang omits "install" while GCC and Intel icc
+ // print all three. The "libraries" seem to be alwasy last, however.
+ //
+ string s;
+ for (bool found (false); !found && getline (is, s); )
{
- ifdstream is (
- move (pr.in_ofd), fdstream_mode::skip, ifdstream::badbit);
-
- // The output of -print-search-dirs are a bunch of lines that start
- // with "<name>: =" where name can be "install", "programs", or
- // "libraries". If you have English locale, that is. If you set your
- // LC_ALL="tr_TR", then it becomes "kurulum", "programlar", and
- // "kitapl?klar". Also, Clang omits "install" while GCC and Intel
- // icc print all three. The "libraries" seem to be alwasy last,
- // however.
- //
- string s;
- for (bool found (false); !found && getline (is, s); )
- {
- found = (s.compare (0, 12, "libraries: =") == 0);
-
- size_t p (found ? 9 : s.find (": ="));
-
- if (p != string::npos)
- l.assign (s, p + 3, string::npos);
- }
+ found = (s.compare (0, 12, "libraries: =") == 0);
- is.close (); // Don't block.
+ size_t p (found ? 9 : s.find (": ="));
- if (!pr.wait ())
- throw failed (); // Assume issued diagnostics to stderr.
- }
- catch (const io_error&)
- {
- pr.wait ();
- fail << "error reading " << x_lang << " compiler -print-search-dirs "
- << "output";
+ if (p != string::npos)
+ l.assign (s, p + 3, string::npos);
}
+
+ is.close (); // Don't block.
}
- catch (const process_error& e)
+ catch (const io_error&)
{
- error << "unable to execute " << args[0] << ": " << e;
-
- if (e.child)
- exit (1);
-
- throw failed ();
+ pr.wait ();
+ fail << "error reading " << x_lang << " compiler -print-search-dirs "
+ << "output";
}
+ run_finish (args, pr);
+
if (l.empty ())
fail << "unable to extract " << x_lang << " compiler system library "
<< "search paths";