public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101546] New: Sporadic issue during compiling a code with a '--save-temps' option
@ 2021-07-21  9:02 filip.bascarevic at siemens dot com
  2021-07-21 13:24 ` [Bug driver/101546] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: filip.bascarevic at siemens dot com @ 2021-07-21  9:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101546

            Bug ID: 101546
           Summary: Sporadic issue during compiling a code with a
                    '--save-temps' option
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: filip.bascarevic at siemens dot com
  Target Milestone: ---

Created attachment 51185
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51185&action=edit
Patch file for the --save-temps bug

Dear GCC community, 

We saw one problem in a GCC 11.1.0. We faced sporadic issue during compiling a
code with a '--save-temps' option. Generally the gcc.exe creates temporary
files containing all include-paths and call internally cc1.exe but in the gcc
10.2.0 these files have random names but in a gcc 11.1.0 names are not random
(it is .args.0). So during parallel compilation it can happen that the file can
be overwritten. Problematic part of a code is at path "gcc-11.1.0/gcc/gcc.c"

Source :Gcc.c
/* Create a temporary @file name.  */

static char *make_at_file (void)
{
  static int fileno = 0;
  char filename[20];
  const char *base, *ext;

  if (!save_temps_flag)  <- skipped for -save-temps
    return make_temp_file (""); <- This function generate a random file name

  base = dumpbase;
  if (!(base && *base))
    base = dumpdir;
  if (!(base && *base))
    base = "a";

  sprintf (filename, ".args.%d", fileno++);  <- fixed file name
  ext = filename;

  if (base == dumpdir && dumpdir_trailing_dash_added)
    ext++;

  return concat (base, ext, NULL);
}

For us we prepared a fix and it seems it works. If you agree with our solution
you can also apply this patch in a next versions of the GCC. The patch is in
the attachment.

With best regards,
MSc. Filip Bascarevic

Siemens, s.r.o.
ADV D EU CZ AE AC 4
Anglicke nabrezi 2434/1
301 00 Plzen, Czech Republic 
filip.bascarevic@siemens.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug driver/101546] Sporadic issue during compiling a code with a '--save-temps' option
  2021-07-21  9:02 [Bug c/101546] New: Sporadic issue during compiling a code with a '--save-temps' option filip.bascarevic at siemens dot com
@ 2021-07-21 13:24 ` rguenth at gcc dot gnu.org
  2021-07-22  7:14 ` stanislav.simek at siemens dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-21 13:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101546

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1
          Component|c                           |driver
                 CC|                            |aoliva at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
   Last reconfirmed|                            |2021-07-21

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The whole point is that with -save-temps temporary filenames become
deterministic.  GCC 11 in addition changed how those auxiliary filenames are
chosen.  Can you share two different example compiler commands that end up
creating conflicting names?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug driver/101546] Sporadic issue during compiling a code with a '--save-temps' option
  2021-07-21  9:02 [Bug c/101546] New: Sporadic issue during compiling a code with a '--save-temps' option filip.bascarevic at siemens dot com
  2021-07-21 13:24 ` [Bug driver/101546] " rguenth at gcc dot gnu.org
