[LLVMdev] [EXPERIMENTAL] Building Dragonegg on Cygwin

NAKAMURA Takumi geek4civic at gmail.com
Mon Apr 18 05:48:30 PDT 2011


Good evening, guys!

I have built dragonegg.dll on cygwin and it works (it seems).
I have not tried stage2 build yet.

It would be applicable to also mingw32-gcc to enhance gcc/plugin.c.

...Takumi


[Instructions]

1. Apply two patches. one is for gcc/config/i386/i386.c.

--- a/gcc/configure
+++ b/gcc/configure
@@ -25621,6 +25621,9 @@ rm -f core conftest.err conftest.$ac_objext \
   fi
   LDFLAGS="$saved_LDFLAGS"

+  pluginlibs="-Wl,--export-all-symbols -Wl,--output-def,cc1.def"
+  enable_plugin=yes
+
   # If plugin support had been requested but not available, fail.
   if test x"$enable_plugin" = x"no" ; then
     if test x"$default_plugin" != x"yes"; then

2. build gcc with --enable-lto --enable-plugin and install it.
cc1*.exe might have export tables.

3. Generate import libraries. (manually!)

$ dragonegg/lazyimp.pl $(GCC_PLUGIN_DIR)/lib/libcc1.a $(builtgcc)/gcc/cc1.def

It takes so long time. :/

4. Compile dll.c

$ gcc -O3 -Wall dll.c -c
$ ar rcs $(GCC_PLUGIN_DIR)/lib/libcc1.a dll.o

5. Tweak Dragonegg's Makefile and build!

[Dragonegg]
--- a/Makefile
+++ b/Makefile
@@ -57,6 +57,8 @@ CPP_OPTIONS+=$(CPPFLAGS) $(shell $(LLVM_CONFIG) --cppflags) \
             -DGCC_MAJOR=$(GCC_MAJOR) -DGCC_MINOR=$(GCC_MINOR) \
             -I$(INCLUDE_DIR) -I$(GCC_PLUGIN_DIR)/include

+LD_OPTIONS+=-Wl,-e,_lazymain at 12 -L $(GCC_PLUGIN_DIR)/lib -lcc1
+
 LD_OPTIONS+=$(shell $(LLVM_CONFIG) --ldflags) $(LDFLAGS)

 # NOTE: The following flags can only be used after TARGET_UTIL has been built.

6. check
$ /path/to/installed/gcc/bin/g++.exe -fplugin=./dragonegg.dll -O3 -S
hello.c -fplugin-arg-dragonegg-emit-ir
$ cat hello.s
; ModuleID = 'hello.c'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-f128:128:128-n8:16:32
"
target triple = "i386-pc-cygwin"
(snip)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dll.c
Type: text/x-csrc
Size: 518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110418/3179075b/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lazyimp.pl
Type: application/octet-stream
Size: 1712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110418/3179075b/attachment.obj>


More information about the llvm-dev mailing list