]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Do not abort compilation when dump file is /dev/*
authorGiuliano Belinassi <gbelinassi@suse.de>
Tue, 16 Nov 2021 16:25:32 +0000 (13:25 -0300)
committerGiuliano Belinassi <gbelinassi@suse.de>
Fri, 19 Nov 2021 14:27:21 +0000 (11:27 -0300)
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  <gbelinassi@suse.de>

* 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  <gbelinassi@suse.de>

* gcc.dg/devnull-dump.c: New.

Signed-off-by: Giuliano Belinassi <gbelinassi@suse.de>
gcc/doc/invoke.texi
gcc/gcc.c
gcc/testsuite/gcc.dg/devnull-dump.c [new file with mode: 0644]

index 1b02ea091975f2d4e92bae713e702fe6d3654e04..49c8befd58a4ba60752bb9c5657b84367a353836 100644 (file)
@@ -1880,7 +1880,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:
index 506c2acc282d61c6ddd0b6e4edbc28ee64cb7a9f..6ff22781042506450be791c83b4f37f2b7d7ecb6 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -5098,7 +5098,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 (file)
index 0000000..378e090
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-do assemble } */
+/* { dg-options "-fdump-ipa-clones -o /dev/null" } */
+
+int main()
+{
+  return 0;
+}