@ 2021-07-22  7:14 ` stanislav.simek at siemens dot com
  2021-07-22 11:23 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: stanislav.simek at siemens dot com @ 2021-07-22  7:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101546

Stanislav Šimek <stanislav.simek at siemens dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stanislav.simek at siemens dot com

--- Comment #2 from Stanislav Šimek <stanislav.simek at siemens dot com> ---
First Command
Command Line: mips_gcc_sde_elf_10.2.0/bin/mips-sde-elf-gcc    -O0 -Wunused
-Wreturn-type -Wundef -fno-common -fno-merge-constants -g  -UNDEBUG 
-save-temps=obj  -IAAA/FolderA    -fno-builtin -c -std=gnu99 -nostdinc -G0
-mips32r2 -EL -fdata-sections -ffunction-sections    -MD -MF tlb.d -o tlb.o
tlb.c 

Second command
Command Line: mips_gcc_sde_elf_10.2.0/bin/mips-sde-elf-gcc    -O0 -Wunused
-Wreturn-type -Wundef -fno-common -fno-merge-constants -g  -UNDEBUG 
-save-temps=obj  -IAAA/FolderA    -fno-builtin -c -std=gnu99 -nostdinc -G0
-mips32r2 -EL -fdata-sections -ffunction-sections    -MD -MF tlba.d -o tlba.o
tlba.c 

Both commands are called in parallel.
If gcc.exe calls  cc1.exe :
 mips_gcc_sde_elf_11.1.0/bin/../libexec/gcc/mips-sde-elf/11.1.0/cc1.exe -E
-quiet -nostdinc -v @.args.0 ----

Include paths are taken over by file that has aways same name ".args.0"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug driver/101546] Sporadic issue during compiling a code with a '--save-temps' option
  2021-07-21  9:02 [Bug c/101546] New: Sporadic issue during compiling a code with a '--save-temps' option filip.bascarevic at siemens dot com
  2021-07-21 13:24 ` [Bug driver/101546] " rguenth at gcc dot gnu.org
  2021-07-22  7:14 ` stanislav.simek at siemens dot com
@ 2021-07-22 11:23 ` rguenth at gcc dot gnu.org
  2021-07-23  5:06 ` stanislav.simek at siemens dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-22 11:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101546

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Stanislav Šimek from comment #2)
> First Command
> Command Line: mips_gcc_sde_elf_10.2.0/bin/mips-sde-elf-gcc    -O0 -Wunused
> -Wreturn-type -Wundef -fno-common -fno-merge-constants -g  -UNDEBUG 
> -save-temps=obj  -IAAA/FolderA    -fno-builtin -c -std=gnu99 -nostdinc -G0
> -mips32r2 -EL -fdata-sections -ffunction-sections    -MD -MF tlb.d -o tlb.o
> tlb.c 
> 
> Second command
> Command Line: mips_gcc_sde_elf_10.2.0/bin/mips-sde-elf-gcc    -O0 -Wunused
> -Wreturn-type -Wundef -fno-common -fno-merge-constants -g  -UNDEBUG 
> -save-temps=obj  -IAAA/FolderA    -fno-builtin -c -std=gnu99 -nostdinc -G0
> -mips32r2 -EL -fdata-sections -ffunction-sections    -MD -MF tlba.d -o
> tlba.o tlba.c 

the above uses mips_gcc_sde_elf_10.2.0/bin/mips-sde-elf-gcc

> Both commands are called in parallel.
> If gcc.exe calls  cc1.exe :
>  mips_gcc_sde_elf_11.1.0/bin/../libexec/gcc/mips-sde-elf/11.1.0/cc1.exe -E
> -quiet -nostdinc -v @.args.0 ----
> 
> Include paths are taken over by file that has aways same name ".args.0"

but this refers to some 11.1.0 compiler.

Note the function you patch can only be invoked if there was an @ file
supplied on the command-line as far as I can see.  But even when I supply
an @ file on the command-line on x86_64-linux I don't get this path
triggered.  Can you post the output of one of the offending commands with -v
appended please?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug driver/101546] Sporadic issue during compiling a code with a '--save-temps' option
  2021-07-21  9:02 [Bug c/101546] New: Sporadic issue during compiling a code with a '--save-temps' option filip.bascarevic at siemens dot com
                   ` (2 preceding siblings ...)
  2021-07-22 11:23 ` rguenth at gcc dot gnu.org
@ 2021-07-23  5:06 ` stanislav.simek at siemens dot com
  2021-07-27  6:24 ` rguenth at gcc dot gnu.org
  2021-07-27  6:24 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: stanislav.simek at siemens dot com @ 2021-07-23  5:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101546

--- Comment #4 from Stanislav Šimek <stanislav.simek at siemens dot com> ---
Hi this is copy paste mistake, we are using same compile comands for 11.1.0 and
10.2.

Correct one
Command Line: mips_gcc_sde_elf_11.1.0/bin/mips-sde-elf-gcc    -O0 -Wunused
> -Wreturn-type -Wundef -fno-common -fno-merge-constants -g  -UNDEBUG 
> -save-temps=obj  -IAAA/FolderA    -fno-builtin -c -std=gnu99 -nostdinc -G0
> -mips32r2 -EL -fdata-sections -ffunction-sections    -MD -MF tlb.d -o tlb.o
> tlb.c 
> 
> Second command
> Command Line: mips_gcc_sde_elf_11.1.0/bin/mips-sde-elf-gcc    -O0 -Wunused
> -Wreturn-type -Wundef -fno-common -fno-merge-constants -g  -UNDEBUG 
> -save-temps=obj  -IAAA/FolderA    -fno-builtin -c -std=gnu99 -nostdinc -G0
> -mips32r2 -EL -fdata-sections -ffunction-sections    -MD -MF tlba.d -o
> tlba.o tlba.c



-V command
Using built-in specs.
COLLECT_GCC=D:\git\s7p.cpu1500_1\s7p.tools\mips_gcc_sde_elf_11.1.0\bin\mips-sde-elf-gcc
Target: mips-sde-elf
Configured with: ../../gcc-11.1.0//configure --host=x86_64-w64-mingw32
--build=x86_64-w64-mingw32
--prefix=/build/mips-sde-elf_11.1.0/cross-gcc/mips-sde-elf
--target=mips-sde-elf --disable-nls --enable-multilib
--enable-poison-system-directories --enable-languages=c,c++
--disable-decimal-float --with-mips-plt
--with-sysroot=/build/mips-sde-elf_11.1.0/cross-gcc/mips-sde-elf
--without-headers --disable-shared --disable-threads --disable-lto
--disable-libmudflap --disable-libssp --disable-libgomp --disable-libffi
--disable-libstdcxx-pch --disable-win32-registry
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm'
--with-newlib --with-gcc --with-gnu-as --with-gnu-ld --with-arch=mips32r2
--enable-sgxx-sde-multilibs --with-gmp=/build/mips-sde-elf_11.1.0/host
--with-mpfr=/build/mips-sde-elf_11.1.0/host
--with-mpc=/build/mips-sde-elf_11.1.0/host
--with-isl=/build/mips-sde-elf_11.1.0/host
--with-zstd=/build/mips-sde-elf_11.1.0/host : (reconfigured)
../../gcc-11.1.0//configure --host=x86_64-w64-mingw32
--build=x86_64-w64-mingw32 --enable-languages=c,c++ --enable-multilib
--with-mips-plt --enable-sgxx-sde-multilibs --with-arch=mips32r2
--enable-poison-system-directories --enable-interwork --disable-lto
--disable-libmudflap --disable-libssp --disable-libgomp --disable-libffi
--with-newlib --with-gcc --with-gnu-ld --with-gnu-as --with-stabs
--disable-shared --disable-threads --disable-win32-registry --disable-nls
--disable-libstdcxx-pch --with-host-libstdcxx='-static-libgcc
-Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --target=mips-sde-elf
--prefix=/build/mips-sde-elf_11.1.0/cross-gcc/mips-sde-elf
--with-gmp=/build/mips-sde-elf_11.1.0/host
--with-mpfr=/build/mips-sde-elf_11.1.0/host
--with-mpc=/build/mips-sde-elf_11.1.0/host
--with-isl=/build/mips-sde-elf_11.1.0/host
--with-zstd=/build/mips-sde-elf_11.1.0/host
--with-sysroot=/build/mips-sde-elf_11.1.0/cross-gcc/mips-sde-elf
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 11.1.0 (GCC) 
COLLECT_GCC_OPTIONS= -I###INCLUDEPATHS### '-O3' '-Wunused' '-Wreturn-type'
'-Wundef' '-fno-common' '-fno-merge-constants' '-ffunction-sections'
'-fdata-sections' '-g' '-U' 'NDEBUG' '-save-temps=obj' '-fno-builtin'
'-mlong-calls' '-c' '-std=gnu99' '-nostdinc' '-G' '0' '-mips32r2' '-EL' '-v'
'-o' 'AAAA/abc.o' '-mplt' '-mabi=32' '-dumpdir' 'BBBB'
 mips_gcc_sde_elf_11.1.0/bin/../libexec/gcc/mips-sde-elf/11.1.0/cc1.exe -E
-quiet -nostdinc -v @AAAA/.args.0 -imultilib el -iprefix
\mips_gcc_sde_elf_11.1.0\bin\../lib/gcc/mips-sde-elf/11.1.0/ AAAA/abc.c -G 0
-mel -mlong-calls -mips32r2 -mplt -mabi=32 -std=gnu99 -Wunused -Wreturn-type
-Wundef -fno-common -fno-merge-constants -ffunction-sections -fdata-sections
-fno-builtin -g -fworking-directory -O3 -fpch-preprocess -o BBBB/abc.i
#include "..." search starts here:
#include <...> search starts here:
 s7p.os_infra/adonis/arch/mips/soc12

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug driver/101546] Sporadic issue during compiling a code with a '--save-temps' option
  2021-07-21  9:02 [Bug c/101546] New: Sporadic issue during compiling a code with a '--save-temps' option filip.bascarevic at siemens dot com
                   ` (3 preceding siblings ...)
  2021-07-23  5:06 ` stanislav.simek at siemens dot com
@ 2021-07-27  6:24 ` rguenth at gcc dot gnu.org
  2021-07-27  6:24 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-27  6:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101546

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
               Host|                            |x86_64-w64-mingw32

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
We seem to have a mix of DOS and UNIX path separators, not sure if this messes
up logic somewhere.  But we're supposed to prefix the temporary filename with
the
-dumpbase argument but I only see -dumpdir.

