[PATCH] Capability of Win32.DLL with ENABLE_SHARED

Good summer, all!

This patch enables ENABLE_SHARED=1 to build DLL based LLVM toolchain.
I have checked this on Cygwin-1.5, Cygwin-1.7, mingw(msysgit) and
mingw-cross-fedora12.

I can separate this patch into some parts; cleanups, adding
definitions and adding rules.

Any feedbacks are welcome.
Have fun!

...Takumi

* Pros
  - reduction of linking time of toolchain.
  - capability of -load plugins on opt.exe
  - capability of LLVM APIs on lli.exe from bc
  - reduction of size of executables.

* Cons
  - linking into DLL spends so much time.
  - contains some ugly tweaks.

* Known issues
  - I took the way to link libstdc++.a together into LLVM.dll. It may
invoke nasal demons. :frowning:
  - On cygwin, fork(3) on DLL sometimes fails to clang.exe crashes.
You have to do "rebaseall".
    (It would be better to get rid of fork(3) in llvm::System for
cygwin in future)
  - I have not checked llvmc.

* TODO
  - check system's stdc++.dll and use it with autoconf.

r110016-shlib-dll.diff.txt (8.08 KB)

Hi Takumi,

Any feedbacks are welcome.
Have fun!

This seems to be pretty useful addition to LLVM on windows! And it
seems the only painless way to make plugins working, yay!

For me the patch looks pretty good. One minor thing: could you please
rename SharedDir => SharedLibDir

Thanks!

Anton,

Thanks for your comment.
2nd patch attached.

  - s/SharedDir/SharedLibDir/g
  - move prefix=cyg sunk into if(cygwin or mingw)

arigato gozaimasu...Takumi

* Additional issues
  - You may build LLVMHello.dll but I don't modify lib/Transforms/Makefile.
    Because making LLVMHello.dll requires the library LLVM.dll,
    but it oughta be on the way to making libs at building lib/Transforms/Hello.
    You can build LLVMHello.dll later;
      $ make -C lib/Transforms OPTIONAL_DIRS+=Hello

* Why dummy bin/libstdc++.dll.a needed?
  - ld resolves data/bss symbols with *.a on LIBRARY_PATH,
    at next, resolves symbols with "auto-import" after.
    I had to suppress standard -lstdc++, it was the reason.

r110016-shlib-dll-2.diff.txt (8.15 KB)

This additional patch enables "make unittests" on enable-shared/mingw.
(still unittests would fail in some points. see also my other patches)
It is intended to apply with previous r110016-shlib-dll-2.diff.txt.

Thank you in advance...Takumi

r105390-unittests-shlib.diff.txt (791 Bytes)

Thanks for your comment.
2nd patch attached.

Applied, thanks for working on this!

This additional patch enables "make unittests" on enable-shared/mingw.
(still unittests would fail in some points. see also my other patches)
It is intended to apply with previous r110016-shlib-dll-2.diff.txt.

Applied, thanks!