[cfe-users] (lib)clang on Solaris (SPARC)

elmo elmopl at gmail.com
Tue Feb 4 12:41:47 PST 2014


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

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140204/2b3816cc/attachment.html>

More information about the cfe-users mailing list