clang++

Clang Linking error: undefined reference to function calls added by LLVM pass

限于喜欢 提交于 2019-12-08 10:43:14
问题 So I am following this tutorial https://www.cs.cornell.edu/~asampson/blog/llvm.html to make a pass that instruments a program by adding calls to an external function (which is logop in rtlib.c). But unlike the tutorial I am trying to instrument a larger code-base which is masstree: https://github.com/kohler/masstree-beta. So as instructed for masstree I run ./configure first but then I edit the generated Makefile to use clang (instead of gcc/g++) and run my pass. I also add rtlib.c in the

setjmp and longjmp implementation

匆匆过客 提交于 2019-12-08 09:54:47
问题 basically my problem in short is my implementation for setjmp and longjmp doesn't work. the reason why i'm asking in this form not in (code review) is that i'm new to assembly i've little background and still learning but still not sure about the code (please read until the end). first i'v executed the code on two platforms with three different compilers and that's the reason why i'm sure that i'm doing something wrong with the assembler. platforms: mac OS 10.12.5 x86_64 , ubuntu linux x86

gcc: is there no tail recursion if I return std::string in C++?

别等时光非礼了梦想. 提交于 2019-12-08 02:23:43
问题 As per my answer in Write a recursive function that reverses the input string, I've tried seeing whether clang++ -O3 or g++ -O3 would make a tail-recursion optimisation, using some of the suggestions from How do I check if gcc is performing tail-recursion optimization?, but it doesn't look like any tail recursion optimisation is taking place. Any idea why? Does this have to do with the way C++ objects are created and destroyed? Is there any way to make it work? The programme: % cat t2.cpp

How to compile #include <experimental/any> for clang on OSX

杀马特。学长 韩版系。学妹 提交于 2019-12-08 01:57:49
问题 I am trying to get the #include <experimental/any> to compile in my C++ program on clang OSX // test.cpp #include <experimental/any> int main() { return 0; } Tried following commands/options as learnt from here clang++ -std=c++14 test.cpp -o test -std=c++1z -stdlib=libc++ clang++ -std=c++1x test.cpp -o test -std=c++1z -stdlib=libc++ clang++ -std=c++1y test.cpp -o test -std=c++1z -stdlib=libc++ clang++ -std=c++1z test.cpp -o test -std=c++1z -stdlib=libc++ But it doesn't compile & complains of

How to explicit instantiate template constructor in C++?

我怕爱的太早我们不能终老 提交于 2019-12-07 18:09:05
问题 Currently I have the following class //AABB.h class AABB { public: template <class T> AABB(const std::vector<T>& verties); template <class T> AABB(const std::vector<int>& indicies, const std::vector<T>& verties); template <class T> AABB(const std::vector<int>::const_iterator begin, const std::vector<int>::const_iterator end, const std::vector<T>& verties); AABB(); AABB(const vec3 min, const vec3 max); AABB(const AABB& other); const vec3& min_p() const { return m_min; } const vec3& max_p()

std::cerr on linux with clang++ and libc++ causes SIGABRT

怎甘沉沦 提交于 2019-12-07 16:18:23
问题 I'm trying to get a simple program running on Ubuntu 12.04 x64 compiled with clang++ 3.3 libc++ libc++abi . Program: #include <iostream> int main(int argc, char **argv) { try { std::cerr << "Test cerr \n"; } catch (...) { std::cout << "catch exception"; } return 0; } Writing to std::cerr prints the message, but results in SIGABRT. However, writing to std::cout works fine. Here the ldd output of the executable: $ldd cerr_test linux-vdso.so.1 => (0x00007fffce5ff000) libc++abi.so.1 => /usr/local

Clang Code Coverage Invalid Output

老子叫甜甜 提交于 2019-12-07 07:02:58
问题 So I've checked out and built the clang trunk by following these instructions http://clang.llvm.org/get_started.html. I can build my binary with --coverage and run it to get the .gcno and .gcda files, but when I run lcov I get "GENINFO: ... reached unexpected end of file". Now I'm stuck and came to SO to look for help :) I'm working with Ubuntu 13.04 and writing c++11, just in case that makes a difference. 回答1: I had the same problem with clang with lcov on Ubuntu 13.04. Here is the solution

Why am I getting “Undefined symbols … typeinfo … vtable” with a virtual and concrete class?

对着背影说爱祢 提交于 2019-12-07 05:27:00
问题 I'm relearning C++ (meaning: go gentle on me! :). I have a superclass ( Node ) with an abstract method ( step() ) that must be implemented in a subclass ( TestNode ). It compiles without error and without any warnings, but linking it results in: bash-3.2$ g++ -Wall -o ./bin/t1 src/t1.cpp Undefined symbols for architecture x86_64: "typeinfo for test::Node", referenced from: typeinfo for test::TestNode in t1-9f6e93.o "vtable for test::Node", referenced from: test::Node::Node() in t1-9f6e93.o

-fno-omit-frame-pointer equivalent compiler option for clang

梦想与她 提交于 2019-12-07 04:13:52
问题 I want to use DS-5 Streamline profiler to profile my code. In the documentation its mentioned that to be able to see call stacks, we need to compile code with compiler option -fno-omit-frame-pointer . This option is there in gcc. Is there an equivalent option for clang also? -fno-omit-frame-pointer is not working for me with clang. I have also tried setting the compiler optimization level to 0, but still I am not getting call stacks in streamline. 回答1: It looks like DS-5 is an ARM thing, so

How to fix a purported lack of an “explicit instantiation declaration” when compiling a CRTP Singleton with Clang?

一曲冷凌霜 提交于 2019-12-07 03:34:12
问题 We're using the curiously recurring template pattern to implement singletons. However, with recent Clang versions we're getting a -Wundefined-var-template warning. The suggested fix to which is to add an "explicit instantiation declaration". I attempted to do this, but then I get errors about "explicit specialization after instantiation" in the compilation unit where the definition of the singleton template class member variable is. What's the appropriate construct to fix the issue