llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.47k stars 11.77k forks source link

Unable to build dragonegg against LLVM from trunk #8601

Closed oroppas closed 14 years ago

oroppas commented 14 years ago
Bugzilla Link 8229
Resolution FIXED
Resolved on Sep 27, 2010 11:33
Version trunk
OS Linux

Extended Description

gcc 4.5.1

Compiling utils/target.cpp Linking target Compiling llvm-cache.c Compiling llvm-convert.cpp In file included from /usr/include/llvm/Support/Allocator.h:17:0, from /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.h:35, from /home/ryuta/devel/dragonegg/src/dragonegg/llvm-convert.cpp:28: /usr/include/llvm/Support/AlignOf.h:57:24: error: expected unqualified-id before ‘alignof’ In file included from /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.h:35:0, from /home/ryuta/devel/dragonegg/src/dragonegg/llvm-convert.cpp:28: /usr/include/llvm/Support/Allocator.h: In member function ‘void llvm::SpecificBumpPtrAllocator::DestroyAll()’: /usr/include/llvm/Support/Allocator.h:204:46: error: expected primary-expression before ‘<’ token /usr/include/llvm/Support/Allocator.h:204:48: error: expected primary-expression before ‘>’ token /usr/include/llvm/Support/Allocator.h:204:50: error: expected primary-expression before ‘)’ token In file included from /usr/include/llvm/ValueSymbolTable.h:18:0, from /home/ryuta/devel/dragonegg/src/dragonegg/llvm-convert.cpp:39: /usr/include/llvm/ADT/StringMap.h: In static member function ‘static llvm::StringMapEntry llvm::StringMapEntry::Create(const char, const char, AllocatorTy&, InitType)’: /usr/include/llvm/ADT/StringMap.h:170:33: error: expected primary-expression before ‘<’ token /usr/include/llvm/ADT/StringMap.h:170:48: error: expected primary-expression before ‘>’ token /usr/include/llvm/ADT/StringMap.h:170:50: error: expected primary-expression before ‘)’ token In file included from /home/ryuta/devel/dragonegg/src/dragonegg/llvm-convert.cpp:61:0: /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/plugin/include/system.h: At global scope: /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/plugin/include/system.h:382:53: error: declaration of ‘int getopt(int, char const, const char)’ throws different exceptions /usr/include/getopt.h:152:12: error: from previous declaration ‘int getopt(int, char const, const char*) throw ()’ make: *** [llvm-convert.o] Error 1

llvmbot commented 14 years ago

The build now has no warnings with -Wextra -pedantic on my machine.

oroppas commented 14 years ago

I suggest you turn off -Werror. I've given up on supporting -Werror because to support it you need to have zero warnings on every platform and for every compiler (and compiler version) - and there are just too many strange platforms out there, not to mention strange compilers with curious ideas of what to warn about. That said, I do try to have no warnings from the build in most cases. If you turn off -Wextra I expect that you too will have no warnings. That leaves the question of whether it is worth having dragonegg be -Wextra clean - probably it is, so I'm leaving this bugreport open until that is the case (or I change my mind!).

Yes, removing -Wextra gets rid of the warning. I see why you have to turn off -Werror.

Thanks for your support.

llvmbot commented 14 years ago

I suggest you turn off -Werror. I've given up on supporting -Werror because to support it you need to have zero warnings on every platform and for every compiler (and compiler version) - and there are just too many strange platforms out there, not to mention strange compilers with curious ideas of what to warn about. That said, I do try to have no warnings from the build in most cases. If you turn off -Wextra I expect that you too will have no warnings. That leaves the question of whether it is worth having dragonegg be -Wextra clean - probably it is, so I'm leaving this bugreport open until that is the case (or I change my mind!).

oroppas commented 14 years ago

That doesn't explain -Werror (which is the reason for the build failure: turning warnings into errors).

Oops. I forgot to mention I turned LLVM_ENABLE_WERROR on in LLVM configuration. That's why llvm-config --cxxflags holds both -W and -Werror.

llvmbot commented 14 years ago

That doesn't explain -Werror (which is the reason for the build failure: turning warnings into errors).

oroppas commented 14 years ago

I see the same (plus a bunch of other warnings) with -W. Why are you building with -W and -Werror? By the way, I cleaned things up so that I no longer see any warnings with -pedantic.

Well, that is because I configured and built LLVM using CMake with warnings enabled. And that automatically sets extra warning-related flags in llvm-config --cxxflags and hence in Makefile. LLVM can be built with extra warning flags.

llvmbot commented 14 years ago

I see the same (plus a bunch of other warnings) with -W. Why are you building with -W and -Werror? By the way, I cleaned things up so that I no longer see any warnings with -pedantic.

oroppas commented 14 years ago

The Makefile always specifies -Wall, so I'm compiling with it too but I don't see this. Are you building with gcc-4.5.1 or some other compiler, if so which one?

I'm using gcc-4.5.1

Nonetheless, I figured out that the warning is triggered by the -W (-Wextra) flag which in turn invokes -Wmissing-field-initializers flag. And I also confirmed gcc without -W doesn't issue the warning. Can you try with -W to see what happens?

