www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - how to build LDC2 on linux x86_64

Let's add any comments to this protocol on this, it's own thread, rather
than on the old thread, to encapsulate and localize -- so as to make it
easier to find and replicate installion.


- Jason

On Tue, Mar 8, 2011 at 2:15 AM, Jens Mueller <jens.k.mueller gmx.de> wrote,
on the old thread titled "LLVM 3.0 type system changes"

 Can you talk me through the building process? I tried it a week ago but
 with no success. Can you post the necessary steps on this list or to me
 in private?
I can try to sketch the important aspects, but obviously this protocol hasn't been tested very widely, so feel free to post back any refinements. Even better if you want to patch the repositories. Some of these may be out of order, especially the CMakeCache.txt edits, so if anything goes wrong, check the variables mentioned below in CMakeCache.txt, and that your ldc2.conf is correct. Those are the most important two control files. I'll start a new thread with a new title to make this easy to find, and more on topic. I. Acknowledgements Heavy credit for this is due to mrmonday on #ldc who guided me and graciously offered assistance. Errors and typos are mine alone. II. Protocol: Building LDC2 on Linux x86_64 Version: 07 March 2011 Prereqs: cmake, git, hg, llvm2.8 from source already installed (package installs of llvm2.8 might work too, I don't know). # 1) Check out ldc2, druntime, and phobos2: $ hg clone https://bitbucket.org/prokhin_alexey/ldc2 $ cd ldc2 $ git clone https://github.com/AlexeyProkhin/druntime $ git clone https://github.com/AlexeyProkhin/phobos # 2) Configure (apparently you can also use ccmake with gui, but I didn't)$ cmake . # 3) Fix up the CMakeCache.txt file: # 3 a) edit CMakeCache.txt by hand, and set D_VERSION to 2, as on these two lines: ... //D language version - will originally be set to 1, change it to 2 like this: D_VERSION:STRING=2 ... # 3 b) check on the variables mentioned in 3 d). I don't think that they will be present yet, but if they aren't, it can't hurt to fix them now as well. # 3 c) make (this should hopefully build bin/ldc2 now ) $ make # there will be some const warnings, but the build finishes for me. # 3 d) edit CMakeCache.txt again (it will have changed/had appendixes now I think) and fix these two variables: ... //runtime source dir RUNTIME_DIR:PATH=/home/jaten/pkg/ldc2/ldc2/druntime ... //phobos2 source dir PHOBOS2_DIR:PATH=/home/jaten/pkg/ldc2/ldc2/phobos ... # 4) modify your your .bashrc to set PATH to include ./bin in front of everything else echo "export PATH=`pwd`/bin:\$PATH" >> ~/.bashrc . ~/.bashrc which ldc2 # should show the one in ./bin now # 5) build druntime and phobos with the command: make phobos2 $ make phobos2 # 6) edit ./bin/ldc2.conf so that it points to the right places. Here is a copy of mine that seems to work. The point of the editing is to make sure that paths are correct, especially the third -I (Include line), which was often wrong out of the box when I was working with it. jaten dfw:~$ cat ldc2.conf // This configuration file uses libconfig. // See http://www.hyperrealm.com/libconfig/ for syntax details. // The default group is required default: { // 'switches' holds array of string that are appends to the command line // arguments before they are parsed. switches = [ "-I/home/jaten/pkg/llvm+lldb+ldc/prokhin_alexeys_ldc2/ldc2/druntime/import", "-I/home/jaten/pkg/llvm+lldb+ldc/prokhin_alexeys_ldc2/ldc2/druntime/src", "-I/home/jaten/pkg/llvm+lldb+ldc/prokhin_alexeys_ldc2/ldc2/phobos/", "-L-L/home/jaten/pkg/llvm+lldb+ldc/prokhin_alexeys_ldc2/ldc2/runtime/../lib", "-defaultlib=phobos2", "-debuglib=phobos2" ]; }; jaten dfw:~$ # 7) Finished. Test and note variances from the protocol above. III. Appendix: Troubleshooting notes If anything goes wrong, in my experience it was due to the settings in either CMakeCache.txt, or in ./bin/ldc2.conf Those are the two places I would look at first when troubleshooting. A) When you edit the CMakeCache.txt, be sure to check that PHOBOS2_DIR gets set to ./phobos and not ../druntime # example that works: jaten dfw:~$ cat CMakeCache.txt.afarm_works_ldc2 | grep PHOBOS2_DIR PHOBOS2_DIR:PATH=/home/jaten/pkg/llvm+lldb+ldc/prokhin_alexeys_ldc2/ldc2/phobos # example that DOES NOT work: jaten dfw:~$ cat CMakeCache.txt.dfw_notwork_ldc2 | grep PHOBOS2_DIR PHOBOS2_DIR:PATH=/home/jaten/pkg/ldc2/ldc2/../druntime B) Be sure in CMakeCache.txt you have these three variables set correctly, with obvious edits for your paths, not mine: ... //D language version D_VERSION:STRING=2 ... //runtime source dir RUNTIME_DIR:PATH=/home/jaten/pkg/ldc2/ldc2/druntime ... //phobos2 source dir PHOBOS2_DIR:PATH=/home/jaten/pkg/ldc2/ldc2/phobos Good luck!
Mar 08 2011