[patch] Fix problems with build LLVM using gcc 4.1.0 (gcc CVS mainline)

Hi!

I have some problems with build current CVS version LLVM using GCC 4.1.0 (GCC CVS mainline version).

1) Build terminate with error:

llvm[3]: Compiling SparcV8CodeEmitter.cpp for Debug build
/usr/home/wanderer/pkg/build/llvm/obj/lib/Target/SparcV8/SparcV8GenCodeEmitter.inc:11: error: definition of 'unsigned int llvm::<unnamed>::SparcV8CodeEmitter::getBinaryCodeForInstr(llvm::MachineInstr&)' is not in namespace enclosing 'llvm::<unnamed>::SparcV8CodeEmitter'
gmake[3]: *** [/usr/home/wanderer/pkg/build/llvm/obj/lib/Target/SparcV8/Debug/SparcV8CodeEmitter.o] Error 1

Problem in including SparcV8GenCodeEmitter.inc:

namespace llvm {
  ...
#include "SparcV8GenCodeEmitter.inc"

} // end llvm namespace

But SparcV8GenCodeEmitter.inc generated with

namespace llvm {
  ...
} // end llvm namespace

2) Same error but some diff. problem with AlphaCodeEmitter.cpp and PPCCodeEmitter.cpp:

GCC don't like definition member-functions in global namespace with declaration in llvm::<unnamed> :

3) Patch suggested in http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20051017/028898.html move END_WITH_NULL to before function name.

Vladimir

=== Patches ===========================

--- lib/Target/SparcV8/SparcV8CodeEmitter.cpp Mon Oct 24 08:25:17 2005
+++ lib/Target/SparcV8/SparcV8CodeEmitter.cpp.new Mon Oct 24 03:17:38 2005
@@ -181,6 +181,6 @@
   abort();
}

-#include "SparcV8GenCodeEmitter.inc"

I have some problems with build current CVS version LLVM using GCC 4.1.0 (GCC CVS mainline version).

Thanks!

1) Build terminate with error:

llvm[3]: Compiling SparcV8CodeEmitter.cpp for Debug build
/usr/home/wanderer/pkg/build/llvm/obj/lib/Target/SparcV8/SparcV8GenCodeEmitter.inc:11: error: definition of 'unsigned int

Patch applied:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20051017/028993.html

2) Same error but some diff. problem with AlphaCodeEmitter.cpp and PPCCodeEmitter.cpp:

GCC don't like definition member-functions in global namespace with declaration in llvm::<unnamed> :

Can you try this patch and see if it works? I'd rather not put the entire file in namespace scope like V8:

Index: AlphaCodeEmitter.cpp

2) Same error but some diff. problem with AlphaCodeEmitter.cpp and PPCCodeEmitter.cpp:

GCC don't like definition member-functions in global namespace with declaration in llvm::<unnamed> :

Sorry for wrong comment.
Must be:
GCC 4.1.0 don't like definition member-functions in llvm namespace with declaration in <global>::<unnamed> namespace

For example

PPCCodeEmitter.cpp:

using namespace llvm;

namespace {
  class PPCCodeEmitter : public MachineFunctionPass {
    ...
   }
  ...
}
...
#include "PPCGenCodeEmitter.inc"

But PPCCodeEmitter.inc:

namespace llvm {
  ...
} // end llvm namespace

As result LLVM build terminate with error:

/usr/home/wanderer/pkg/build/llvm/obj/lib/Target/PowerPC/PPCGenCodeEmitter.inc:11: error: definition of 'unsigned int<unnamed>::PPCCodeEmitter::getBinaryCodeForInstr(llvm::MachineInstr&)' is not in namespace enclosing '<unnamed>::PPCCodeEmitter'

After adding "namespace llvm {" in AlphaCodeEmitter.cpp
gcc 4.1.0 terminate build with error:
/home/wanderer/pkg/build/llvm/src/llvm/lib/Target/Alpha/AlphaCodeEmitter.cpp:76: error: explicit qualification in declaration of 'llvm::FunctionPass* llvm::createAlphaCodeEmitterPass(llvm::MachineCodeEmitter&)'

As result I remove llvm:: from line:
FunctionPass *llvm::createAlphaCodeEmitterPass(MachineCodeEmitter &MCE) {

Vladimir

Ahhh, ok, I see. I just applied a patch to SparcV8. With it, does this patch fix the problem?

Sorry for wrong comment.
Must be:
GCC 4.1.0 don't like definition member-functions in llvm namespace with declaration in <global>::<unnamed> namespace

Ahhh, ok, I see. I just applied a patch to SparcV8. With it, does this patch fix the problem?

- o << "namespace llvm {\n\n";
+ //o << "namespace llvm {\n\n";

Yes :slight_smile:

Vladimir

Great! Applied:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20051024/029002.html

Thanks for the heads up!

-Chris