Hello,
Thanks to recent changes in the SVN, I was able to successfully build LLVM under Windows in the following environments:
1. Cygwin;
2. MinGW/MSYS;
3. "gcc -mno-cygwin" (a.k.a MinGW on Cygwin).
For 3., I've had to make a few manual changes to the build system. Care is needed because non-Cygwin external commands require Windows paths and Cygwin's make does not like path names with colon in them (as in C:\...). Currently, the only such external command in LLVM's build seems to be tblgen.
I describe below what I've done in case others are interested (I believe that minimal fixes to the configure script would be enough to have everything work out of the box.)
(
The OCaml bindings needs some more work (I've haven't succeeded yet) to compile under Mingw:
- the statement CFLAGS+=... in bindings/ocaml/Makefile.ocaml is destroyed if we set CFLAGS in Makefile.config (this might be solved by using =? instead of = in Makefile.config);
- the variables OCAMLC, OCAMLOPT, OCAMLDEP in Makefile.config are Windows paths (they should be Cygwin paths);
- there should be quotes when adding to CFLAGS in Makefile.ocaml:
CFLAGS += -I"$(shell $(OCAMLC) -where)";
- use $(SYSPATH) as below for all the ocaml commands;
- replace .a with .lib in Makefile.ocaml;
- adapt llvm-config to produce .lib suffixes for --libnames;
- ... (probably other things)
)
* Run the configure script
CFLAGS=-mno-cygwin CXXFLAGS=-mno-cygwin ./configure --prefix=... --build=i686-pc-mingw32 --disable-threads --disable-ltdl-install
* Add the following lines to Makefile.config:
CFLAGS=-mno-cygwin
CXXFLAGS=-mno-cygwin
SYSPATH = $(shell echo $(1) | cygpath -m -f -)
(I could not figure out how to have the configure script pass CFLAGS and CXXFLAGS to Makefile.config. I've tried to add them on configure's command line and in the environment as above. Is this a bug?)
(The configure script could produce the SYSPATH above when asked to compile for MinGW on Cygwin, and just "SYSPATH = $(1)" otherwise.)
* Set variables in include/llvm/Config/config.h:
HAVE_ARGZ_H = 0
HAVE_LIBDL = 0
(The configure script find Cygwin libraries which should not be used here. When asked to compile for MinGW on Cygwin, it should not try to find those libraries.)
* Arrange so that Windows path are passed to the tblgen tool, using the SYSPATH function defined above (might be better to factorize all the calls to tblgen with such a function).
Index: lib/VMCore/Makefile