Precompiled headers error with clang++ 2.7-r96348

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++".

Do precompiled headers work with clang++ yet?

They works “better” a few weeks ago. I am seeing this since Thursday/Wednesday. I hope the devs will fix this asap :slight_smile:

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

Forwarding to the list...