clang

Xcode clang link: Build Dynamic Framework (or dylib) not embed dependencies

冷暖自知 提交于 2019-12-23 03:31:34
问题 I’m building a dynamic framework for iOS. It needs reference some symbols from code or other libraries, but I not want link them into the framework. This can be achieved when build an static library, just setup search path and make sure them not included in target’s build phases. But when build a dynamic framework or dylib, this result undefined symbol error. I tried all kinds of link options, eg -l -weak_library -weak_framework -I -rpath -rpath-link . But none works. The link command looks

How to detect X32 ABI or environment in the preprocessor?

老子叫甜甜 提交于 2019-12-23 02:58:21
问题 X32 is an ABI for amd64 / x86_64 CPUs using 32-bit pointers. The idea is to combine the larger register set of x86_64 with the smaller memory and cache footprint resulting from 32-bit pointers. It provides up to about a 40% speedup. See Difference between x86, x32, and x64 architectures on Stack Overflow, and the Debian X32 Ports wiki page for details and setting it up as a chroot environment. We have a bug report from a Debian maintainer under the environment. The report is adcq is an

How to define string type in getOrInsertFunction() llvm?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 02:36:23
问题 I'm new to llvm and was trying to do instrument. But I found LLVM API only has primitive types, like: getInt32Ty(Ctx).. What i want to do use getOrInsertFunction(),the function argument type is string type.As is known, when argument type is int, we can do it like is : LLVMContext &Ctx = F.getContext(); Constant *logFunc = F.getParent()->getOrInsertFunction( "logop", Type::getVoidTy(Ctx), Type::getInt32Ty(Ctx), NULL ); Type::getInt32Ty(Ctx) is the function argument type (int), what i want to

C++11 standard libraries in libstdc++ on Mac

浪子不回头ぞ 提交于 2019-12-23 02:02:13
问题 In a Xcode project which I currently work on, I am using C++11 with Apple LLVM 4.2 (clang) compiler, and using libstdc++ as my standard library, because I am using a library (NTL) which was not compiled with libc++ and so I must use libstdc++. When writing the following code: #include <regex> int main() { return 0; } It doesn't compile, by saying: 'regex' file not found And so I can't use any C++11 library with my libstdc++ (Tried <mutex> , <thread> aswell). Another I tried to take is to

C++11 standard libraries in libstdc++ on Mac

点点圈 提交于 2019-12-23 02:02:05
问题 In a Xcode project which I currently work on, I am using C++11 with Apple LLVM 4.2 (clang) compiler, and using libstdc++ as my standard library, because I am using a library (NTL) which was not compiled with libc++ and so I must use libstdc++. When writing the following code: #include <regex> int main() { return 0; } It doesn't compile, by saying: 'regex' file not found And so I can't use any C++11 library with my libstdc++ (Tried <mutex> , <thread> aswell). Another I tried to take is to

How to tell clang that my LLVM Target should use 16-bit 'int'?

天涯浪子 提交于 2019-12-22 17:59:55
问题 For my PIC Backend, I want 'int' to be 16 bits. How can I / my target tell clang what should be the size of 'int'? Defining 16-bit registers only seems not sufficient. Currently "clang -O2 -emit-llvm -target pic" converts int foo(int a, int b) { return a + b; } to this IR code, using 32-bit integers: ; ModuleID = '../test/sum.c' source_filename = "../test/sum.c" target datalayout = "e-m:e-p:16:16-i16:16-a:0:16-n16-S16" target triple = "pic" ; Function Attrs: norecurse nounwind readnone define

clang: What does emitting mean?

て烟熏妆下的殇ゞ 提交于 2019-12-22 14:45:07
问题 The clang diagnostics reference uses the word emit four times. The following warnings use this term. Example 1: Compile this with -Wunneeded-internal-declaration -Wunneeded-member-function : namespace { int x; int F (); struct A { void M (); }; } decltype (x) global1; decltype (F ()) global2; decltype (&A::M) global3; You get the following warnings: warning: variable 'x' is not needed and will not be emitted warning: function 'F' is not needed and will not be emitted warning: member function

Is the compiler allowed to optimize out heap memory allocations?

情到浓时终转凉″ 提交于 2019-12-22 13:58:58
问题 Consider the following simple code that makes use of new (I am aware there is no delete[] , but it does not pertain to this question): int main() { int* mem = new int[100]; return 0; } Is the compiler allowed to optimize out the new call? In my research, g++ (5.2.0) and Visual Studio 2015 do not optimize out the new call, while clang (3.0+) does. All tests have been made with full optimizations enabled (-O3 for g++ and clang, Release mode for Visual Studio). Isn't new making a system call

Compilation error when using Xcode 9.0 with clang (cannot specify -o when generating multiple output files)

你说的曾经没有我的故事 提交于 2019-12-22 12:19:51
问题 I updated my Xcode yesterday (version 9.0) and since then I cannot compile my code with clang anymore. It works great with with apple native compiler, but gives a compilation error with clang from macports. I will explain with more details now... I usually use clang 4.0 because it has openmp support and I change in Xcode by creating a user-defined setting as in the following figure. Image with how to use clang 4.0 from macports in Xcode This has been working perfectly for some time until I

Changing compiler from MinGW32 to clang in CodeLite (Windows) results in compilation errors

不羁岁月 提交于 2019-12-22 11:44:10
问题 I have a project the successfully builds using MinGW32 on Windows 8.1 using CodeLite. I am trying to change the compiler from MinGW32 to clang. However, after switching the compiler over I get the following error: c:/MinGW/lib/gcc/mingw32/4.8.1/include/c++\bits/stringfwd.h:74:33: error: use of undeclared identifier 'char16_t' ...followed by many others of a similar nature. So, I tried making a simpler program to check if the program was simply in my code and I'd been 'lucky' with MinGW32. The