ExceptionDemo build failed

Dear LLVM Devs,

Recently when doing even a clean build the following error occurs:

/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp: In function ‘void createStandardUtilityFunctions(unsigned int, llvm::Module&, llvm::IRBuilder<true, llvm::ConstantFolder, llvm::IRBuilderDefaultInserter<true> >&)’:
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1666: error: call of overloaded ‘get(llvm::LLVMContext&, const llvm::IntegerType*, NULL)’ is ambiguous
/home/dawiejoubert/Source/SVN/Clang/llvm/include/llvm/DerivedTypes.h:246: note: candidates are: static llvm::StructType* llvm::StructType::get(llvm::LLVMContext&, llvm::ArrayRef<const llvm::Type*>, bool)
/home/dawiejoubert/Source/SVN/Clang/llvm/include/llvm/DerivedTypes.h:260: note: static llvm::StructType* llvm::StructType::get(llvm::LLVMContext&, const llvm::Type*, ...)
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1671: error: call of overloaded ‘get(llvm::LLVMContext&, llvm::StructType*&, NULL)’ is ambiguous
/home/dawiejoubert/Source/SVN/Clang/llvm/include/llvm/DerivedTypes.h:246: note: candidates are: static llvm::StructType* llvm::StructType::get(llvm::LLVMContext&, llvm::ArrayRef<const llvm::Type*>, bool)
/home/dawiejoubert/Source/SVN/Clang/llvm/include/llvm/DerivedTypes.h:260: note: static llvm::StructType* llvm::StructType::get(llvm::LLVMContext&, const llvm::Type*, ...)
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1679: error: call of overloaded ‘get(llvm::LLVMContext&, const llvm::IntegerType*, NULL)’ is ambiguous
/home/dawiejoubert/Source/SVN/Clang/llvm/include/llvm/DerivedTypes.h:246: note: candidates are: static llvm::StructType* llvm::StructType::get(llvm::LLVMContext&, llvm::ArrayRef<const llvm::Type*>, bool)
/home/dawiejoubert/Source/SVN/Clang/llvm/include/llvm/DerivedTypes.h:260: note: static llvm::StructType* llvm::StructType::get(llvm::LLVMContext&, const llvm::Type*, ...)
make[2]: ***
[examples/ExceptionDemo/CMakeFiles/ExceptionDemo.dir/ExceptionDemo.cpp.o] Error 1
make[1]: *** [examples/ExceptionDemo/CMakeFiles/ExceptionDemo.dir/all]
Error 2
make: *** [all] Error 2

Best regards,

Dawie Joubert
Senior Researcher: Information Security, Modelling and Digital Science,
CSIR

Tel: +27 12 841 3379
Fax: +27 12 841 2456
Mobile: +27 84 589 2078
E-Mail: djjoubert@csir.co.za

Fixed in r129139, thanks.

-Chris

Chris,

That fixed the "overloaded error" ... but now I have the following error
(from a clean build environment):

/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp: In function ‘void print32Int(int, const char*)’:
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:271: error: ‘stderr’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:271: error: ‘fprintf’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:275: error: ‘stderr’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:275: error: ‘fprintf’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp: In function ‘void print64Int(long int, const char*)’:
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:288: error: ‘stderr’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:288: error: ‘fprintf’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:292: error: ‘stderr’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:292: error: ‘fprintf’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp: In function ‘void printStr(char*)’:
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:301: error: ‘stderr’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:301: error: ‘fprintf’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:304: error: ‘stderr’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:304: error: ‘fprintf’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp: In function ‘void runExceptionThrow(llvm::ExecutionEngine*, llvm::Function*, int32_t)’:
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1594: error: ‘stderr’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1597: error: ‘fprintf’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1606: error: ‘stderr’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1607: error: ‘fprintf’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp: In function ‘int main(int, char**)’:
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1912: error: ‘stderr’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1921: error: ‘fprintf’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1982: error: ‘stderr’ was not declared in this scope
/home/dawiejoubert/Source/SVN/Clang/llvm/examples/ExceptionDemo/ExceptionDemo.cpp:1982: error: ‘fprintf’ was not declared in this scope
make[2]: ***
[examples/ExceptionDemo/CMakeFiles/ExceptionDemo.dir/ExceptionDemo.cpp.o] Error 1
make[1]: *** [examples/ExceptionDemo/CMakeFiles/ExceptionDemo.dir/all]
Error 2
make[1]: *** Waiting for unfinished jobs....

