[EXPERIMENTAL] Building Dragonegg on Cygwin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[EXPERIMENTAL] Building Dragonegg on Cygwin

NAKAMURA Takumi
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@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)

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

dll.c (710 bytes) Download Attachment
lazyimp.pl (2K) Download Attachment