diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-06-14 16:05:57 +0000 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2017-06-14 17:05:57 +0100 |
commit | e72c4afd99c06e29b4f73f61ee0ff9091bf7fa02 (patch) | |
tree | 8b372d46d33e5b585b9e4735fe7bc7e234ad0e79 | |
parent | 4524009c09ac5148643c1226f6868ef38cc44e6c (diff) | |
download | gcc-e72c4afd99c06e29b4f73f61ee0ff9091bf7fa02.zip gcc-e72c4afd99c06e29b4f73f61ee0ff9091bf7fa02.tar.gz gcc-e72c4afd99c06e29b4f73f61ee0ff9091bf7fa02.tar.bz2 |
Recognize '-' as special -MF argument (write to stdout)
Sometimes it is useful to generate pre-processed output to a file and
the dependency information to stdout for further analysis/processing.
For example:
g++ -E -MD -fdirectives-only -o test.ii test.cxx
This will generate the dependency information to test.d (as per the
documentation). While changing this behavior is probably unwise, one
traditional (e.g., supported by -o) way to handle this is to recognize
the special '-' file name as an instruction to write to stdout:
g++ -E -MD -fdirectives-only -o test.ii -MF - test.cxx
Currently this will create a file named '-'. The included patch
changes this behavior to write to stdout.
Note also that Clang has supported this from at least version 3.5.
gcc:
2017-06-14 Boris Kolpackov <boris@codesynthesis.com>
* doc/cppopts.texi: Document '-' special value to -MF.
gcc/c-family:
2017-06-14 Boris Kolpackov <boris@codesynthesis.com>
* c-opts.c (c_common_finish): Handle '-' special value to -MF.
From-SVN: r249201
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/c-family/c-opts.c | 4 | ||||
-rw-r--r-- | gcc/doc/cppopts.texi | 2 |
4 files changed, 13 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 59ca506..2987e5e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2017-06-14 Boris Kolpackov <boris@codesynthesis.com> + + * doc/cppopts.texi: Document '-' special value to -MF. + 2017-06-14 Wilco Dijkstra <wdijkstr@arm.com> * config/arm/cortex-a53.md (cortex_a53_fpalu) Adjust latency. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 9387bb0..1eba1c6 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2017-06-14 Boris Kolpackov <boris@codesynthesis.com> + + * c-opts.c (c_common_finish): Handle '-' special value to -MF. + 2017-06-13 Marek Polacek <polacek@redhat.com> PR objc/80949 diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index be4478f..1657e7a 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -1150,6 +1150,8 @@ c_common_finish (void) output stream. */ if (!deps_file) deps_stream = out_stream; + else if (deps_file[0] == '-' && deps_file[1] == '\0') + deps_stream = stdout; else { deps_stream = fopen (deps_file, deps_append ? "a": "w"); @@ -1163,7 +1165,7 @@ c_common_finish (void) with cpp_destroy (). */ cpp_finish (parse_in, deps_stream); - if (deps_stream && deps_stream != out_stream + if (deps_stream && deps_stream != out_stream && deps_stream != stdout && (ferror (deps_stream) || fclose (deps_stream))) fatal_error (input_location, "closing dependency file %s: %m", deps_file); diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi index 0497712..16bf22a 100644 --- a/gcc/doc/cppopts.texi +++ b/gcc/doc/cppopts.texi @@ -125,6 +125,8 @@ preprocessed output. When used with the driver options @option{-MD} or @option{-MMD}, @option{-MF} overrides the default dependency output file. +If @var{file} is @file{-}, then the dependencies are written to @file{stdout}. + @item -MG @opindex MG In conjunction with an option such as @option{-M} requesting |