public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100462] New: g++ fails to find the a pre-compiled header
@ 2021-05-06 20:29 mail at 3v1n0 dot net
  2021-05-06 20:39 ` [Bug c++/100462] g++ fails to find a generated " mail at 3v1n0 dot net
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: mail at 3v1n0 dot net @ 2021-05-06 20:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100462
           Summary: g++ fails to find the a pre-compiled header
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mail at 3v1n0 dot net
  Target Milestone: ---

Unfortunately I've not a minimal test case for this, but in gjs we can't use
pre-compiled headers with g++ (while they work fine with clang++).

In particular, we get this error:

 cc1plus: fatal error: gjs_pch.hh: No such file or director

When in the build directory (that is included) there's a pch file
(_build/libgjs.so.0.0.0.p/gjs_pch.hh.pch).
This happens no matter what's in the pch source (can be just an include).

 An example failure is visible at:
  - https://gitlab.gnome.org/3v1n0/gjs/-/jobs/1288211 (see job artifacts for
more logs)


While the file gets used by clang++
(https://gitlab.gnome.org/3v1n0/gjs/-/jobs/1288273)

The best way to reproduce this is:
  git clone https://gitlab.gnome.org/3v1n0/gjs -b pch
  cd gjs
  meson _build -Db_pch=true
  ninja -C _build

I tried to make a minimal reproducer, but can't define one.

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
@ 2021-05-06 20:39 ` mail at 3v1n0 dot net
  2021-05-06 22:43 ` pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mail at 3v1n0 dot net @ 2021-05-06 20:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Marco Trevisan <mail at 3v1n0 dot net> ---
Some verbose logging:

unstable /data/GNOME/gjs
❯ echo $PWD                                           
/data/GNOME/gjs

unstable /data/GNOME/gjs 
❯ ls _build/libgjs.so.0.0.0.p -lht
total 119M
-rw-rw-r-- 1 marco marco 119M mag  6 22:37 gjs_pch.hh.gch
-rw-rw-r-- 1 marco marco  43K mag  6 22:37 libgjs-private_gjs-gdbus-wrapper.c.o
-rw-rw-r-- 1 marco marco  21K mag  6 22:37 libgjs-private_gjs-util.c.o
-rw-rw-r-- 1 marco marco 251K mag  6 22:37 meson-generated_.._js-resources.c.o
-rw-rw-r-- 1 marco marco 3,2K mag  6 22:37 gjs_gi_probes.o
-rw-rw-r-- 1 marco marco 1,5K mag  6 22:37 gjs_gi_probes.h
-rw-rw-r-- 1 marco marco  186 mag  6 22:37 GjsPrivate_1.0_gir_filelist


g++ -v -Ilibgjs.so.0.0.0.p -I. -I.. -I/opt/dev/GNOME/include/glib-2.0
-I/opt/dev/GNOME/lib/glib-2.0/include
-I/opt/dev/GNOME/include/gobject-introspection-1.0
-I/opt/dev/GNOME/include/pixman-1 -I/usr/include/cairo -I/usr/include/uuid
-I/usr/include/freetype2 -I/usr/include/libpng16 -fvisibility=hidden
-fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch
-Wnon-virtual-dtor -Wextra -std=c++17 -fno-rtti -g -fno-strict-aliasing
-Wno-variadic-macros -Wno-missing-field-initializers
-fno-semantic-interposition -fPIC -pthread
-isystem/opt/dev/GNOME/include/sysprof-4 -include
/usr/include/mozjs-78/js/RequiredDefines.h -isystem /usr/include/mozjs-78
-DGJS_COMPILATION '-DGJS_JS_DIR="/usr/local/share/gjs-1.0"'
'-DPKGLIBDIR="/usr/local/lib/x86_64-linux-gnu/gjs"' '-DG_LOG_DOMAIN="Gjs"'
-fpch-preprocess -include gjs_pch.hh -MD -MQ
libgjs.so.0.0.0.p/gi_arg-cache.cpp.o -MF libgjs.so.0.0.0.p/gi_arg-cache.cpp.o.d
-o libgjs.so.0.0.0.p/gi_arg-cache.cpp.o -c ../gi/arg-cache.cpp
Using built-in specs.
COLLECT_GCC=g++
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 10.3.0-1ubuntu1'
--with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-10
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib
--enable-libphobos-checking=release --with-target-system-zlib=auto
--enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-10-gDeRY6/gcc-10-10.3.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-gDeRY6/gcc-10-10.3.0/debian/tmp-gcn/usr,hsa
--without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
--with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.3.0 (Ubuntu 10.3.0-1ubuntu1) 
COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-v' '-I' 'libgjs.so.0.0.0.p'
'-I' '.' '-I' '..' '-I' '/opt/dev/GNOME/include/glib-2.0' '-I'
'/opt/dev/GNOME/lib/glib-2.0/include' '-I'
'/opt/dev/GNOME/include/gobject-introspection-1.0' '-I'
'/opt/dev/GNOME/include/pixman-1' '-I' '/usr/include/cairo' '-I'
'/usr/include/uuid' '-I' '/usr/include/freetype2' '-I' '/usr/include/libpng16'
'-fvisibility=hidden' '-pipe' '-D' '_FILE_OFFSET_BITS=64' '-Wall'
'-Winvalid-pch' '-Wnon-virtual-dtor' '-Wextra' '-std=c++17' '-fno-rtti' '-g'
'-fno-strict-aliasing' '-Wno-variadic-macros' '-Wno-missing-field-initializers'
'-fno-semantic-interposition' '-fPIC' '-pthread' '-isystem'
'/opt/dev/GNOME/include/sysprof-4' '-include'
'/usr/include/mozjs-78/js/RequiredDefines.h' '-isystem' '/usr/include/mozjs-78'
'-D' 'GJS_COMPILATION' '-D' 'GJS_JS_DIR="/usr/local/share/gjs-1.0"' '-D'
'PKGLIBDIR="/usr/local/lib/x86_64-linux-gnu/gjs"' '-D' 'G_LOG_DOMAIN="Gjs"'
'-fpch-preprocess' '-include' 'gjs_pch.hh' '-MD' '-MQ'
'libgjs.so.0.0.0.p/gi_arg-cache.cpp.o' '-MF'
'libgjs.so.0.0.0.p/gi_arg-cache.cpp.o.d' '-o'
'libgjs.so.0.0.0.p/gi_arg-cache.cpp.o' '-c' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/10/cc1plus -quiet -v -I libgjs.so.0.0.0.p -I .
-I .. -I /opt/dev/GNOME/include/glib-2.0 -I /opt/dev/GNOME/lib/glib-2.0/include
-I /opt/dev/GNOME/include/gobject-introspection-1.0 -I
/opt/dev/GNOME/include/pixman-1 -I /usr/include/cairo -I /usr/include/uuid -I
/usr/include/freetype2 -I /usr/include/libpng16 -imultiarch x86_64-linux-gnu
-MD libgjs.so.0.0.0.p/gi_arg-cache.cpp.d -MF
libgjs.so.0.0.0.p/gi_arg-cache.cpp.o.d -MQ libgjs.so.0.0.0.p/gi_arg-cache.cpp.o
-D_GNU_SOURCE -D_REENTRANT -D _FILE_OFFSET_BITS=64 -D GJS_COMPILATION -D
GJS_JS_DIR="/usr/local/share/gjs-1.0" -D
PKGLIBDIR="/usr/local/lib/x86_64-linux-gnu/gjs" -D G_LOG_DOMAIN="Gjs" -isystem
/opt/dev/GNOME/include/sysprof-4 -include
/usr/include/mozjs-78/js/RequiredDefines.h -isystem /usr/include/mozjs-78
-include gjs_pch.hh ../gi/arg-cache.cpp -quiet -dumpbase arg-cache.cpp
-mtune=generic -march=x86-64 -auxbase-strip
libgjs.so.0.0.0.p/gi_arg-cache.cpp.o -g -Wall -Winvalid-pch -Wnon-virtual-dtor
-Wextra -Wno-variadic-macros -Wno-missing-field-initializers -std=c++17
-version -fdiagnostics-color=always -fvisibility=hidden -fno-rtti
-fno-strict-aliasing -fno-semantic-interposition -fPIC -fpch-preprocess
-fasynchronous-unwind-tables -fstack-protector-strong -Wformat-security
-fstack-clash-protection -fcf-protection -o - |
 as -v -I libgjs.so.0.0.0.p -I . -I .. -I /opt/dev/GNOME/include/glib-2.0 -I
/opt/dev/GNOME/lib/glib-2.0/include -I
/opt/dev/GNOME/include/gobject-introspection-1.0 -I
/opt/dev/GNOME/include/pixman-1 -I /usr/include/cairo -I /usr/include/uuid -I
/usr/include/freetype2 -I /usr/include/libpng16 --64 -o
libgjs.so.0.0.0.p/gi_arg-cache.cpp.o
GNU assembler version 2.36.1 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Ubuntu) 2.36.1
GNU C++17 (Ubuntu 10.3.0-1ubuntu1) version 10.3.0 (x86_64-linux-gnu)
        compiled by GNU C version 10.3.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/10"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/10/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/opt/dev/include"
#include "..." search starts here:
#include <...> search starts here:
 libgjs.so.0.0.0.p
 .
 ..
 /opt/dev/GNOME/include/glib-2.0
 /opt/dev/GNOME/lib/glib-2.0/include
 /opt/dev/GNOME/include/gobject-introspection-1.0
 /opt/dev/GNOME/include/pixman-1
 /usr/include/cairo
 /usr/include/uuid
 /usr/include/freetype2
 /usr/include/libpng16
 /opt/dev/GNOME/include/sysprof-4
 /usr/include/mozjs-78
 /opt/dev/GNOME/include
 /usr/include/c++/10
 /usr/include/x86_64-linux-gnu/c++/10
 /usr/include/c++/10/backward
 /usr/lib/gcc/x86_64-linux-gnu/10/include
 /usr/local/include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C++17 (Ubuntu 10.3.0-1ubuntu1) version 10.3.0 (x86_64-linux-gnu)
        compiled by GNU C version 10.3.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.0, isl version isl-0.23-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 118e824ee50d24f402f1f2e0e1ebfb12
cc1plus: fatal error: gjs_pch.hh: No such file or directory
compilation terminated.
ninja: build stopped: subcommand failed.

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
  2021-05-06 20:39 ` [Bug c++/100462] g++ fails to find a generated " mail at 3v1n0 dot net
