Hi Dan, Thank you for your advice on the build/install. On Jun 11, 2014, at 7:06 PM, Dan Liew <dan at su-root.co.uk> wrote:> Well on many Linux distributions LLVM and Clang are installable as > packages (along with the header files) so for something like the > Kaleidoscope tutorial it isn't necessary to build LLVM and Clang from > source. However you are running OSX which I'm not familiar with so I > don't know what the situation is there. I know clang is now the > default compiler but I don't know if LLVM header files and libraries > are shipped with OSX or can be installed as the OSX equivalent of a > package.It doesn’t appear to be installed on mac osx by default (it’s not on either of my two machines).> You are doing what is called an "out of source build". This is where > all the generated binary files and some build system files go in a > different directory to the source code directory. This is the opposite > of an "in source build" where binary files and some build system files > go in the same directory as the source code directory. The advantage > of doing an "out of source build" is that > > - you can have multiple build configurations all building from the > same source directory > - Prevents you from accidently committing files generated by the build system > - Deleting build files is really easy, you just delete the build > directory ( /Users/josephmorgan/build ) > > I would stick with doing out of source builds, so this is fine.This makes sense to me now. :)>> 5. #configure (I am still not clear on what is purpose of prefix here) >> /Users/josephmorgan/llvm/configure --prefix=/Users/josephmorgan/build >> --enable-targets=x86,x86_64 > > If you read [1] you'll see that ``--prefix=`` is optional and that it > sets the install location. I think you are confused between "building" > and "installing". Building (i.e. running ``make``) builds the binaries > in the build directory (e.g. You'll probably find the built binaries > in /Users/josephmorgan/build/Release+Asserts/bin/). This does not > install the binaries. By running ``make install`` this will install > > LLVM Binaries to <prefix>/bin > LLVM Libraries to <prefix>/lib > LLVM header files to <prefix>/include > > where <prefix> is what was specified using ``--prefix=`` (or the > default /usr/local if it was not specified). Telling configure to > build and install LLVM in the same directory like you did does not > make any sense so if you're still confused just don't specify the > ``--prefix=`` flag.I am now leaving out the ``--prefix=`` flag when I make install it was able to find the includes as expected.> For the kaleidoscope tutorial it is actually not necessary to install > LLVM, you can use it directly from your build directory > (``/Users/josephmorgan/build``). > > Once you've successfully built LLVM you can then build the > Kaleidoscope example by doing something like > > ``` > clang++ -g -O3 toy.cpp > `/Users/josephmorgan/build/Release+Assert/bin/llvm-config --cppflags > --ldflags --libs core` -o toyI also tried this before doing a make install and it was able to find the includes as expected. Not having it originally installed in usr/local was really what caused my confusion. Installing in the build folder as you suggested in an earlier email was the culprit for me. Had I not specified "—prefix=“ flag all the includes would have been located automatically. I didn’t know that I needed to specify where the binary was for llvm-config. So I understand now. So now that the includes are being found building the tutorial results in 74 warnings and 20 errors. Heres a couple examples: In file included from /usr/local/include/llvm/IR/DerivedTypes.h:21: In file included from /usr/local/include/llvm/IR/Type.h:19: In file included from /usr/local/include/llvm/ADT/APFloat.h:20: In file included from /usr/local/include/llvm/ADT/APInt.h:19: In file included from /usr/local/include/llvm/ADT/ArrayRef.h:14: /usr/local/include/llvm/ADT/SmallVector.h:232:20: warning: rvalue references are a C++11 extension [-Wc++11-extensions] void push_back(T &&Elt) { ^ /usr/local/include/llvm/ADT/SmallVector.h:476:33: warning: rvalue references are a C++11 extension [-Wc++11-extensions] iterator insert(iterator I, T &&Elt) { In file included from toy.cpp:3: In file included from /usr/local/include/llvm/IR/IRBuilder.h:24: In file included from /usr/local/include/llvm/IR/Instructions.h:22: In file included from /usr/local/include/llvm/IR/Attributes.h:20: In file included from /usr/local/include/llvm/ADT/FoldingSet.h:21: /usr/local/include/llvm/Support/Allocator.h:134:70: error: expected expression BumpPtrAllocatorImpl<AllocatorT, SlabSize, SizeThreshold>> { ^ /usr/local/include/llvm/Support/Allocator.h:346:2: error: expected a type }; Do you know what would cause these errors? Thank you! Joseph
On 6/12/14, 3:07 PM, Joseph wrote:> Hi Dan, > > > So now that the includes are being found building the tutorial results in 74 warnings and 20 errors. Heres a couple examples: > > In file included from /usr/local/include/llvm/IR/DerivedTypes.h:21: > In file included from /usr/local/include/llvm/IR/Type.h:19: > In file included from /usr/local/include/llvm/ADT/APFloat.h:20: > In file included from /usr/local/include/llvm/ADT/APInt.h:19: > In file included from /usr/local/include/llvm/ADT/ArrayRef.h:14: > /usr/local/include/llvm/ADT/SmallVector.h:232:20: warning: rvalue references are a C++11 extension [-Wc++11-extensions] > void push_back(T &&Elt) { > ^ > /usr/local/include/llvm/ADT/SmallVector.h:476:33: warning: rvalue references are a C++11 extension [-Wc++11-extensions] > iterator insert(iterator I, T &&Elt) { >You need to build Clang/LLVM with a {CXX, CXXFLAGS} pair (read: a c++ compiler for your host) that supports C++11. That can either be one whose default is c++11, or one that doesn't but lets you put '--std=c++11' in the CXXFLAGS. http://llvm.org/docs/GettingStarted.html suggests GCC >= 4.7.0 for this.> > > Thank you! > Joseph > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-- Jon Roelofs jonathan at codesourcery.com CodeSourcery / Mentor Embedded
On Jun 12, 2014, at 4:37 PM, Jonathan Roelofs <jonathan at codesourcery.com> wrote:> > > On 6/12/14, 3:07 PM, Joseph wrote: >> Hi Dan, >> >> >> So now that the includes are being found building the tutorial results in 74 warnings and 20 errors. Heres a couple examples: >> >> In file included from /usr/local/include/llvm/IR/DerivedTypes.h:21: >> In file included from /usr/local/include/llvm/IR/Type.h:19: >> In file included from /usr/local/include/llvm/ADT/APFloat.h:20: >> In file included from /usr/local/include/llvm/ADT/APInt.h:19: >> In file included from /usr/local/include/llvm/ADT/ArrayRef.h:14: >> /usr/local/include/llvm/ADT/SmallVector.h:232:20: warning: rvalue references are a C++11 extension [-Wc++11-extensions] >> void push_back(T &&Elt) { >> ^ >> /usr/local/include/llvm/ADT/SmallVector.h:476:33: warning: rvalue references are a C++11 extension [-Wc++11-extensions] >> iterator insert(iterator I, T &&Elt) { >> > You need to build Clang/LLVM with a {CXX, CXXFLAGS} pair (read: a c++ compiler for your host) that supports C++11. That can either be one whose default is c++11, or one that doesn't but lets you put '--std=c++11' in the CXXFLAGS. > > http://llvm.org/docs/GettingStarted.html suggests GCC >= 4.7.0 for this.Hello again, Running gcc —version gets me the following results: Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn) So it looks like I do not have proper GCC installed, I figured that Xcode would have gcc included. I can see that I am in over my head because I do not know what CXX, CXXFLAGS are and where do you apply them? In make? In other words what does " put '--std=c++11' in the CXXFLAGS” mean? Do you have an example of what it would look like? or what should I read in order to learn this? I’m happy to read up but I don’t know where to start reading (besides the getting started page on llvm) :) Thank you for your suggestions! Joseph Morgan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140613/90b83d6b/attachment.html>