I wish to do path profiling. I am using LLVM 4.0. After building and llvm I don't find llvm-prof tool. Is it removed? What are the options available for profiling now? Should I use older versions of LLVM?.
I also don't find profiling passes in /lib/Transformation!
Is there a repository of passes which I can use?
Related
I've recently downloaded and successfully compiled a small CUDA dll using NVCC (10.2). Unfortunately because I have the most recent toolkit version the distribution requires the most recent driver version too. So I was wondering if there was an NVCC flag that enabled me to effectively target an earlier driver version and then distribute with an older runtime.
Currently, I have to check the run time and driver versions in order to check for compatibility.
The CUDA toolchain, runtime API and its support libraries are versioned and if you build runtime API code with a given toolkit version, you must ship the resulting code with all the libraries from that version or have users install that toolkit version (aka the tensorflow problem).
If you use the driver API, then you can potentially target a lower compute capability with PTX which might be backward compatible with a different driver. I say might because there are still PTX version support limits which can stop it from working correctly.
If you want to support older CUDA versions, just install the older toolchain and build using that toolkit.
We compile different branches of our project with different versions of Xcode, because it has different versions of the c++ compiler "clang" built-in. And a new compiler not only means new features, but unfortunately also new compiler bugs (hence new workarounds). So we want to keep the compiler once we branched a stable version of our project, but always use the latest compiler for the trunk.
Installing several Xcode versions is easy: We just add the Version number to the name and so we get:
/Applications/Xcode9
/Applications/Xcode10
/Applications/Xcode11
For the integration server and other scripts the required version can easily be picked and started with
xcode-select -s /Applications/Xcode10.app
xcodebuild -project myproj.xcodeproj build
But for working on the different branches with Xcode as graphical IDE this proves to be quite a problem:
Unlike Visual Studio Solutions (.sln and .vcxproj), Xcode Projects (.xcproj) don't support the specification of an IDE version they open in.
Different versions of Xcode don't play well together and seem to overwrite each others settings and caches (e.g. which projects/windows that were open, and even build status).
My last hope of solving this is to always use the latest Xcode IDE, but let it use an earlier compiler version.
There seems to be a project setting under Build Options for this, called Compiler for C/C++/Objective-C (GCC_VERSION when set via .xcconfig) with the standard value Default Compiler (Apple Clang) (com.apple.compilers.llvm.clang.1_0).
However, I was not able to find another valid value that I could use there. So far, I have tried clang version number and path to the clang executable (e.g. /Applications/Xcode10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang). Xcode always says Unsupported Compiler.
So what is the correct way to specify another compiler version in Xcode? Or do you know another approach to solve the original problem?
I found a way to use an older clang version in latest IDE. This example works for using the Apple LLVM version 10.0.0 (clang-1000.11.45.2) in the Xcode 11.3:
In the .xcconfig file (Menu->File->New->File, "Configuration Settings File"), the compiler paths can be set explicitly with
CC = /Applications/Xcode10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
CPLUSPLUS = /Applications/Xcode10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
But this is not enough: The system header files of a newer Xcode installation are sometimes incompatible with the old compiler. We need to set the roots for these files accordingly
OTHER_CFLAGS = -isysroot /Applications/Xcode10.app/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
From llvm's site, I can dowload the prebuilt binary of LLVM 4.0. After having installed the prebuilt binary on Windows with Visual Studio 2017, I can easily switch the compiler between VC++ and Clang 4.0 via Platform Toolset options.
From Getting Started with the LLVM System using Microsoft Visual Studio, I can also build LLVM toolchain (result in many executables) on Windows. However, I don't know how to make a prebuilt installer and get the same effects as the official version provided.
Because llvm's site doesn't provide prebuilt binary for LLVM 5.0 (SVN), so I have to do it myself.
Is there a tutorial telling me how to build the installer of LLVM 5.0 (SVN) from LLVM's source code?
Thanks in advance.
==================
Why LLVM 5.0
The following C++17's features are available in LLVM 5.0 only:
Template argument deduction for class templates
constexpr lambda expressions
As a quick hack you can overwrite prebuilt binaries with those you've compiled. Or take a look at <LLVMInstallDir>/tools/msbuild directory, it contains bat scripts to install LLVM toolchain. You can alter and run them to add another toolchain that would use SVN versions.
You can use the Clang Power Tools extension to add any custom LLVM versions directly from Visual Studio. It comes with the latest LLVM version support(now its LLVM 11) and you can install any version you want from the extension settings panel.
To do that open CPT Settings -> select the LLVM Tab -> choose the version you want to install and press the install button. Now the setup is complete, no other configuration is needed.
This feature is better described in this blog post.
PS: I'm one of the developers of this extension and the project is open source.
I need to build KLEE on my Ubuntu 12.04. I followed KLEE website's instructions step by step. I had LLVM 2.9 built. But when I need to install klee-uclibc, and in the process of configuring, it complained that it failed to find a working LLVM bitcode compiler. Does this mean that my LLVM built was unsuccessful? I am new to Linux and new to the testing tool. Any help is greatly appreciated.
I ran into the same problem, but a closer look in klee document helped me fix it. Especially look at step (02)(01):
Install llvm-gcc:
Download and install the LLVM 2.9 release of llvm-gcc from here. On an x86-64 Linux platform you are going to need the archive LLVM-GCC 4.2 Front End Binaries for Linux x86-64.
Add llvm-gcc to your PATH. It is important to do this first so that llvm-gcc is found in subsequent configure steps. llvm-gcc will be used later to compile programs that KLEE can execute. Forgetting to add llvm-gcc to your PATH at this point is by far the most common source of build errors reported by new users.
Hence, make sure that llvm-gcc is installed and a PATH is provided to the executable.
I heavily use the c++0x/c++11 features in my project, particularly code blocks and shared pointers. When I upgraded my OS to 10.8 Mountain Lion (Edit: From 10.7), I was forced to upgrade Xcode. In upgrading Xcode, I lost the ability to compile my c++ project for deployment on 10.6 systems as I get the following error.
clang: error: invalid deployment target for -stdlib=libc++ (requires Mac OS X 10.7 or later)
It appears that Apple is trying to force people to upgrade by not allowing developers to support Snow Leopard. This makes me angry. Arrrggg!!!
What can I do?
EDIT: After several comments back and forth, it should be made clear that 10.6 does not ship with system libc++ libraries. As a result, simply being able to build a libc++ project for 10.6 deployment is not enough. You would also need to include libc++ binaries with your 10.6 distribution or statically link to them. So lets continue with the premise that I am already doing that.
UPDATE 1: This question was originally intended for use with Xcode 4.5.2 (the latest version at the time the question was asked). I have since upgraded to Xcode 4.6.3 and have updated the question and answer to reflect that.
UPDATE 2: I've since upgraded to Xcode 5.0.2. The technique listed in the selected answer below still works as expected.
UPDATE 3: I've since upgraded to Xcode 5.1. The technique listed in the answer below does not yet work for this version!
UPDATE 4: I've since upgraded to Xcode 6.0.1. The technique listed in the selected answer below appears to be working again.
UPDATE 5: I've since upgraded to Xcode 7.1.1. The technique listed in the selected answer below appears to be working again, with one important caveat. You must disable Bitcoding used for AppThinning since the opensource LLVM version doesn't support it (nor should it). So you will need to switch between the open source and Apple LLVM clang in order to compile for both 10.6 and tvOS/watchOS (since Bitcoding is required for those OSes).
Apple has decided to only officially support libc++ on 10.7 or higher. So the version of clang/llvm that ships with Xcode checks to see if the deployment target is set for 10.6 when using libc++, and prevents you from compiling. However, this flag is not included in the open source version of clang/llvm.
Take a look at this thread:
http://permalink.gmane.org/gmane.comp.compilers.clang.devel/17557
So, to compile a project that is using c++11 for 10.6 deployment, you need to give Xcode the open source version. Here is one way of doing it:
Download the open source version of clang from here (use LLVM 3.1 for Xcode 4.5.x; use LLVM 3.2 for Xcode 4.6.x; use LLVM 3.3 for Xcode 5.0.x; use LLVM 3.5.0 for XCode 6.0.1; use LLVM 3.7.0 for XCode 7.1.1):
http://llvm.org/releases/download.html
Make a backup of Xcode's default clang compiler and put it in a safe place (In case you screw up!)
This is located at:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
Replace the default clang compiler with the one you downloaded from [1]
chown the clang binary for root:wheel with sudo chown root:wheel clang from the bin directory listed in [2].
Startup Xcode and compile!
UPDATE #1: This technique does not currently work for Xcode 5.1 or newer, which relies on LLVM 3.4. When I get some more time, I will try and find a solution to post here. But if someone comes up with a solution before me, they should post it as an answer.
UPDATE #2: Unfortunately I can't remember if I ever found a solution for Xcode 5.1, however I can confirm that the technique does still work for Xcode 6.0.1. I haven't tested on versions newer than that, but it could still work.
UPDATE #3: This technique appears to still work with XCode 7.1.1 using LLVM 3.7.0. However, the open source LLVM clang does not support Bitcoding. So you will need to switch between the open source compiler and Apple's compiler in order to develop for both 10.6 and tvOS/watchOS (which require Bitcoding).
P.S.: The Mac OS X binaries for LLVM 3.4 and 3.5.0 are listed as "Clang for Darwin 10.9" at www.llvm.org/releases/download.html rather than as "Clang Binaries for Mac OS X" in previous versions.
While Xcode 4.5.x is the current default version on OS X 10.8, you can have other, older versions of Xcode, such as Xcode 3.2.6 for OS X 10.6, available on 10.8 as long as you have access to their installers. You will need to ensure you install each one to a unique directory. Also, one thing you can't or shouldn't do is to install the Command Line Tools component or installer package of older Xcodes onto your 10.8 system, i.e. not into /usr or /System/Library. You can use the xcodebuild, xcode-select, and xcrun command line tools to access non-default Xcode components. See their man pages for more info. Older versions of Xcode are available to registered users of developer.apple.com
UPDATE: Based on your subsequent comments, I believe I did miss the point of the question and also that you had answered your own question. I think what you are saying is that you upgraded from 10.7 to 10.8, not from 10.6 to 10.8 as I assumed. You also did not make clear in the original question that you were distributing your own version of Apple's libc++ and friends from 10.7 with your own app. Apple does not make it easy in Xcode to do something like that since it has long been Apple's policy to discourage static linking with libs or distributing duplicate libs (which in some cases could violate license terms). There are good reasons for that policy.
The bottom line is that libc++ is only shipped with OS X 10.7 or later systems. There never was Apple support for libc++ in 10.6, so it's misleading to say it was removed. If you want to supply an app that is deployable on 10.6 and later systems and depends on libc++, the safest approach is to build your own clang/llvm and libc++ targeted for OS X 10.6 and use that to build your project. There are various ways to do that, probably the easiest is to use the MacPorts versions and set the deployment target in MacPorts for 10.6. Or build it all from scratch yourself. But modifying the clang compiler within Xcode 4.5 is a bad idea. And copying Apple libraries to one's app is generally a bad idea.
If you have a solution that works for you, great. But I would not recommend it to others.