(lib)clang on Solaris (SPARC)

Hi,

I have been trying to get libclang.so working on Solaris, but I can’t seem to get anything out of it.
Simply running “cmake …” worked, it successfully picked up GCC and was able to build parts of llvm/clang. Unfortunately it died on running llvm-tblgen.

A bit of scrambling and poking showed that if I specify LLVM_TARGETS_TO_BUILD=AArch64 running “gmake libclang” successfully ends producing “clang” and “libclang.so” (note: I do not intend to produce binaries with clang, all I want is libclang.so for its awesome C++ parsing/traversing facilities).
Unfortunately neither of them works when I try to actually use them. Both show the same symptoms of dying with SIGBUS.

The most debugging I could get was either by injecting print statements or trying to use dbx (gdb simply dies when I try to run anything on it). More annoyingly dbx is able to show function names only with optimized code (which I find odd, but when I tried using version built with -O0 -g options I didn’t even get function names on stacktrace, not to mention file+line).

Now, my tracking lead me to places with awful code like this:

Stmt **getStmts() { return reinterpret_cast<Stmt **> (this + 1); }

Apparently that is standard “solution” in clang sources, yet it seems to be one of the reasons that clang/libclang.so crashes.
There are other places where “this” has requirement to be aligned only to 4 bytes and data after has alignment of 8. Which not surprisingly causes SIGBUS issue.

I tried using -mfaster-structs which causes GCC to align all structures to at least 8 bytes, but that breaks ELF* classes and AlignOf template.

I tried searching on google, this mailing list and official website, but I can’t find any information on how to build llvm/clang on Solaris so that it will work.

Has anyone succeeded in getting libclang.so working on Solaris?
Are there some instructions on how to build it on Solaris?

If this is the case, these are the bugs we would like to fix (and
appreciate patches for!)

Unfortunately, as far as I know, we have no buildbots where unaligned
access is trapping, so these issues are dormant.

Dmitri