I'm looking to get started with LLVM as the back end for a compiler that
ultimately should self-host.
From an ease of use perspective, the optimum on Windows would be a DLL
along with C header files that I can translate into the front end's
language.
I read in the FAQ:
http://llvm.org/docs/FAQ.html#langs
that "the C bindings in include/llvm-c should help a lot". However,
looking at the contents of llvm-2.6/Release after I've built it on
Cygwin, it looks like I'll have to cobble together a DLL out of the
libraries myself.
I can't imagine I'm the first to want a pre-packaged DLL containing all
the relevant bits, along with DLL exports etc. Has someone else done
this work?
Thanks,
-- Barry
Hello Barry,
Are you still using Cygwin? Why not try using MinGW instead. I think Cygwin cannot create .DLL files or if it can, the build scripts are not set up to do it from Cygwin. IIRC, Cygwin support is being dropped from later versions of LLVM so you'll have to either use Visual C++ to compile it or MinGW. See http://www.mingw.org for downloads.
--Sam
From: Barry Kelly <bkelly.ie@gmail.com>
To: LLVM Developers Mailing List <llvmdev@cs.uiuc.edu>
Sent: Wed, March 31, 2010 10:22:46 AM
Subject: [LLVMdev] Getting started with LLVM on Win32 from non-C/C++ language
I'm looking to get started with LLVM as the back end for a compiler
that
ultimately should self-host.
From an ease of use perspective,
the optimum on Windows would be a DLL
along with C header files that I can
translate into the front end's
language.
I read in the
FAQ:
http://llvm.org/docs/FAQ.html#langs
that "the C bindings in
include/llvm-c should help a lot". However,
looking at the contents of
llvm-2.6/Release after I've built it on
Cygwin, it looks like I'll have to
cobble together a DLL out of the
libraries myself.
I can't imagine I'm
the first to want a pre-packaged DLL containing all
the relevant bits, along
with DLL exports etc. Has someone else done
this
work?
Thanks,
-- Barry
Samuel Crow wrote:
Are you still using Cygwin?
Why not try using MinGW instead.
It was available. I live in Cygwin; MSYS is a poor alternative. Also
generally speaking, open source projects targeting a POSIXy environment
have a higher probability of working first time with Cygwin, so it
serves well for investigation (e.g. no distribution in the GPL sense).
I think Cygwin cannot create .DLL files
It can.
or if it can,
the build scripts are not set up to do it from Cygwin.
I was able to build a DLL by roughly:
cd Release/lib
for f in *.a; ar x $f; done
rm PluginMain.o
g++ -shared --export-all-symbols -o LLVM.dll *.o
(Credit to Óscar Fuentes in an old message.)
It doesn't link with Cygwin disabled (-mno-cygwin) because the libraries
have all been compiled without that switch used, of course.
I have yet to try and use the C API directly, however.
IIRC, Cygwin support is being
dropped from later versions of LLVM so you'll have to either use Visual C++ to compile
it or MinGW.
If Visual Studio 2008 were supported, I'd consider using it. The current
solution and project files work less than optimally when auto-upgraded
by VS2008.
Are you still working on an LLVM back end for FPC? What integration
approach are / were you using for that?
-- Barry
Hello again Barry,
In order to compile LLVM from Visual C++, you should use CMake to create the project file. See http://www.cmake.org/ for downloads.
I was going to work on an FPC compatible backend by adding the Borland Fastcall calling convention to the x86 backend but I've run into two snags: 1. I've never used the TableGen utility and I haven't gotten around to figuring it out, and 2. the person who was making the runtime library for the dialect of BASIC that I'm working on (he was using Delphi) has not been in contact with us for some time and we're thinking of dropping that runtime idea and just using a LibC-based solution.
I hope this answers your questions,
--Sam
From: Barry Kelly <barry.j.kelly@gmail.com>
To: Samuel Crow <samuraileumas@yahoo.com>
Cc: LLVM Developers Mailing List <llvmdev@cs.uiuc.edu>
Sent: Wed, March 31, 2010 12:35:40 PM
Subject: Re: [LLVMdev] Getting started with LLVM on Win32 from non-C/C++ language
If Visual Studio 2008 were
supported, I'd consider using it. The current
solution and project files work
less than optimally when auto-upgraded
by VS2008.
Are you still
working on an LLVM back end for FPC? What integration
approach are / were you
using for that?
-- Barry
Barry Kelly <bkelly.ie@gmail.com> writes:
[snip]
It was available. I live in Cygwin; MSYS is a poor alternative. Also
generally speaking, open source projects targeting a POSIXy environment
have a higher probability of working first time with Cygwin, so it
serves well for investigation (e.g. no distribution in the GPL sense).
LLVM is not a POSIX-centric project. Maintainers are happy to apply
patches that improve its usability on other platforms, specially
Windows. If right now LLVM lacks something on Windows, is due to the
fact that most developers work on Unix. For the specific case of DLLs,
they are available on Linux and Mac OS just because they are so easy to
create there. Maintaining a VS-compatible DLL build would be a
nightmare, given the volatility of the LLVM C++ API and the heavy
inter-dependencies among its libraries.
[snip]
I was able to build a DLL by roughly:
cd Release/lib
for f in *.a; ar x $f; done
rm PluginMain.o
g++ -shared --export-all-symbols -o LLVM.dll *.o
Yes, this works. But what I've done is to isolate my backend on its own
DLL, which statically links LLVM. This approach has the advantage of
working everywhere. Another option for you is to add the declspec's to
the C bindings and create a dll that just exposes that interface. Please
submit a patch if you follow this route.
[snip]
If Visual Studio 2008 were supported, I'd consider using it. The current
solution and project files work less than optimally when auto-upgraded
by VS2008.
LLVM is fine on VS 2008. The hand-made project files were removed after
the 2.6 release. Use cmake for generating the project files:
http://www.llvm.org/docs/CMake.html
[snip]