Compile error while building LLDB

I was just trying to build lldb-6.0 from source (and had previously successfully build llvm-6.0, clang-6.0, and lld-6.0 from source), but received a compile error while using both just cmake and cmake+ninja

Does this look familiar to anyone?

In file included from llvm/lldb-6.0.0.src/source/API/SystemInitializerFull.cpp:89:
In file included from llvm/lldb-6.0.0.src/source/./Plugins/SymbolFile/PDB/SymbolFilePDB.h:17:
In file included from llvm/DebugInfo/PDB/IPDBSession.h:13:
In file included from llvm/DebugInfo/PDB/PDBSymbol.h:13:
In file included from llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h:14:
In file included from llvm/DebugInfo/PDB/PDBTypes.h:13:
In file included from llvm/DebugInfo/CodeView/CodeView.h:509:
llvm/DebugInfo/CodeView/CodeViewRegisters.def:78:13: error: expected identifier
CV_REGISTER(CR0, 80)
^
/usr/include/sys/termios.h:184:14: note: expanded from macro ‘CR0’
#define CR0 0x00000000
^
In file included from llvm/lldb-6.0.0.src/source/API/SystemInitializerFull.cpp:89:
In file included from llvm/lldb-6.0.0.src/source/./Plugins/SymbolFile/PDB/SymbolFilePDB.h:17:
In file included from llvm/DebugInfo/PDB/IPDBSession.h:13:
In file included from llvm/DebugInfo/PDB/PDBSymbol.h:13:
In file included from llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h:14:
In file included from llvm/DebugInfo/PDB/PDBTypes.h:13:
In file included from llvm/DebugInfo/CodeView/CodeView.h:509:
llvm/DebugInfo/CodeView/CodeViewRegisters.def:79:13: error: expected identifier
CV_REGISTER(CR1, 81)
^
/usr/include/sys/termios.h:185:14: note: expanded from macro ‘CR1’
#define CR1 0x00001000
^
In file included from llvm/lldb-6.0.0.src/source/API/SystemInitializerFull.cpp:89:
In file included from llvm/lldb-6.0.0.src/source/./Plugins/SymbolFile/PDB/SymbolFilePDB.h:17:
In file included from llvm/DebugInfo/PDB/IPDBSession.h:13:
In file included from llvm/DebugInfo/PDB/PDBSymbol.h:13:
In file included from llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h:14:
In file included from llvm/DebugInfo/PDB/PDBTypes.h:13:
In file included from llvm/DebugInfo/CodeView/CodeView.h:509:
llvm/DebugInfo/CodeView/CodeViewRegisters.def:80:13: error: expected identifier
CV_REGISTER(CR2, 82)
^
/usr/include/sys/termios.h:186:14: note: expanded from macro ‘CR2’
#define CR2 0x00002000
^
In file included from llvm/lldb-6.0.0.src/source/API/SystemInitializerFull.cpp:89:
In file included from llvm/lldb-6.0.0.src/source/./Plugins/SymbolFile/PDB/SymbolFilePDB.h:17:
In file included from llvm/DebugInfo/PDB/IPDBSession.h:13:
In file included from llvm/DebugInfo/PDB/PDBSymbol.h:13:
In file included from llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h:14:
In file included from llvm/DebugInfo/PDB/PDBTypes.h:13:
In file included from llvm/DebugInfo/CodeView/CodeView.h:509:
llvm/DebugInfo/CodeView/CodeViewRegisters.def:81:13: error: expected identifier
CV_REGISTER(CR3, 83)
^
/usr/include/sys/termios.h:187:14: note: expanded from macro ‘CR3’
#define CR3 0x00003000
^
4 errors generated.
make[2]: *** [source/API/CMakeFiles/liblldb.dir/SystemInitializerFull.cpp.o] Error 1
make[1]: *** [source/API/CMakeFiles/liblldb.dir/all] Error 2
make: *** [all] Error 2

+ Jonas who hit the same bug recently.

I’m still trying to figure this out. On one of my machines it went away after a clean install even though my configuration is exactly the same. I’ll let you know once I know more.

Sounds like we have an issue in the CodeView headers related to a duplicate symbol. While this doesn’t entirely surprise me after seeing the error, I’m also not sure why this problem is only just happening now. Ultimately what’s happening is we have this enumeration:

enum class RegisterId : uint16_t {

CR3,

};

But your termios.h file also has a #define for CR3.

I guess one possible fix would be to rename these to something like CVRegCR3.

Sounds like we have an issue in the CodeView headers related to a duplicate symbol. While this doesn't entirely surprise me after seeing the error, I'm also not sure why this problem is only just happening now. Ultimately what's happening is we have this enumeration:

enum class RegisterId : uint16_t {
...
CR3,
...
};

But your termios.h file also has a #define for CR3.

I guess one possible fix would be to rename these to something like CVRegCR3.

Since I haven’t made any progress on this yet I’ve put up a CR with your suggestion: https://reviews.llvm.org/D47478