@ 2021-05-06 22:43 ` pinskia at gcc dot gnu.org
  2021-05-07 14:29 ` mail at 3v1n0 dot net
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-05-06 22:43 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Running GCC under strace (with -f option since GCC forks off to exec cc1plus).
Should be able to see where the files are being tested for.

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
  2021-05-06 20:39 ` [Bug c++/100462] g++ fails to find a generated " mail at 3v1n0 dot net
  2021-05-06 22:43 ` pinskia at gcc dot gnu.org
@ 2021-05-07 14:29 ` mail at 3v1n0 dot net
  2021-05-07 14:36 ` mail at 3v1n0 dot net
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mail at 3v1n0 dot net @ 2021-05-07 14:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marco Trevisan <mail at 3v1n0 dot net> ---
Created attachment 50775
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50775&action=edit
strace.log

This is crazy, as even according to strace the file isn't there...

But it is and it's valid.
❯ ls -lht _build/libgjs-jsapi.a.p 
total 119M
-rw-rw-r-- 1 marco marco 119M mag  7 16:20 gjs_pch.hh.gch


[pid 1168435] openat(AT_FDCWD, "./gjs_pch.hh", O_RDONLY|O_NOCTTY) = -1 ENOENT
(No such file or directory)
[pid 1168435] openat(AT_FDCWD, "libgjs.so.0.0.0.p/gjs_pch.hh",
O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)
[pid 1168435] openat(AT_FDCWD, "../gjs_pch.hh", O_RDONLY|O_NOCTTY) = -1 ENOENT
(No such file or directory)
[pid 1168435] openat(AT_FDCWD, "/opt/dev/GNOME/include/glib-2.0/gjs_pch.hh",
O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)
[pid 1168435] openat(AT_FDCWD,
"/opt/dev/GNOME/lib/glib-2.0/include/gjs_pch.hh", O_RDONLY|O_NOCTTY) = -1
ENOENT (No such file or directory)
[pid 1168435] openat(AT_FDCWD,
"/opt/dev/GNOME/include/gobject-introspection-1.0/gjs_pch.hh",
O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)
[pid 1168435] openat(AT_FDCWD, "/opt/dev/GNOME/include/pixman-1/gjs_pch.hh",
O_RDONLY|O_NOCTTY) = -1 ENOENT (No such file or directory)