So this looks somehow host specific and since I lack access to a mingw host I
can't check myself.  Leaving to people who have such access - or, since you
already produced a patch maybe you can trace through the driver invocation
to see why it fails to add a -dumpbase argument to the cc1.exe invocation.
-dumpbase should be derived from the input filename.  See the largish comment
in process_command before the -save-temps processing.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug driver/101546] Sporadic issue during compiling a code with a '--save-temps' option
  2021-07-21  9:02 [Bug c/101546] New: Sporadic issue during compiling a code with a '--save-temps' option filip.bascarevic at siemens dot com
                   ` (4 preceding siblings ...)
  2021-07-27  6:24 ` rguenth at gcc dot gnu.org
@ 2021-07-27  6:24 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-27  6:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101546

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |UNCONFIRMED
     Ever confirmed|1                           |0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-27  6:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21  9:02 [Bug c/101546] New: Sporadic issue during compiling a code with a '--save-temps' option filip.bascarevic at siemens dot com
2021-07-21 13:24 ` [Bug driver/101546] " rguenth at gcc dot gnu.org
2021-07-22  7:14 ` stanislav.simek at siemens dot com
2021-07-22 11:23 ` rguenth at gcc dot gnu.org
2021-07-23  5:06 ` stanislav.simek at siemens dot com
2021-07-27  6:24 ` rguenth at gcc dot gnu.org
2021-07-27  6:24 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).