How to integrate LLVM 5.0 into Visual Studio 2017? - c++

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.

Related

How to compile and install LLVM 13 from source on windows 10?

I want to install LLVM 13.0.1 in my local windows (64 bit) system to use it for creating a working enviorment for open source project. I downloaded and install from here but I found it is not complete It is missing many library files and cmake files that are required and getting errors while building. so I want now to install LLVM 13.0.1 from source.
I am very early in learning LLVM , Clang so don't have any idea of doing so. Can anyone give me the entire step / commands to do so.

How to make Qt Creator use Rosetta and x86 compiler on Mac M1?

I am using Qt 5.15.2 on my Mac mini with M1 chip. This works fine (due to Rosetta). Below is the list of compilers Qt Creator found on this computer, and among them is the C++, x86 64bit that I use. No problem.
I would like to use the same settings on a (somewhat newer) Mac Book Pro (also with M1 chip). Below is the list of compilers Qt Creator finds on this computer, the x86 is now missing!
I do not know if I have a x86 compiler on the new M1-computer. I have installed Xcode and the command line tools for XCode 13.2.
Can I somewhere tell Qt Creator that the deployment target is x86?
Does /usr/bin/clang++ only compile for the ARM/M1-chip, or can it also produce and link to x86 code?
if not, how can I find out if there is an x86 compiler on my new M1-computer?
If the compiler is missing, how to install it?
Any help would be most appreciated!
A few tips that can help, I just setup a project using Qt 5.15.2 on a 2021 M1 Mac.
Note this will likely be different for Qt >= 6.
Can I somewhere tell Qt Creator that the deployment target is x86?
Yes, you can do this using specific argument in the build settings of your kit.
Add the QMAKE_APPLE_DEVICE_ARCHS="x86_64" additional argument to qmake.
Also, add an additional CMake option: -DCMAKE_OSX_ARCHITECTURES:STRING="x86_64"
ℹ️ Click Manage Kits.. in the projects view to open the preferences editor where you can update your CMake configuration.
Does /usr/bin/clang++ only compile for the ARM/M1-chip, or can it also produce and link to x86 code?
With rosetta installed (/usr/sbin/softwareupdate –install-rosetta –agree-to-license), and the configuration above, yes you can compile and link x86 binaries.

Headers for Clang from VS build tools and LLVM

I was experimenting with different compilers, build managers and IDEs for my new project in C++. I am using VSCode(v1.52) on a windows 10 machine. I installed VS build tools 2019 and also included C++ Clang Compiler for Windows and C++ Clang-cl for v142 build tools (x64/x86). The project uses CMake as build manager and a plug-in CMake tools have been installed as well. Setup works fine as it is now.
However, I just want to know what are the differences to include Clang compiler from VSCode build tools 2019 and from LLVM. Does Clang that comes with VSCode build tools uses its own headers or the headers from VS? I do not want to use if Clang uses headers from VS..!
VSCode build tools (C++ Clang tools for Windows) will link the Clang compiler with Microsoft implementation of the Standard Library
Also, VSCode build tools has a component called: "C++ Clang-cl for v142" that gives you the freedom of using your own Compiler/Settings
Regarding header files, on Windows you should use clang with either GCC (Open Source) or MSVC header files.
I could not find the exact source of the header files in VS Build tools. However, as said above, it will link the compiler with Microsoft STL.
To install Clang with GCC header files (Works on VsCode):
go to https://www.msys2.org/ and install mysys2
then open mysys2 terminal and copy those commands to install Clang:
pacman -S mingw-w64-x86_64-clang
pacman -S mingw-w64-x86_64-clang-tools-extra
dont forget to add \msys64\mingw64\bin to the SYSTEM PATH variable
I have also made a video, with step by step: https://youtu.be/5OSO8IRlyXc

Building OpenCV with Clang 5 in Windows

I'm trying to build OpenCV in Windows 7 with Clang 5.0.0 but Cmake does not recognize the option and, therefore, there is no compilation available.
The system contains Clang 5.0.0, MSVC 2013 Express and Cmake 3.10.0.
Googling the solution does not show any valid results.
There is any way to generate the OpenCV dll/lib with Clang (and LLVM) capabilites/dependencies?
If there is a workaround evading MSVC, I accept it, too.
Thanks in advance.

How to update the clang version to compile a C++11 project? (on Mac)

I'm trying to build a project which is originally written for archlinux. The building process works fine on that archlinux but has a huge amount of errors when I tried to build it on my mac. The project is basically written in C++11 so it's very unstable. I think there has something to do with the compiler because the clang version in mac is 4.2(It actually shows 'Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)' when I type clang --version) and 3.3 for linux. So I want a different version of clang, perhaps 3.3. How Can I specify the version of my compiler when trying to build the project?
Some might argue this belongs on apple.stackexchange.com, but I'm not sure C++11 tags grab a lot of attention there:)
Xcode 5.0 is now available from the App Store. Install it, go to Preferences -> Downloads, and install the Command Line Tools. However...
First, you will need to go to Preferences -> Accounts and add your Apple ID. For some reason, the Command Line Tools download requires an account login. I don't know what the rationale for this is.
> clang -v
Apple LLVM version 5.0 (clang-500.2.75) (based on LLVM 3.3svn)
If you are willing to build from the command line, using make for example (which sounds likely given the project is from Linux), then install Macports and install whatever version of clang you would like:
$sudo port install clang-3.1
$sudo clang_select
Note that this version of clang shouldn't interfere with the Xcode Command Line package if you are will to invoke the Xcode version using xcrun clang instead of plain old clang.