Same is also running manually (with CWD in _build directory):

strace -f g++ -v -Ilibgjs-jsapi.a.p -I. -I.. -I/opt/dev/GNOME/include/glib-2.0
-I/opt/dev/GNOME/lib/glib-2.0/include
-I/opt/dev/GNOME/include/gobject-introspection-1.0
-I/opt/dev/GNOME/include/pixman-1 -I/usr/include/cairo -I/usr/include/uuid
-I/usr/include/freetype2 -I/usr/include/libpng16 -fdiagnostics-color=always
-pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra
-std=c++17 -fno-rtti -g -fno-strict-aliasing -Wno-variadic-macros
-Wno-missing-field-initializers -fno-semantic-interposition -fPIC -pthread
-isystem/opt/dev/GNOME/include/sysprof-4 -include
/usr/include/mozjs-78/js/RequiredDefines.h -isystem /usr/include/mozjs-78
-DGJS_COMPILATION '-DGJS_JS_DIR="/usr/local/share/gjs-1.0"'
'-DPKGLIBDIR="/usr/local/lib/x86_64-linux-gnu/gjs"' '-DG_LOG_DOMAIN="Gjs"'
-fpch-preprocess -include gjs_pch.hh -MD -MQ
libgjs-jsapi.a.p/gjs_jsapi-dynamic-class.cpp.o -MF
libgjs-jsapi.a.p/gjs_jsapi-dynamic-class.cpp.o.d -o
libgjs-jsapi.a.p/gjs_jsapi-dynamic-class.cpp.o -c
../gjs/jsapi-dynamic-class.cpp

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
                   ` (2 preceding siblings ...)
  2021-05-07 14:29 ` mail at 3v1n0 dot net
