Hi Sameer,
> Dragonegg can now load LLVM plugins, including Polly. Thanks, Duncan:
>
>
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120709/146321.html
>
> It can be used like this:
>
> gcc -fplugin=./dragonegg.so -fplugin-arg-dragonegg-llvm-option=-load:LLVMPolly.so ...
>
> But this leads to two more issues:
>
> 1. gcc complains about undefined symbols, since LLVM libraries need to be linked into LLVMPolly.so. I fixed this for now using a brute-force setting in the Makefile for the shared object:
>
> LINK_COMPONENTS = all
>
> This should be reduced to a list of the actual components required. Trying individual components such as "core" and "analysis" only results in more symbols reported undefined. Is there a blanket way to find all the required symbol definitions and somehow map them to the components that should be passed to llvm-config?
the probable reason for this is that dragonegg is built with (hidden visibility
and) an explicit exports map, see exports.map. The only symbols it exports
are: plugin_is_GPL_compatible and plugin_init. Thus even if it is linked
against all kinds of LLVM libraries (which it is) the polly plugin won't be
able to access those routines because they are hidden inside the dragonegg.so
dynamic library. Try building dragonegg with this patch, does it help?
Index: Makefile
===================================================================
--- Makefile (revision 160120)
+++ Makefile (working copy)
@@ -36,14 +36,14 @@
QUIET:=@
endif
-COMMON_FLAGS=-Wall -Wextra -fvisibility=hidden
+COMMON_FLAGS=-Wall -Wextra #-fvisibility=hidden
CFLAGS+=$(COMMON_FLAGS) $(shell $(LLVM_CONFIG) --cflags)
CXXFLAGS+=$(COMMON_FLAGS) $(shell $(LLVM_CONFIG) --cxxflags)
ifeq ($(shell uname),Darwin)
LOADABLE_MODULE_OPTIONS=-bundle -undefined dynamic_lookup
else
-LOADABLE_MODULE_OPTIONS=-shared -Wl,-O1 -Wl,--version-script=$(TOP_DIR)/exports.map
+LOADABLE_MODULE_OPTIONS=-shared -Wl,-O1
#-Wl,--version-script=$(TOP_DIR)/exports.map
endif
GCC_PLUGIN_DIR:=$(shell $(GCC) -print-file-name=plugin)
The reason for only exporting these two symbols is that (1) it speeds the
loading of dragonegg.so and (2) allows link-time optimizers to do a lot of
good stuff when linking dragonegg.so.
> 2. I suppose the polly optimizations should be enabled by passing yet another llvm-option to dragonegg, like so:
>
> -fplugin-arg-dragonegg-llvm-option=-polly
>
> But this results in an error:
>
> cc1: Unknown command line argument '-polly'. Try: 'cc1 -help'
> cc1: Did you mean '-load'?
>
> Should this be treated as yet another enhancement in dragonegg?
I can reproduce this, but didn't get to the bottom of it yet. I think it is
related to pass registration: if the plugin registers a command line option
directly then that works fine. What doesn't work is if the option is the pass
name, -polly in this case.
Ciao, Duncan.