Hello, Everyone. This is just brief description on building llvm-gcc4 with mingw32. It's definitely non error-free and contains many "hacks", which should be eliminated in the future. 1. Prerequisites We're building in the folowing configuration: 1.1 GCC 3.4.5: gcc -v Reading specs from f:/research/mingw/bin/../lib/gcc/mingw32/3.4.5/specs Configured with: ../gcc-3.4.5/configure --with-gcc --with-gnu-ld --with-gnu-as - -host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls -- enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shar ed --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --ena ble-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-sync hronization --enable-libstdcxx-debug Thread model: win32 gcc version 3.4.5 (mingw special) 1.2 binutils 2.16.91 (20060119): ld --version GNU ld version 2.16.91 20060119 Copyright 2005 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License. This program has absolutely no warranty. (both taken from mingw32 site) 1.3 Flex & bison taken from gnuwin32 site: flex --version flex.EXE version 2.5.4 bison --version bison (GNU Bison) 2.1 Written by Robert Corbett and Richard Stallman. Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1.4 llvm-gcc4 snapshot named 2006-05-08-llvm-gcc-4.tar.gz 1.5 Patches to LLVM source code and GCC source code (attached). 2. LLVM itself We're using MSYS shell for main compilation. Also, we're using objdir!=srcdir directory structure (the root is actually f:/tmp/llvm): f:/tmp/llvm/build /gccbuild /gccsrc /install /src LLVM sources goes to src, GCC sources goes to gccsrc. We're using build dir to build LLVM and gccbuild dir to build GCC. 2.1 Switch do /build directory and configure LLVM: $ ../src/configure --enable-jit --enable-optimized --prefix=f:/tmp/llvm/build 2.2. Than make it: $ make tools-only LIBS="-lpsapi -limagehlp" I had 1 ICE while compiling /src/lib/Transforms/Scalar/InstructionCombining.cpp Everything was fixed, when I lowered optimization switch to -O2 and rebuild that file by hand. 3. GCC We're using cygwin shell, as msys isn't able to handle GCC's auto* machinery well. We're needing just folowing packages installed: alternatives ash base-files base-passwd bash bzip2 clear coreutils crypt cygutils cygwin cygwin-doc diffutils editrights expat findutils gawk gdbm grep groff gzip less libbz2_1 libcharset1 libdb4.2 libdb4.3 libgdbm libgdbm-devel libgdbm3 libgdbm4 libiconv libiconv2 libintl libintl1 libintl2 libintl3 libncurses5 libncurses6 libncurses7 libncurses8 libpcre0 libpopt0 libreadline4 libreadline5 libreadline6 login m4 make man mktemp ncurses openssl openssl097 perl python run sed tar tcltk termcap terminfo texinfo unzip which zip zlib (much of them, except make & perl are installed by default) 3.1 Black magic starts here.... 3.1.1 Mount your drive to cygwin. So, inside shell my disk f: is looking like directory /f 3.1.2 Much of autotools is using pwd command to extract current path. Unfortunately, it's in form: /drive/path, but we wants it to be: drive:/path. In order to do that, rename cygwin's pwd.exe located in the /bin directory into pwd_real.exe and create file named "pwd" with the folowing content (place it also in the /bin directory): <=cut=> #!/bin/sh cygpath -m `pwd_real` <=cut> Copy that file into "my_pwd" 3.1.3 Start cygwin. Be sure, that no msys tools (sh.exe, make.exe, etc) is staying in your path. Type: PWDCMD=/bin/my_pwd export PWDCMD 3.2 Go to gccbuild directory and configure gcc: $ ../gccsrc/configure --host=mingw32 \ --target=mingw32 \ --prefix=f:/tmp/llvm/install \ --enable-threads --disable-nls \ --enable-languages=c,c++ \ --disable-win32-registry \ --disable-shared \ --enable-sjlj-exceptions \ --enable-llvm=f:/tmp/llvm/build \ --program-prefix=llvm- 3.3 Make it! $ make CFLAGS="-O2 -fomit-frame-pointer" CXXFLAGS="-mthreads -fno-omit-frame-pointer -O2" 3.4 Take a cup of coffee.... 3.5 libstdc++ black magic After some time you'll see error message from ar.exe complaining, that It cannot create libstdc++.a file due to invalid path of form /drive/path. Goto to gccbuild/mingw32libstdc++-v3 directory. Open file libtool and replace all "`pwd" to "`my_pwd" and rerun make (you might also do that just monitoring libtool creation and do this hack on-fly, while libstdc++ is configuring). You'll have error message about inline assembler in the atomicity.cc (located in the gccbuild/mingw32/libstdc++-v3/src), feel free to comment the entire loop there, since current version of llvm-gcc4 doesn't support any exceptions yet. This should be definitely fixed in the future. BTW, another patch (to gthr-win32.c) was supplied also to overcome inline assembler handling bugs (both containing "lock xchg" instructions). 3.6 libiberty issues You might also find, that cc1 crashed compiling md5.c from libiberty. This is due to some weird bug in Select_add routine from X86GenDAGISel.inc. I don't know the reason, seems to be some stack overflow or something like this. I'm investigating this problem. Funny, that some other file with SHA implementation also causes such crash ;) Maybe this is due to be amount of ariphmetical operations inside. 3.7 You've done it! $ make install 4. LLVM: rebuilding Configure LLVM again (inside msys!) with $ ../src/configure --enable-jit --enable-optimized --prefix=f:/tmp/llvm/build --with-llvmgccdir=f:/tmp/llvm/install and make it as usual... 5. Congratulations: you've done it! -- With best regards, Anton mailto:asl at math.spbu.ru Thursday, May 11, 2006 12:37:17 AM Faculty of Mathematics & Mechanics, Saint-Petersburg State University -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm.diff Type: application/octet-stream Size: 4441 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20060511/bc4746e6/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: gcc.diff Type: application/octet-stream Size: 5610 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20060511/bc4746e6/attachment-0001.obj>
Thanks Anton. Nice Job. Henrik.>From: Anton Korobeynikov Date: Thu, 11 May 2006 01:17:24 +0400 > >Hello, Everyone. > >This is just brief description on building llvm-gcc4 with mingw32. >It's definitely non error-free and contains many "hacks", which should >be eliminated in the future. > >1. Prerequisites >We're building in the folowing configuration: > >1.1 GCC 3.4.5: >gcc -v >Reading specs from f:/research/mingw/bin/../lib/gcc/mingw32/3.4.5/specs >Configured with: ../gcc-3.4.5/configure --with-gcc --with-gnu-ld >--with-gnu-as - >-host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads >--disable-nls -- >enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry >--disable-shar >ed --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x >--ena >ble-java-gc=boehm --disable-libgcj-debug --enable-interpreter >--enable-hash-sync >hronization --enable-libstdcxx-debug >Thread model: win32 >gcc version 3.4.5 (mingw special) > >1.2 binutils 2.16.91 (20060119): >ld --version >GNU ld version 2.16.91 20060119 >Copyright 2005 Free Software Foundation, Inc. >This program is free software; you may redistribute it under the terms of >the GNU General Public License. This program has absolutely no warranty. > >(both taken from mingw32 site) > >1.3 Flex & bison taken from gnuwin32 site: >flex --version >flex.EXE version 2.5.4 > >bison --version >bison (GNU Bison) 2.1 >Written by Robert Corbett and Richard Stallman. > >Copyright (C) 2005 Free Software Foundation, Inc. >This is free software; see the source for copying conditions. There is NO >warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > >1.4 llvm-gcc4 snapshot named 2006-05-08-llvm-gcc-4.tar.gz > >1.5 Patches to LLVM source code and GCC source code (attached). > >2. LLVM itself >We're using MSYS shell for main compilation. Also, we're using >objdir!=srcdir directory structure (the root is actually f:/tmp/llvm): > >f:/tmp/llvm/build > /gccbuild > /gccsrc > /install > /src > >LLVM sources goes to src, GCC sources goes to gccsrc. We're using >build dir to build LLVM and gccbuild dir to build GCC. > >2.1 Switch do /build directory and configure LLVM: > $ ../src/configure --enable-jit --enable-optimized >--prefix=f:/tmp/llvm/build >2.2. Than make it: > $ make tools-only LIBS="-lpsapi -limagehlp" > > I had 1 ICE while compiling >/src/lib/Transforms/Scalar/InstructionCombining.cpp > Everything was fixed, when I lowered optimization switch to -O2 and > rebuild that file by hand. > >3. GCC >We're using cygwin shell, as msys isn't able to handle GCC's auto* >machinery well. We're needing just folowing packages installed: > >alternatives ash base-files base-passwd bash bzip2 clear coreutils >crypt cygutils cygwin cygwin-doc diffutils editrights expat findutils >gawk gdbm grep groff gzip less libbz2_1 libcharset1 libdb4.2 libdb4.3 >libgdbm libgdbm-devel libgdbm3 libgdbm4 libiconv libiconv2 libintl libintl1 >libintl2 libintl3 libncurses5 libncurses6 libncurses7 libncurses8 libpcre0 >libpopt0 libreadline4 libreadline5 libreadline6 login m4 make man mktemp >ncurses openssl openssl097 perl python run sed tar tcltk termcap terminfo >texinfo unzip which zip zlib > >(much of them, except make & perl are installed by default) > >3.1 Black magic starts here.... >3.1.1 >Mount your drive to cygwin. So, inside shell my disk f: is looking >like directory /f > >3.1.2 >Much of autotools is using pwd command to extract current path. >Unfortunately, it's in form: /drive/path, but we wants it to be: >drive:/path. In order to do that, rename cygwin's pwd.exe located in >the /bin directory into pwd_real.exe and create file named "pwd" with >the folowing content (place it also in the /bin directory): > ><=cut=> >#!/bin/sh > >cygpath -m `pwd_real` ><=cut> > >Copy that file into "my_pwd" >3.1.3 >Start cygwin. Be sure, that no msys tools (sh.exe, make.exe, etc) is >staying in your path. >Type: > >PWDCMD=/bin/my_pwd >export PWDCMD > >3.2 Go to gccbuild directory and configure gcc: >$ ../gccsrc/configure --host=mingw32 \ > --target=mingw32 \ > --prefix=f:/tmp/llvm/install \ > --enable-threads --disable-nls \ > --enable-languages=c,c++ \ > --disable-win32-registry \ > --disable-shared \ > --enable-sjlj-exceptions \ > --enable-llvm=f:/tmp/llvm/build \ > --program-prefix=llvm- > >3.3 Make it! >$ make CFLAGS="-O2 -fomit-frame-pointer" CXXFLAGS="-mthreads >-fno-omit-frame-pointer -O2" > >3.4 Take a cup of coffee.... > >3.5 libstdc++ black magic >After some time you'll see error message from ar.exe complaining, that >It cannot create libstdc++.a file due to invalid path of form >/drive/path. Goto to gccbuild/mingw32libstdc++-v3 directory. Open file >libtool and replace all "`pwd" to "`my_pwd" and rerun make (you might >also do that just monitoring libtool creation and do this hack on-fly, >while libstdc++ is configuring). > >You'll have error message about inline assembler in the atomicity.cc >(located in the gccbuild/mingw32/libstdc++-v3/src), feel free to comment >the entire loop there, since current version of llvm-gcc4 doesn't >support any exceptions yet. This should be definitely fixed in the >future. BTW, another patch (to gthr-win32.c) was supplied also to >overcome inline assembler handling bugs (both containing "lock xchg" >instructions). > >3.6 libiberty issues > >You might also find, that cc1 crashed compiling md5.c from libiberty. >This is due to some weird bug in Select_add routine from >X86GenDAGISel.inc. I don't know the reason, seems to be some stack >overflow or something like this. I'm investigating this problem. >Funny, that some other file with SHA implementation also causes such >crash ;) Maybe this is due to be amount of ariphmetical operations >inside. > >3.7 You've done it! >$ make install > >4. LLVM: rebuilding >Configure LLVM again (inside msys!) with >$ ../src/configure --enable-jit --enable-optimized >--prefix=f:/tmp/llvm/build --with-llvmgccdir=f:/tmp/llvm/install > >and make it as usual... > >5. Congratulations: you've done it! > >-- >With best regards, > Anton mailto:asl at math.spbu.ru > >Thursday, May 11, 2006 12:37:17 AM > >Faculty of Mathematics & Mechanics, Saint-Petersburg State University><< llvm.diff >>><< gcc.diff >>>_______________________________________________ >LLVM Developers mailing list >LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev_________________________________________________________________ Ta' p� udsalg �ret rundt p� MSN Shopping: http://shopping.msn.dk - her finder du altid de bedste priser
On Thu, 11 May 2006, Anton Korobeynikov wrote:> 1.5 Patches to LLVM source code and GCC source code (attached).Hi, Sorry, I didn't notice that there were patches attached to this email :( Here are some feedback on the patches. The LLVM one in particular looks like this. Comments below are prefixed with ***. ===========================================================--- configure 155956256e89ce3f97692ea550e612f23b20c9a5 +++ configure 35f342fc281c8107ea3b3e6b7a4c67748e9818da @@ -3150,10 +3150,10 @@ fi; case "$withval" in default) WITH_LLVMGCCDIR=default ;; - /*) WITH_LLVMGCCDIR=$withval ;; - *) { { echo "$as_me:$LINENO: error: Invalid path for --with-llvmgccdir. Provide full path" >&5 -echo "$as_me: error: Invalid path for --with-llvmgccdir. Provide full path" >&2;} - { (exit 1); exit 1; }; } ;; + *) WITH_LLVMGCCDIR=$withval ;; +# *) { { echo "$as_me:$LINENO: error: Invalid path for --with-llvmgccdir. Provide full path" >&5 +#echo "$as_me: error: Invalid path for --with-llvmgccdir. Provide full path" >&2;} +# { (exit 1); exit 1; }; } ;; esac *** I'm not sure what this does, but it seems that you should be modifying configure.ac, not configure itself. It's quite possible this is obsolete with the other patches of yours that have gone in. ===========================================================--- examples/Makefile 2ceb866a00384348771cb6cbea5ef37c5ec049f2 +++ examples/Makefile fd1fd2b481e9390712d31222e14ca73f8311da4c @@ -11,6 +11,6 @@ include $(LEVEL)/Makefile.config #PARALLEL_DIRS:= $(patsubst %/Makefile,%,$(wildcard $(SourceDir)/*/Makefile)) -PARALLEL_DIRS:= ParallelJIT Fibonacci HowToUseJIT ModuleMaker BFtoLLVM +PARALLEL_DIRS:= Fibonacci HowToUseJIT ModuleMaker BFtoLLVM *** This isn't suitable for mainline, it disables the program for all targets. Try something like this: include $(LEVEL)/Makefile.config ifeq($OS,Win32) PARALLEL_DIRS := $(filter-out ParallelJIT, $(PARALLEL_DIRS)) endif Also, please include a comment as to why this is disabled. If it's lack of threading stuff, that should just be a matter of implementing the right pieces in libsystem. include $(LEVEL)/Makefile.common ===========================================================--- lib/CodeGen/AsmPrinter.cpp 4d087f1319aa4dfebaaa1e60a31c472e3ac73f95 +++ lib/CodeGen/AsmPrinter.cpp ef7057d8945842dc2c79cd4c6ff355925233f48c @@ -50,8 +50,13 @@ MLSections(false), ConstantPoolSection("\t.section .rodata\n"), JumpTableSection("\t.section .rodata\n"), +#ifndef __MINGW32__ StaticCtorsSection("\t.section .ctors,\"aw\", at progbits"), StaticDtorsSection("\t.section .dtors,\"aw\", at progbits"), +#else + StaticCtorsSection("\t.section .ctors,\"aw\""), + StaticDtorsSection("\t.section .dtors,\"aw\""), +#endif LCOMMDirective(0), COMMDirective("\t.comm\t"), COMMDirectiveTakesAlignment(true), This isn't the right approach to take. Instead of modifying target-independent code, you should be modifying the backend. Also, instead of using #ifndef __MINGW32__, you should be checking X86Subtarget::TargetType, so that this works in cross compiles. ===========================================================--- lib/Target/X86/X86ATTAsmPrinter.cpp 8322d2abc8060ad351cb91560a0217e76273e502 +++ lib/Target/X86/X86ATTAsmPrinter.cpp 6a01b8b87d60c49fb4f4159d936abfcd2a210388 @@ -64,7 +64,11 @@ } else { EmitAlignment(4, F); // FIXME: This should be parameterized somewhere. O << "\t.section\t.llvm.linkonce.t." << CurrentFnName +#ifndef __MINGW32__ << ",\"ax\", at progbits\n"; +#else + << ",\"ax\"\n"; +#endif O << "\t.weak " << CurrentFnName << "\n"; } break; *** Same as above, please check the subtarget. ===========================================================--- lib/Target/X86/X86AsmPrinter.cpp 56794abbf644ef81639885abd8c9d00088ccf333 +++ lib/Target/X86/X86AsmPrinter.cpp c1c961dc23dffd5cb7c7367af2b65a01bd384b10 @@ -128,8 +128,10 @@ } else O << COMMDirective << name << "," << Size; } else { +#if !defined(__MINGW32__) if (I->hasInternalLinkage()) O << "\t.local\t" << name << "\n"; +#endif O << COMMDirective << name << "," << Size; if (COMMDirectiveTakesAlignment) O << "," << (AlignmentIsInBytes ? (1 << Align) : Align); @@ -145,7 +147,11 @@ << "\t.weak_definition " << name << "\n"; SwitchSection(".section __DATA,__datacoal_nt,coalesced", I); } else { +#ifndef __MINGW32__ O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\", at progbits\n"; +#else + O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\"\n"; +#endif O << "\t.weak " << name << "\n"; } break; *** Same as above, please check the subtarget. -Chris -- http://nondot.org/sabre/ http://llvm.org/