[cfe-dev] Fwd: Precompiled headers error with clang++ 2.7-r96348

Bruce Cran bruce.cran at gmail.com
Sat Apr 3 11:17:24 PDT 2010


Forwarding to the list...

---------- Forwarded message ----------
From: Bruce Cran <bruce.cran at gmail.com>
Date: 3 April 2010 19:14
Subject: Re: [cfe-dev] Precompiled headers error with clang++ 2.7-r96348
To: Douglas Gregor <dgregor at apple.com>


I think I've figured out what's causing the problem. The Makefile Qt
generates outputs the precompiled header to obj/helloworldpch.gch/c++
and then passes obj/helloworldpch to clang++. It seems clang++ tries
to open obj/helloworldpch.gch as a file and fails.

--
Bruce


On 29 March 2010 16:33, Douglas Gregor <dgregor at apple.com> wrote:
>
> On Mar 6, 2010, at 2:07 AM, Bruce Cran wrote:
>
>> Hi,
>>
>> I'm trying to use precompiled headers when building a C++ application
>> on amd64 FreeBSD using llvm 2.7 r96348,
>> but even with a simple "hello world" application I'm getting the error:
>>
>> error: invalid or corrupt PTH file 'obj/helloworldpch.gch'
>> Assertion failed: (P && "No PTHManager."), function
>> AddImplicitIncludePTH, file InitPreprocessor.cpp, line 85.
>>
>> I've put the test application at
>> http://www.cran.org.uk/~brucec/freebsd/helloworldpch.tar.gz - I'm
>> trying to
>> build it using "gmake CXX=clang++".
>
> Unfortunately, I am not able to use this tarball to reproduce the problem you're seeing, since I don't have a FreeBSD system with Qt on it. I did a quick test with "precompiled headers" for C++ here:
>
> blackthorn:clang dgregor$ cat std.h
> #include <string>
> #include <list>
> #include <vector>
>
> blackthorn:clang dgregor$ clang++ -x c++-header std.h
> blackthorn:clang dgregor$ ls -l std.h*
> -rw-r--r--  1 dgregor  staff       53 Mar 29 08:25 std.h
> -rw-r--r--  1 dgregor  staff  1550000 Mar 29 08:29 std.h.gch
> blackthorn:clang dgregor$ cat main.cpp
> #include "std.h"
>
> int main() {
>  std::vector<int> v;
> }
>
> blackthorn:clang dgregor$ clang++ -include std.h main.cpp
> blackthorn:clang dgregor$
>
> and it works fine for me. That means we either fixed something since you sent your note, or that your makefile is using precompiled headers in some way that is broken/unsupported/different from what we've seen. Could you try again, and if it's still broken, get down to a simpler test case I can reproduce?
>
>> Do precompiled headers work with clang++ yet?
>
>
> Yes and no. Precompiled headers themselves are not implemented for C++ yet, so the precompiled header syntax for C++ (with -include, -x c++-header, etc.) actually maps down to Clang's pretokenized headers, which are language-agnostic. Pretokenized headers don't give quite the same performance improvements that precompiled headers do, but they work now.
>
>        - Doug




More information about the cfe-dev mailing list