Best regards,

Dawie Joubert
Senior Researcher: Information Security, Modelling and Digital Science,
CSIR

Tel: +27 12 841 3379
Fax: +27 12 841 2456
Mobile: +27 84 589 2078
E-Mail: djjoubert@csir.co.za

Hi Dawie,

So I tested this with make on head branch for OS X 10.6.x, and it compiled and ran fine.
Since it looks like your are using cmake, and you are getting un-defines for symbols in
stdio.h and other headers, your environment is a little different from mine. Would you be
willing to help debug this as I don't have immediate access to a Linux system (I'm assuming
you are on one)?

If so, could you temporarily add #include <cstdio> on top of the existing #include <sstream> in
ExceptionDemo.cpp (<source root>/llvm/examples/ExceptionDemo.cpp), and then build, and
give me the results. That would be really helpful.

If you don't have time, I'll build a system later today to test.

Thanks in advance

Garrison

Garrison,

I did as you instructed and the Exception Example (and the whole of
Clang and LLVM for that matter) was able to build successfully in Linux
64-bit using Cmake and GCC (Ubuntu 4.4.3-4ubuntu5). I previously saw a
similar behavior that GCC "changed/removed" its default includes ...
possibly to allow for different "std libs" to be used in the future?

Anyway, thanks a mil for a kind response towards an "easy" problem, it
makes one want to assist your project even more!

Best regards,

Dawie Joubert
Senior Researcher: Information Security, Modelling and Digital Science,
CSIR

Tel: +27 12 841 3379
Fax: +27 12 841 2456
Mobile: +27 84 589 2078
E-Mail: djjoubert@csir.co.za

Glad I could be of help, however the fix I gave you is not the real answer, as
I believe a needed llvm header file has not been included. Regardless I'll post
when the repository update is available with the proper fix.

Also keep in mine that the example directory should not be built by default,
but rather explicitly requested. For example, in a make build, one has to set
the BUILD_EXAMPLES environmental variable to 1, in order for the examples
to be built. I'll have to check on cmake to see what the equivalent switch is.
Anyway you probably knew this. I just wanted to make sure you don't get stuck
with not being able to use clang/llvm just because the examples won't build.
Having said that, the examples should always build.

Thanks for reporting the issue, and your patience.

Garrison

In debugging this issue, I ran across a Linux configuration where the demo
associated to your previous build failure, fails to run. As this configuration uses
a small amazon's ec2 instance, and takes a very long time to build, I'm going to
have to build another system. In meantime would you be willing to the run the
test and see if there is a failure on your system? If you don't have time, no worries,
as it looks like I have to build another test platform anyway. However if you do
have time you would run this with:

<release type>/examples/ExceptionDemo 2 3 7 -1

at the top of the llvm object root where <release type> == Release+Asserts, or Debug for example.

I'm just looking to see if it crashes with:

Stack dump:
0. Running pass 'X86 DAG->DAG Instruction Selection' on function '@outerCatchFunct'
Segmentation fault

Garrison

PS: I have a feeling this is some sort of default bit width issue, but I have not had a chance
to look into it yet.

Looks like all is fine though I'm still not sure why your build originally failed as my
builds are not failing on any of the systems I tested on when the #include <cstdio>
is NOT added.

Regardless anything after -r129360, has the #include <cstdio> addition.

Thanks for the pointer

Garrison