zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 8d60ffe314306e5295fb76338c6391e5fe986dea (tree)
parent 8409e518abad78cef8984b798c404bdc2923efbf
Author: Andrew Kelley <superjoe30@gmail.com>
Date:   Fri, 15 Jan 2016 17:12:26 -0700

solve the mystery of undefined reference error

big surprise, C++ is to blame

Diffstat:
MREADME.md | 14++++++++++++++
Msrc/config.h.in | 2++
Msrc/zig_llvm.cpp | 7+++++++
3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -90,3 +90,17 @@ cmake .. -DCMAKE_BUILD_TYPE=Release -DZIG_LIBC_DIR=path/to/libc/dir make sudo make install ``` + +### Troubleshooting + +If you get one of these: + + * `undefined reference to `_ZNK4llvm17SubtargetFeatures9getStringB5cxx11Ev'` + * `undefined reference to `llvm::SubtargetFeatures::getString() const'` + +This is because of [C++'s Dual ABI](https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html). +Most likely LLVM was compiled with one compiler while Zig was compiled with a +different one, for example GCC vs clang. + +To fix this, compile Zig with the same compiler that LLVM was compiled with, or +add `-DZIG_LLVM_OLD_CXX_ABI=yes` to the cmake configure line. diff --git a/src/config.h.in b/src/config.h.in @@ -10,4 +10,6 @@ #define ZIG_STD_DIR "@CMAKE_INSTALL_PREFIX@/@ZIG_STD_DEST@" #define ZIG_LIBC_DIR "@ZIG_LIBC_DIR@" +#cmakedefine ZIG_LLVM_OLD_CXX_ABI + #endif diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp @@ -5,6 +5,13 @@ * See http://opensource.org/licenses/MIT */ +// This must go before all includes. +#include "config.h" +#if defined(ZIG_LLVM_OLD_CXX_ABI) +#define _GLIBCXX_USE_CXX11_ABI 0 +#endif + + #include "zig_llvm.hpp" /*