@ 2021-05-07 14:36 ` mail at 3v1n0 dot net
  2021-05-07 14:43 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mail at 3v1n0 dot net @ 2021-05-07 14:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Marco Trevisan <mail at 3v1n0 dot net> ---
(In reply to Marco Trevisan from comment #3)
> Created attachment 50775 [details]
> strace.log
> 
> This is crazy, as even according to strace the file isn't there...
> 
> But it is and it's valid.
> ❯ ls -lht _build/libgjs-jsapi.a.p 
> total 119M
> -rw-rw-r-- 1 marco marco 119M mag  7 16:20 gjs_pch.hh.gch

Ah, wait... The file isn't there of course, but it doesn't even try to load the
precompiled `gjs_pch.hh.gch` file there...

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
                   ` (3 preceding siblings ...)
  2021-05-07 14:36 ` mail at 3v1n0 dot net
@ 2021-05-07 14:43 ` jakub at gcc dot gnu.org
  2021-05-07 14:59 ` mail at 3v1n0 dot net
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-07 14:43 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
As documented - see https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html
- PCH is only tried if no C token is seen before the #include directive
(comments and preprocessor directives like #if/#ifdef/#define/#undef are fine,
but e.g. #pragma is not).
So, is #include "gjs_pch.hh" the first thing in your sources?

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
                   ` (4 preceding siblings ...)
  2021-05-07 14:43 ` jakub at gcc dot gnu.org
@ 2021-05-07 14:59 ` mail at 3v1n0 dot net
  2021-05-07 15:01 ` mail at 3v1n0 dot net
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mail at 3v1n0 dot net @ 2021-05-07 14:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Marco Trevisan <mail at 3v1n0 dot net> ---
(In reply to Jakub Jelinek from comment #5)
> As documented - see
> https://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html - PCH is only
> tried if no C token is seen before the #include directive (comments and
> preprocessor directives like #if/#ifdef/#define/#undef are fine, but e.g.
> #pragma is not).
> So, is #include "gjs_pch.hh" the first thing in your sources?

Well it's not because I instead was following the approach of

> This also works with -include. So yet another way to use precompiled headers, good for projects not designed with precompiled header files in mind, is to simply take most of the header files used by a project, include them from another header file, precompile that header file, and -include the precompiled header. If the header files have guards against multiple inclusion, they are skipped because they’ve already been included (in the precompiled header). 


Thus, `-include` is ignored here it seems... Because it comes after another
include...

As per this I think the minimal reproducer is actually easy to have:

// main.c
int main(int argc, char**argv)
{
  std::string s = "Hi";
  return 0;
}

// header.h
#include <string>

----

mkdir _build
g++ -c header.h -o _build/gjs_pch.h.gch

# Works
g++ -I _build main.c -o main -include string -include gjs_pch.h

# Fails
g++ -I _build main.c -o main -include string -include gjs_pch.h


cc1plus: fatal error: gjs_pch.h: No such file or directory

So, in this case I'm not sure that the pch should be ignored...

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
                   ` (5 preceding siblings ...)
  2021-05-07 14:59 ` mail at 3v1n0 dot net
@ 2021-05-07 15:01 ` mail at 3v1n0 dot net
  2021-05-07 17:14 ` [Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include` mail at 3v1n0 dot net
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mail at 3v1n0 dot net @ 2021-05-07 15:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Marco Trevisan <mail at 3v1n0 dot net> ---
(In reply to Marco Trevisan from comment #6)
> # Works
> g++ -I _build main.c -o main -include string -include gjs_pch.h


Ouch, I forgot to delete an include after pasting

# Works
g++ -I _build main.c -o main -include gjs_pch.h

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
                   ` (6 preceding siblings ...)
  2021-05-07 15:01 ` mail at 3v1n0 dot net
@ 2021-05-07 17:14 ` mail at 3v1n0 dot net
  2021-05-07 17:50 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mail at 3v1n0 dot net @ 2021-05-07 17:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Marco Trevisan <mail at 3v1n0 dot net> ---
It's also relevant to say that just using 

main.c:

#include "gjs_pch.h"

int main(int argc, char**argv)
{
  std::string s = "Hi";
  return 0;
}

fails with:

❯ g++ -I _build main.c -o main -include string                   
/tmp/main.c:1:10: fatal error: gjs_pch.h: No such file or directory
    1 | #include "gjs_pch.h"
      |          ^~~~~~~~~~~


While works when not passing any `-include` to the command line

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
                   ` (7 preceding siblings ...)
  2021-05-07 17:14 ` [Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include` mail at 3v1n0 dot net
@ 2021-05-07 17:50 ` jakub at gcc dot gnu.org
  2021-05-07 17:52 ` mail at 3v1n0 dot net
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-07 17:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
<string> certainly contains lots of tokens, so you can't expect PCH to work
after including that header.  It needs to go before that.

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
                   ` (8 preceding siblings ...)
  2021-05-07 17:50 ` jakub at gcc dot gnu.org
@ 2021-05-07 17:52 ` mail at 3v1n0 dot net
  2021-05-07 17:59 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mail at 3v1n0 dot net @ 2021-05-07 17:52 UTC (permalink / raw)
  To: gcc-bugs

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

Marco Trevisan <mail at 3v1n0 dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |---

--- Comment #10 from Marco Trevisan <mail at 3v1n0 dot net> ---
(In reply to Jakub Jelinek from comment #9)
> <string> certainly contains lots of tokens, so you can't expect PCH to work
> after including that header.  It needs to go before that.

Could be any include... The point here is that any `-include` in command line
breaks pch.

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
                   ` (9 preceding siblings ...)
  2021-05-07 17:52 ` mail at 3v1n0 dot net
@ 2021-05-07 17:59 ` jakub at gcc dot gnu.org
  2021-05-07 18:01 ` mail at 3v1n0 dot net
  2021-05-07 18:06 ` jakub at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-07 17:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And that is documented to behave that way.  The PCH header must be the first
header that contains any tokens.
PCH works by dumping the compiler state after compiling the header, and at
#include line if found restores that state from the *.gch file.  So, there
can't be any state before that, it would be lost.  And the macros and important
options need to match.

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
                   ` (10 preceding siblings ...)
  2021-05-07 17:59 ` jakub at gcc dot gnu.org
@ 2021-05-07 18:01 ` mail at 3v1n0 dot net
  2021-05-07 18:06 ` jakub at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: mail at 3v1n0 dot net @ 2021-05-07 18:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Marco Trevisan <mail at 3v1n0 dot net> ---
Well, I see...

At least the error should be a bit clearer though.

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

* [Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include`
  2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
                   ` (11 preceding siblings ...)
  2021-05-07 18:01 ` mail at 3v1n0 dot net
@ 2021-05-07 18:06 ` jakub at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-07 18:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The error is clear, the header you want to include doesn't exist, which is the
case.
Usually people use PCH as an optimization, have the header normally in search
path and have there also the precompiled version of that header.  If it can be
used, it is, otherwise it is parsed normally.
You chose to not have the header in search path, so when it is not
successufully used as PCH, it isn't found.  But to mention that in the
diagnostic the compiler would need to for all missing headers search again for
PCH headers.  That doesn't look like a good idea to me.

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

end of thread, other threads:[~2021-05-07 18:06 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 20:29 [Bug c++/100462] New: g++ fails to find the a pre-compiled header mail at 3v1n0 dot net
2021-05-06 20:39 ` [Bug c++/100462] g++ fails to find a generated " mail at 3v1n0 dot net
2021-05-06 22:43 ` pinskia at gcc dot gnu.org
2021-05-07 14:29 ` mail at 3v1n0 dot net
2021-05-07 14:36 ` mail at 3v1n0 dot net
2021-05-07 14:43 ` jakub at gcc dot gnu.org
2021-05-07 14:59 ` mail at 3v1n0 dot net
2021-05-07 15:01 ` mail at 3v1n0 dot net
2021-05-07 17:14 ` [Bug c++/100462] g++ fails to find a generated pre-compiled header when using `-include` mail at 3v1n0 dot net
2021-05-07 17:50 ` jakub at gcc dot gnu.org
2021-05-07 17:52 ` mail at 3v1n0 dot net
2021-05-07 17:59 ` jakub at gcc dot gnu.org
2021-05-07 18:01 ` mail at 3v1n0 dot net
2021-05-07 18:06 ` jakub 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).