authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-01-15 17:12:26-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-01-15 17:12:26-07:00
log8d60ffe314306e5295fb76338c6391e5fe986dea
tree06e551cf499421ce89656181b814c02c86875034
parent8409e518abad78cef8984b798c404bdc2923efbf

solve the mystery of undefined reference error

big surprise, C++ is to blame

3 files changed, 23 insertions(+), 0 deletions(-)

README.md+14
......@@ -90,3 +90,17 @@ cmake .. -DCMAKE_BUILD_TYPE=Release -DZIG_LIBC_DIR=path/to/libc/dir
9090make
9191sudo make install
9292```
93
94### Troubleshooting
95
96If you get one of these:
97
98 * `undefined reference to `_ZNK4llvm17SubtargetFeatures9getStringB5cxx11Ev'`
99 * `undefined reference to `llvm::SubtargetFeatures::getString() const'`
100
101This is because of [C++'s Dual ABI](https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html).
102Most likely LLVM was compiled with one compiler while Zig was compiled with a
103different one, for example GCC vs clang.
104
105To fix this, compile Zig with the same compiler that LLVM was compiled with, or
106add `-DZIG_LLVM_OLD_CXX_ABI=yes` to the cmake configure line.
src/config.h.in+2
......@@ -10,4 +10,6 @@
1010#define ZIG_STD_DIR "@CMAKE_INSTALL_PREFIX@/@ZIG_STD_DEST@"
1111#define ZIG_LIBC_DIR "@ZIG_LIBC_DIR@"
1212
13#cmakedefine ZIG_LLVM_OLD_CXX_ABI
14
1315#endif
src/zig_llvm.cpp+7
......@@ -5,6 +5,13 @@
55 * See http://opensource.org/licenses/MIT
66 */
77
8// This must go before all includes.
9#include "config.h"
10#if defined(ZIG_LLVM_OLD_CXX_ABI)
11#define _GLIBCXX_USE_CXX11_ABI 0
12#endif
13
14
815#include "zig_llvm.hpp"
916
1017/*