From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2100) id 9784B385800C; Fri, 19 Nov 2021 15:50:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9784B385800C MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Giuliano Belinassi To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9253] Do not abort compilation when dump file is /dev/* X-Act-Checkin: gcc X-Git-Author: Giuliano Belinassi X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: dc3630e05d7df3d9a93400e33710dd19be207da3 X-Git-Newrev: 753cd5f36158e0c99e25b171b2e44e2fbe86a064 Message-Id: <20211119155051.9784B385800C@sourceware.org> Date: Fri, 19 Nov 2021 15:50:51 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2021 15:50:51 -0000 https://gcc.gnu.org/g:753cd5f36158e0c99e25b171b2e44e2fbe86a064 commit r11-9253-g753cd5f36158e0c99e25b171b2e44e2fbe86a064 Author: Giuliano Belinassi Date: Tue Nov 16 13:25:32 2021 -0300 Do not abort compilation when dump file is /dev/* The `configure` scripts generated with autoconf often tests compiler features by setting output to `/dev/null`, which then sets the dump folder as being /dev/* and the compilation halts with an error because GCC cannot create files in /dev/. This is a problem when configure is testing for compiler features because it cannot tell if the failure was due to unsupported features or any other problem, and disable it even if it is working. As an example, running configure overriding CFLAGS="-fdump-ipa-clones" will result in several compiler-features as being disabled because of gcc halting with an error creating files in /dev/*. This commit fixes this issue by checking if the output file is /dev/null or /dev/zero. In this case we use the current working directory for dump output instead of the directory of the output file because we cannot write to /dev/*. gcc/ChangeLog 2021-11-16 Giuliano Belinassi * gcc.c (process_command): Skip dumpdir override if file is a not_actual_file_p. * doc/invoke.texi: Update -dumpdir documentation. gcc/testsuite/ChangeLog 2021-11-16 Giuliano Belinassi * gcc.dg/devnull-dump.c: New. (cherry-picked from commit c7381debe4c5dd7878338f38db98face1cfa6f90) Diff: --- gcc/doc/invoke.texi | 3 ++- gcc/gcc.c | 3 ++- gcc/testsuite/gcc.dg/devnull-dump.c | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 95a2949cd22..5a4b3c6c234 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1865,7 +1865,8 @@ named @file{dir/bar.*}, combining the given @var{dumppfx} with the default @var{dumpbase} derived from the primary output name. Dump outputs also take the input name suffix: @file{dir/bar.c.*}. -It defaults to the location of the output file; options +It defaults to the location of the output file, unless the output +file is a special file like @code{/dev/null}. Options @option{-save-temps=cwd} and @option{-save-temps=obj} override this default, just like an explicit @option{-dumpdir} option. In case multiple such options are given, the last one prevails: diff --git a/gcc/gcc.c b/gcc/gcc.c index 4d790f9dd4a..8ba410c9e17 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -4991,7 +4991,8 @@ process_command (unsigned int decoded_options_count, bool explicit_dumpdir = dumpdir; - if (!save_temps_overrides_dumpdir && explicit_dumpdir) + if ((!save_temps_overrides_dumpdir && explicit_dumpdir) + || (output_file && not_actual_file_p (output_file))) { /* Do nothing. */ } diff --git a/gcc/testsuite/gcc.dg/devnull-dump.c b/gcc/testsuite/gcc.dg/devnull-dump.c new file mode 100644 index 00000000000..378e0901c28 --- /dev/null +++ b/gcc/testsuite/gcc.dg/devnull-dump.c @@ -0,0 +1,7 @@ +/* { dg-do assemble } */ +/* { dg-options "-fdump-ipa-clones -o /dev/null" } */ + +int main() +{ + return 0; +}