Building Clang examples and running

Im trying to get the printfn example to work. I go to director and do
sudo make and then sudo make install, i then run

clang -cc1 -load /usr/local/lib/libPrintFunctionNames.so -plugin help

and i get
clang -cc1 plugins:

which means there are no plugins, indeed when i to prin-fns instead of
help, it says it cant find plugin.

Also, for the two other examples, ther eis no ability to make install,
when i make it i can't find the .so files, only .o files in the debug
directory, so how do i run those?

Seth Burleigh <seth-12uWGSe1GEnQT0dZR+AlfA@public.gmane.org> writes:

Im trying to get the printfn example to work. I go to director and do
sudo make and then sudo make install, i then run

clang -cc1 -load /usr/local/lib/libPrintFunctionNames.so -plugin help

and i get
clang -cc1 plugins:

which means there are no plugins, indeed when i to prin-fns instead of
help, it says it cant find plugin.

I foung the same. The only way I managed to get it to work was to
ignore configure and use cmake. So, in another directory use "ccmake
<path-to-llvm-source>" (where ccmake is one of the frontends to cmake)
and turn on the CMAKE_BUILD_EXAMPLES option (and set
CMAKE_INSTALL_PREFIX if you want) then use make in that directory.
"make install" will also work.

On the downside, I haven't worked out how to produce API documentation,
whereas I could with the in-tree build.

to have it working with make, see:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-April/008559.html

or there, for an archlinux packaged example:
http://repos.archlinux.org/wsvn/community/llvm/trunk/PKGBUILD
http://repos.archlinux.org/wsvn/community/llvm/trunk/clang-plugin-loader-registry.patch

hth,
sebastien.

configure also needs to be regenerated (but of course I have a different
version of autoconf, so the diffs aren't enlightening)

diff --git a/Makefile.config.in b/Makefile.config.in
index d073e9b..53fd943 100644
--- a/Makefile.config.in
+++ b/Makefile.config.in
@@ -340,3 +340,6 @@ NO_VARIADIC_MACROS = @NO_VARIADIC_MACROS@
# Flags supported by the linker.
# bfd ld / gold --version-script=file
HAVE_LINK_VERSION_SCRIPT = @HAVE_LINK_VERSION_SCRIPT@

tried editing the autoconf and rebuilding, didn't work. When i use make
to build the examples, and then make install, only the print function
exxample is installed, and for the two other examples only a .o file is
produced , and make install skips those two. And then when i try to do
the plugin thing with the .so file installed under /usr/local/bin/, it
says it cant find the plugin. None listed when using -help either.

Also tried using ccmake ~/.tmp/llvm/, came up with an 'empty cache page
0/0' so cant edit anything there.

It appears that BUILD_EXAMPLES doesn't work as I expected. However, the
trivial addition of

dnl doxygen configuration
AC_CONFIG_FILES(docs/doxygen.cfg)

to autoconf/configure.ac seems worthwhile. (I think it would also be
useful to be able to build the examples with an option, but I don't know
how and it doesn't seem particularly important---building them
individually is easy enough.)

[...]

Seth Burleigh <seth-12uWGSe1GEnQT0dZR+AlfA@public.gmane.org> writes:

[...]

Also tried using ccmake ~/.tmp/llvm/, came up with an 'empty cache page
0/0' so cant edit anything there.

I perhaps explained that poorly, you run ccmake in a fresh directory,
passing it the path to the checked out source.

[...]

I did

cd ~/llvm
ccmake ~/.tmp/llvm/

and i get

EMPTY CACHE

Then i hit c for configure and i dont see the build example option. And
then when i do make clean under ~/.tmp/llvm and do the above again, i
get an error when trying to configure, it says there are suspicious
files most likely produced by doing ./configure and then make.

I think i will try to just build the one source example file, I'll see
how that goes, how hard can it be :slight_smile:

Seth Burleigh <seth-12uWGSe1GEnQT0dZR+AlfA@public.gmane.org> writes:

I did

cd ~/llvm
ccmake ~/.tmp/llvm/

and i get

EMPTY CACHE

Then i hit c for configure and i dont see the build example option. And
then when i do make clean under ~/.tmp/llvm and do the above again, i
get an error when trying to configure, it says there are suspicious
files most likely produced by doing ./configure and then make.

I apologise. I was misremembering what I did. Here's something that I
think actually does work (I just did it):

cmake <path to llvm-toplevel>
ccmake .

So use cmake the first time, then "c" and "g" seem to work. I guess
cmake the first time does some kind of default configuration or
something. (I don't really understand cmake very well.)

[...]

Yay, it actually built print functions correctly and works!