llvmbot commented 14 years ago

The Makefile always specifies -Wall, so I'm compiling with it too but I don't see this. Are you building with gcc-4.5.1 or some other compiler, if so which one?

oroppas commented 14 years ago

I committed the HAVE_DECL_GETOPT change. I don't know why you are getting the llvm-debug.cpp errors. It is true that no initializer is given for column and sysp, but as far as I know this is perfectly valid (it means that they are initialized to zero). My version of gcc-4.5 doesn't complain about it even with -pedantic.

You can reproduce the error by compiling with -Wall and -Werror flag. I was able to fix it by initializing individual field of struct. I thought the way Location gets initialized is valid too, but clearly gcc with -Wall doesn't like it and issues the warning...

Index: llvm-debug.cpp

--- llvm-debug.cpp (revision 114802) +++ llvm-debug.cpp (working copy) @@ -161,7 +161,9 @@ /// whether the node is a TYPE or DECL. UseStub is true if we should consider /// the type stub as the actually location (ignored in struct/unions/enums.) static expanded_location GetNodeLocation(tree Node, bool UseStub = true) {

llvmbot commented 14 years ago

I committed the HAVE_DECL_GETOPT change. I don't know why you are getting the llvm-debug.cpp errors. It is true that no initializer is given for column and sysp, but as far as I know this is perfectly valid (it means that they are initialized to zero). My version of gcc-4.5 doesn't complain about it even with -pedantic.

oroppas commented 14 years ago

Does this fix it?

Index: llvm-convert.cpp

--- llvm-convert.cpp (revision 114791) +++ llvm-convert.cpp (working copy) @@ -58,6 +58,7 @@ // GCC headers extern "C" {

include "config.h"

+#undef HAVE_DECL_GETOPT

include "system.h"

include "coretypes.h"

include "target.h"

Yes, it did.

Now, llvm-backend.cpp and llvm-debug.cpp have the same issue. Fixing it by inserting the line #undef HAVE_DECL_GETOPT, I was able to compile up to this point:

Compiling llvm-debug.cpp cc1plus: warnings being treated as errors /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp: In function ‘expanded_location GetNodeLocation(tree_node, bool)’: /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp:163:42: error: missing initializer for member ‘expanded_location::column’ /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp:163:42: error: missing initializer for member ‘expanded_location::sysp’ /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp: In member function ‘llvm::DIType llvm::DebugInfo::createEnumType(tree_node)’: /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp:705:37: error: missing initializer for member ‘expanded_location::column’ /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp:705:37: error: missing initializer for member ‘expanded_locCompiling llvm-debug.cpp cc1plus: warnings being treated as errors /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp: In function ‘expanded_location GetNodeLocation(tree_node, bool)’: /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp:163:42: error: missing initializer for member ‘expanded_location::column’ /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp:163:42: error: missing initializer for member ‘expanded_location::sysp’ /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp: In member function ‘llvm::DIType llvm::DebugInfo::createEnumType(tree_node)’: /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp:705:37: error: missing initializer for member ‘expanded_location::column’ /home/ryuta/devel/dragonegg/src/dragonegg/llvm-debug.cpp:705:37: error: missing initializer for member ‘expanded_location::sysp’ make: [llvm-debug.o] Error 1 ation::sysp’ make: [llvm-debug.o] Error 1

llvmbot commented 14 years ago

Does this fix it?

Index: llvm-convert.cpp

--- llvm-convert.cpp (revision 114791) +++ llvm-convert.cpp (working copy) @@ -58,6 +58,7 @@ // GCC headers extern "C" {

include "config.h"

+#undef HAVE_DECL_GETOPT

include "system.h"

include "coretypes.h"

include "target.h"

oroppas commented 14 years ago

Are you compiling with -pedantic ?

Ah, you're right. Here's my llvm-config --cxxflags:

-I/usr/include -D_GNU_SOURCE -fPIC -DSTDC_LIMIT_MACROS -DSTDC_CONSTANT_MACROS -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -Werror

llvmbot commented 14 years ago

Are you compiling with -pedantic ?

oroppas commented 14 years ago

You need dragonegg trunk if you want to build against LLVM trunk.

My bad. This is the actual error I got:

Compiling llvm-convert.cpp In file included from /home/ryuta/devel/dragonegg/src/dragonegg/llvm-convert.cpp:61:0: /usr/lib/gcc/i686-pc-linux-gnu/4.5.1/plugin/include/system.h:382:53: error: declaration of ‘int getopt(int, char const, const char)’ throws different exceptions /usr/include/getopt.h:152:12: error: from previous declaration ‘int getopt(int, char const, const char) throw ()’ make: *** [llvm-convert.o] Error 1

Please disregard the earlier error message.

oroppas commented 14 years ago

You need dragonegg trunk if you want to build against LLVM trunk.

This dragonegg is from trunk at revision 114542.

llvmbot commented 14 years ago

You need dragonegg trunk if you want to build against LLVM trunk.