llvm-clang

Compilation failing on EnableABIBreakingChecks

送分小仙女□ 提交于 2019-12-06 06:42:18
问题 I recently installed LLVM v8.0.0 (on RHEL 7.4). I am going through the LLVM Kaleidoscope tutorial to learn how to use the system, but am running into an issue linking. Per the tutorial (end of chapter 2), I run: clang++ -g -O3 kld.cpp `llvm-config --cxxflags` -o kld It compiles, but the linker fails on: /tmp/kld-f7264f.o:(.data+0x0): undefined reference to `llvm::EnableABIBreakingChecks' clang-8: error: linker command failed with exit code 1 (use -v to see invocation) I suspected this may

Adding nodes to Clang's AST

爷,独闯天下 提交于 2019-12-06 05:38:19
问题 I need to insert new nodes to AST. for instance, adding a namespace to a function: Turning this - void foo(); into this - namespace bar { void foo(); } I read How to clone or create an AST Stmt node of clang? but I prefer not using source-to-source compilation Tnx 回答1: The answer can be found here http://clang-developers.42468.n3.nabble.com/Adding-nodes-to-Clang-s-AST-td4054800.html However, the nodes are added to the compiled AST - for instance, in case one wants to inject a namespace to the

Quirk with Core Data, protocols, and readwrite vs. readonly property declarations

倾然丶 夕夏残阳落幕 提交于 2019-12-06 02:47:41
I'm running into an odd quirk involving Core Data, a declared protocol, and perhaps the LLVM 1.5 compiler. Here's the situation. I have a Core Data model that among others has two classes, IPContainer and IPEvent, with IPContainer being the parent entity of IPEvent. Each entity has a custom class in the project for it, created using mogenerator. mogenerator generates an additional subclass that just contains the modeled property declarations, so the class hierarchy is actually IPEvent > _IPEvent > IPContainer > _IPContainer > NSManagedObject. The IPContainer entity has an attribute named 'id',

Do C++ compilers perform compile-time optimizations on lambda closures?

纵饮孤独 提交于 2019-12-05 20:22:48
问题 Suppose we have the following (nonsensical) code: const int a = 0; int c = 0; for(int b = 0; b < 10000000; b++) { if(a) c++; c += 7; } Variable 'a' equals zero, so the compiler can deduce on compile time, that the instruction 'if(a) c++;' will never be executed and will optimize it away. My question: Does the same happen with lambda closures? Check out another piece of code: const int a = 0; function<int()> lambda = [a]() { int c = 0; for(int b = 0; b < 10000000; b++) { if(a) c++; c += 7; }

Building autotooled software to LLVM bitcode

狂风中的少年 提交于 2019-12-05 17:16:01
问题 I would like to compile software using the autotools build system to LLVM bitcode; that is, I would like the executables obtained at the end to be LLVM bitcode, not actual machine code. (The goal is to be able to run LLVM bitcode analysis tools on the whole program.) I've tried specifying CC="clang -emit-llvm -use-gold-plugins" and variants to the configure script, to no avail. There is always something going wrong (e.g. the package builds .a static libraries, which are refused by the linker)

'ext/slist' file not found on OS X 10.9

删除回忆录丶 提交于 2019-12-05 16:00:59
I am trying to get some older third-party software to compile on OS X 10.9. I've managed to get rid of most compilation problems by adjusting settings in the Makefiles, which were originally written for gcc probably around 2005. However, I currently don't know how to overcome this error for a C++ source file: /utility.h:42:10: fatal error: 'ext/slist' file not found I understand that ext/slist belongs to some version of STL . Has that version been superseded or does it have to be activated in any special way for Apple's version of Clang/ LLVM (5.0 for OS X 10.9)? If at all possible, I would

Getting actual value of local variables in llvm

空扰寡人 提交于 2019-12-05 13:55:58
If I have this example: int a=0, b=0; a and b are local variables and make any modifications in their values, such as: a++; b++; I need to get the value in this line code during running MCJIT. I mean by value not Value class, but the actual integer or any type value. You need to return the value from a JITed LLVM function in order to retrieve it from the code invoking MCJIT. Check out this Kaleidoscope example . The relevant code is in HandleTopLevelExpression(): if (FunctionAST *F = ParseTopLevelExpr()) { if (Function *LF = F->Codegen()) { // JIT the function, returning a function pointer.

Enable LLVM + Clang in Xcode new project causes linking errors

牧云@^-^@ 提交于 2019-12-05 05:48:48
问题 I've done a complete clean uninstall of XCode and deleted the prefs and deleted complete /Developer folder and reinstalled XCode again. I create a new Cocoa application, go over to Target, doing a "Get info" in the target and enable "C / C++ compiler version" to "LLVM compiler 1.0.2" and press Build. I get: ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64' following -L not found ld: warning: directory '/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64' following -L not found

Unable to cross-compile to SPARC using clang

好久不见. 提交于 2019-12-05 04:30:21
So here's the situation: I need to be able to compile binaries from a Linux machine (on Ubuntu, for what it's worth) which are able to run from a SPARC server. The program I'm trying to compile is very simple: #include <stdio.h> #include <stdlib.h> int main() { printf("Testing the SPARC program..."); return EXIT_SUCCESS; } I've tried a number of different compile lines to get it to work, but unfortunately nothing appears to be working. I tried the traditional: clang -target sparc blah.c -o blahsparc But this doesn't work, with a bunch of assembler failures: /tmp/blah-519e77.s: Assembler

Getting clang-tidy to fix header files

非 Y 不嫁゛ 提交于 2019-12-05 00:44:48
I'm in the process of moving a project currently compiling with gcc to clang, and have a bunch of warnings that gcc didn't generate ( -Winconsistent-missing-override ). clang-tidy works for fixing these errors in the *.cpp files, however it doesn't touch the hpp files because a compile command wasn't found in the database (as I would expect). I'm using ninja to build the project and ninja -t compdb cc cxx > .build/compile_commands.json to generate the compilation database. I've tried running: clang-tidy-3.6 -p .build/ \ $(find src/ -name *.cpp) \ $(find src/ -name *.hpp) \ --checks=misc-use