Hendrik Boom
2008-Jun-02 16:43 UTC
[LLVMdev] The first two lines of llvm tutorial don't compile.
I took the first two lines of the sample program in the tutorial: hendrik at lovesong:~/dv/lang/hlvm$ cat broken.cpp #include "llvm/DerivedTypes.h" #include "llvm/Module.h" hendrik at lovesong:~/dv/lang/hlvm$ and tried to compile them using the llvm-dev in Debian testing: hendrik at lovesong:~/dv/lang/hlvm$ g++ -o broken.o -c broken.cpp In file included from /usr/include/llvm/Type.h:16, from /usr/include/llvm/DerivedTypes.h:21, from broken.cpp:1: /usr/include/llvm/Support/DataTypes.h:38:3: error: #error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" hendrik at lovesong:~/dv/lang/hlvm$ Did I do something wrong, or is something broken? In llvm or in g++? hendrik at lovesong:~/dv/lang/hlvm$ g++ --version g++ (GCC) 4.2.4 (Debian 4.2.4-1) Copyright (C) 2007 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. hendrik at lovesong:~/dv/lang/hlvm$ -- hendrik
Thomas Hudson
2008-Jun-02 16:52 UTC
[LLVMdev] The first two lines of llvm tutorial don't compile.
You need to use the script 'llvm-config' to pass correct arguments to g ++: g++ -o broken.o `llvm-config --cxxflags` broken.cpp On Jun 2, 2008, at 9:43 AM, Hendrik Boom wrote:> I took the first two lines of the sample program in the tutorial: > > > hendrik at lovesong:~/dv/lang/hlvm$ cat broken.cpp > #include "llvm/DerivedTypes.h" > #include "llvm/Module.h" > hendrik at lovesong:~/dv/lang/hlvm$ > > > and tried to compile them using the llvm-dev in Debian testing: > > > hendrik at lovesong:~/dv/lang/hlvm$ g++ -o broken.o -c broken.cpp > In file included from /usr/include/llvm/Type.h:16, > from /usr/include/llvm/DerivedTypes.h:21, > from broken.cpp:1: > /usr/include/llvm/Support/DataTypes.h:38:3: error: #error "Must > #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" > hendrik at lovesong:~/dv/lang/hlvm$ > > > Did I do something wrong, or is something broken? In llvm or in g++? > > > hendrik at lovesong:~/dv/lang/hlvm$ g++ --version > g++ (GCC) 4.2.4 (Debian 4.2.4-1) > Copyright (C) 2007 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. > > hendrik at lovesong:~/dv/lang/hlvm$ > > > > -- hendrik > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Mike Stump
2008-Jun-02 17:04 UTC
[LLVMdev] The first two lines of llvm tutorial don't compile.
On Jun 2, 2008, at 9:43 AM, Hendrik Boom wrote:> I took the first two lines of the sample program in the tutorial:> /usr/include/llvm/Support/DataTypes.h:38:3: error: #error "Must > #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h"The #error is unfortunate. It all comes about because the C standards committee tried to define C++ and they got it wrong. Then this wrong concept was burned into stdint.h, for poor project folks to deal with. From the header itself: // Note that this header's correct operation depends on __STDC_LIMIT_MACROS // being defined. We would define it here, but in order to prevent Bad Things // happening when system headers or C++ STL headers include stdint.h before // we define it here, we define it on the g++ command line (in Makefile.rules). #if !defined(__STDC_LIMIT_MACROS) # error "Must #define __STDC_LIMIT_MACROS before #including Support/ DataTypes.h" #endif So, for now, it looks like you have to define the on the command line. :-( This code is bogus however, working stdint.h files don't need this defined and checking it like this is wrong.
Hendrik Boom
2008-Jun-02 17:10 UTC
[LLVMdev] The first two lines of llvm tutorial don't compile.
On Mon, 02 Jun 2008 09:52:16 -0700, Thomas Hudson wrote:> You need to use the script 'llvm-config' to pass correct arguments to g > ++: > > g++ -o broken.o `llvm-config --cxxflags` broken.cpp > >Interesting. When I type the command as you provided it (using cut-and-paste) I get: hendrik at lovesong:~/dv/lang/hlvm$ g++ -o broken.o `llvm-config --cxxflags` broken.cpp g++: (Debian: No such file or directory g++: 2.2-7): No such file or directory hendrik at lovesong:~/dv/lang/hlvm$ So I execute the script by itself, and get hendrik at lovesong:~/dv/lang/hlvm$ llvm-config --cxxflags -I/usr/include/llvm -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O2 -fomit-frame-pointer -DLLVM_DEBIAN_INFO= (Debian 2.2-7) -Woverloaded-virtual hendrik at lovesong:~/dv/lang/hlvm$ Putting that output into the command, and removing the -DLLVM_DEBIAN_INFO= (Debian 2.2-7) from it, things work as well as one might expect for a program without main(): hendrik at lovesong:~/dv/lang/hlvm$ g++ -o broken.o -I/usr/include/llvm -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -O2 -fomit-frame-pointer -Woverloaded-virtual broken.cpp/usr/lib/gcc/i486-linux-gnu/4.2.4/../../../../lib/crt1.o: In function `_start': (.text+0x18): undefined reference to `main' collect2: ld returned 1 exit status hendrik at lovesong:~/dv/lang/hlvm$ Do you suppose a bug should be logged against the Debian package? -- hendrik