Building V8 with Clang/LLVM - v8

I am building V8 from sources on Windows following this instruction.
It works but uses MSVS C++ compiler and I need to switch compilation to Clang/LLVM. It is installed on the machine but I have no idea how to specify it during the build.
I see is_clang flag in args.gn but it seems it is true by default.
Any ideas?
From toolchain.ninja file
rule cxx
command = ..\..\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe /c ${in} /Fo${out} /nologo /showIncludes:user "-imsvc../../../../Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/include" "-imsvc../../../../Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.34.31933/ATLMFC/include" "-imsvc../../../../Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/VS/include" "-imsvc../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/ucrt" "-imsvc../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/um" "-imsvc../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/shared" "-imsvc../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/winrt" "-imsvc../../../../Program Files (x86)/Windows Kits/10/include/10.0.20348.0/cppwinrt" "-imsvc../../../../Program Files (x86)/Windows Kits/NETFXSDK/4.8/include/um" ${defines} ${include_dirs} ${cflags} ${cflags_cc} /Fd"${target_out_dir}/${label_name}_cc.pdb"
description = CXX ${out}
deps = msvc

command = ..\..\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe
That means it's using Clang to compile. That's its own bundled Clang, so it doesn't need you to manually install Clang on your system.

Related

CMake uses too long paths when searching for CUDA compiler on Windows

I am running CMake from under CLion and when identifying CUDA compiler, it apperently uses too long paths, and fails (according to CMakeError.log file):
Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.2/bin/nvcc.exe
Build flags:
Id flags: --keep;--keep-dir;tmp -v
The output was:
1
D:\TESTS\CUDA_CLion\test01\cmake-build-debug\CMakeFiles\3.19.1\CompilerIdCUDA>call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat"
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.8.2
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
The input line is too long.
The syntax of the command is incorrect.
#$ C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/HostX64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'
...
The command it runs is (according to CMake pane of CLion):
D:\Apps\CMake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug --debug-output -G "CodeBlocks - NMake Makefiles" D:\TESTS\CUDA_CLion\test01
If I run this command from CLI, it also fails, but with different error:
Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed.
Compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v10.2/bin/nvcc.exe
Build flags:
Id flags: --keep;--keep-dir;tmp -v
The output was:
1
nvcc fatal : Cannot find compiler 'cl.exe' in PATH
And finally, if I just run
cmake ..
from CLI it works: it finds itself Ok with long paths, it finds cl.exe, everything.
The question is: how to fix everything OR how to force CLion just to use only CMake without imagination?
Did your script invoke vcvarsall.bat or vcvars64.bat multiple times?
It could be solved by reduce them

Integrating PVS-Studio and CMake

I use Windows 10, QtCreator 4.7.1, CMake 3.11.4 (Ninja, CodeBlocks), MSVC 2017. Try to integrate PVS-Studio to CMake project.
cmake_minimum_required(VERSION 3.10)
project(tst CXX)
add_executable(${PROJECT_NAME} main.cpp)
include(PVS-Studio.cmake)
pvs_studio_add_target(
TARGET ${PROJECT_NAME}.analyze ALL
OUTPUT FORMAT errorfile
ANALYZE ${PROJECT_NAME}
BIN "C:/Program Files (x86)/PVS-Studio/x64/PVS-Studio.exe")
I get error
[3/6 4.2/sec] Generating PVS-Studio.cfg
[4/6 5.1/sec] Analyzing CXX file main.cpp
FAILED: PVS-Studio/main.cpp.plog
cmd.exe /C "cd /D D:\work\v2.0\ui_tools\build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430 && "C:\Program Files\CMake\bin\cmake.exe" -E make_directory D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio && "C:\Program Files\CMake\bin\cmake.exe" -E remove_directory D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio/main.cpp.plog && "C:\Program Files\CMake\bin\cmake.exe" -D PVS_STUDIO_AS_SCRIPT=TRUE -D "PVS_STUDIO_COMMAND=C:/Program Files (x86)/PVS-Studio/x64/PVS-Studio.exe;analyze;--output-file;D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio/main.cpp.plog;--source-file;D:/work/v2.0/ui_tools/tst/main.cpp;--dep-file;D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio/main.cpp.plog.d;--dep-file-target;PVS-Studio/main.cpp.plog;--cfg;D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio.cfg;--platform;x64;--preprocessor;visualcpp;--cxx;C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/HostX86/x64/cl.exe;--cc;C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/HostX86/x64/cl.exe;--cl-params;;;-DPVS_STUDIO;D:/work/v2.0/ui_tools/tst/main.cpp" -P D:/work/v2.0/ui_tools/tst/PVS-Studio.cmake"
CMake Error at D:/work/v2.0/ui_tools/tst/PVS-Studio.cmake:46 (message):
Incorrect parameter syntax: An unknown parameter is present in the command
line: dep-file.
Any idea what to do?
In your CMake integration code, the 'BIN' parameter should point to the 'CompilerCommandsAnalyzer.exe' tool (under Windows) instead of the 'PVS-Studio.exe' C++ analyzer core.
However, PVS-Studio CMake module support for Windows will become available in PVS-Studio 6.26, which is expected to be released in a couple of days. The current 6.25 release is missing this tool.
Please check whether you have the 'CompilerCommandsAnalyzer.exe' inside your PVS-Studio installation folder ('c:\Program Files (x86)\PVS-Studio\' by default). If you do not have it, please write us at support#viva64.com, so we can give you a pre-release version to try. Or you can just wait for a 6.26 release which will become available quite soon.

Building 64bit Live555 with Visual Studio 2013

I am trying to build the components of Live555 with Visual Studio 2013 64bit on Windows 7.
I have tried editing win32config and the *.mak files without success. I've been searching the internet for a few hours and trying all kinds of things with command prompts.
For some reason VS2013 x64 command prompt is still building 32bit static libs and I can't figure out why.
If anyone has any good ideas, that would be fantastic!
The win32config file that you get from the .tar.gz file requires substantial editing to make it compatible with recent SDK and MSVC++ releases. This is a version that produced a clean build:
NODEBUG=1
TARGETOS = WINNT
UI_OPTS = $(guilflags) $(guilibsdll)
CONSOLE_UI_OPTS = $(conlflags) $(conlibsdll)
CPU=amd64
COMPILE_OPTS = $(INCLUDES) $(cdebug) $(cflags) $(cvarsdll) -I. /EHsc /O2 /MD /GS /D "WIN64" /Oy- /Oi /D "NDEBUG"
C = c
C_COMPILER = cl
C_FLAGS = $(COMPILE_OPTS)
CPP = cpp
CPLUSPLUS_COMPILER = $(C_COMPILER)
CPLUSPLUS_FLAGS = $(COMPILE_OPTS)
OBJ = obj
LINK = link -out:
LIBRARY_LINK = lib -out:
LINK_OPTS_0 = $(linkdebug) ws2_32.lib /NXCOMPAT
LIBRARY_LINK_OPTS =
LINK_OPTS = $(LINK_OPTS_0) $(UI_OPTS)
CONSOLE_LINK_OPTS = $(LINK_OPTS_0) $(CONSOLE_UI_OPTS)
SERVICE_LINK_OPTS = kernel32.lib advapi32.lib shell32.lib ws2_32.lib -subsystem:console,$(APPVER)
LIB_SUFFIX = lib
LIBS_FOR_CONSOLE_APPLICATION =
LIBS_FOR_GUI_APPLICATION =
MULTIMEDIA_LIBS = winmm.lib
EXE = .exe
PLATFORM = Windows
rc32 = rc.exe
.rc.res:
$(rc32) $<
After you've edited this file, run the genWindowsMakefiles command from bash (or the CMD file). Next, start the x64 Visual Studio Command Prompt. Make sure you got the x64 native configuration flavor of it. Issue the following commands:
cd c:\projects\live\liveMedia
nmake -f liveMedia.mak
cd ..\groupsock
nmake -f groupsock.mak
cd ..\UsageEnvironment
nmake -f UsageEnvironment.mak
cd ..\BasicUsageEnvironment
nmake -f BasicUsageEnvironment.mak
cd ..\testProgs
nmake -f testProgs.mak
cd ..\mediaServer
nmake -f mediaServer.mak
Alter the first command to match the directory where you put the source.
TODO items: cleaning doesn't work, it tries to use the *nix rf command. Simplest workaround is del *.obj to force the compiler to rebuild the object files
the .exe files are built without a manifest. Shouldn't matter for the test programs, I assume you're only interested in the .lib files
it builds the release version of the libraries and executables, you'll have to tweak the COMPILE_OPTS to get a debug build.
In order to compile 64 bit native code with Visual Studio 2013, you
require professional edition.
Open the VS2013 x64 Native Tools Command Prompt
Then make sure you set C_COMPILER to "$(TOOLS32)\bin\amd64\cl" after correcting TOOLS32 to the VC/bin dir.
In order to compile 64 bit native code with Visual Studio 2013, you require professional edition.
Open the VS2013 x64 Native Tools Command Prompt
Then make sure you set C_COMPILER to "$(TOOLS32)\bin\amd64\cl" after correcting TOOLS32 to the VC/bin dir.

What is the "Visual Studio configuration file", why is nvcc looking for it, why can't it find it, how to fix?

I am trying to compile CUDA code from the command line using CUDA toolkit version 5.0 and the Visual Studio 2010 Professional compiler. In response to the following,
nvcc -c AddVectors.cu -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin"
I get the following error message
nvcc : fatal error : Visual Studio configuration file '(null)' could not be found for installation at 'C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC/bin/../..'
I also get this error message when Rebuilding within the VS 2010 IDE, but not when I just plain Build.
I am by no means a Visual Studio expert, but what is curious about the error message for me is that nvcc seems to exit the compiler directory I have specified and search upward from there VC/bin/../..
Why is it doing this? Why does it need anything other than the compiler executable in VC/bin/ and what is the role of the "Visual Studio configuration file" in all of this?
And, last but not least, how do I resolve this?
EDIT: My environment and search path are
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\mjacobson\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=WAA04087-RD
ComSpec=C:\Windows\system32\cmd.exe
CUDA_BIN_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin
CUDA_INC_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include
CUDA_LIB_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\lib\x64
CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\
CUDA_PATH_V4_2=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\
CUDA_PATH_V5_0=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\
C_IA64_REDIST11=C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\mjacobson
LOCALAPPDATA=C:\Users\mjacobson\AppData\Local
LOGONSERVER=\\SVRAABKP01
NUMBER_OF_PROCESSORS=12
NVCUDASAMPLES5_0_ROOT=C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\
NVCUDASAMPLES_ROOT=C:\ProgramData\NVIDIA Corporation\CUDA Samples\v5.0\
NVTOOLSEXT_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\nvToolsExt\
OS=Windows_NT
Path=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\libnvvp\;C:\Program Files (x
86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Common Files\Intel\Shared Files\cpp\bin\ia64;C:\Program Files\AccelerEyes\Jacket\engine\bin
64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\ATI Technologies\ATI.ACE
\Core-Static;C:\Program Files (x86)\NTRU Cryptosystems\NTRU TCG Software Stack\bin\;C:\Program Files\NTRU Cryptosystems\NTRU TCG Software Stack\bin\;C
:\Program Files\Wave Systems Corp\Gemalto\Access Client\v5\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Common
Files\Roxio Shared\10.0\DLLShared\;C:\Program Files\MATLAB\R2013b\runtime\win64;C:\Program Files\MATLAB\R2013b\bin;C:\Program Files\MATLAB\R2012b\runt
ime\win64;C:\Program Files\MATLAB\R2012b\bin;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files (x86)\Common Files\Xoran Technol
ogies;C:\Program Files\MATLAB\MATLAB Compiler Runtime\v81\runtime\win64;C:\Program Files\MATLAB\R2011b\runtime\win64;C:\Program Files\MATLAB\R2011b\bi
n;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Ser
ver\100\DTS\Binn\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 44 Stepping 2, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=2c02
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
RoxioCentral=C:\Program Files (x86)\Common Files\Roxio Shared\10.0\Roxio Central36\
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\MJACOB~1\AppData\Local\Temp
TMP=C:\Users\MJACOB~1\AppData\Local\Temp
USERNAME=mjacobson
USERPROFILE=C:\Users\mjacobson
VS100COMNTOOLS=c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\
windir=C:\Windows
CUDA nvcc is just a steering compilation driver, that means nvcc uses both MSVC compiler and the CUDA compiler to perform his actions.
In a Windows environment you need to pay attention to several things before starting the compilation, make sure to review all of these:
Make sure you have enough privileges to run/write compilation chain programs into your paths. If you're admin on a home personal computer, in order to debug your problem, make sure to run all of the below commands and programs with administrative privileges (if that solves the issue, it was it!)
Environment variables are used to set the appropriate compiler and toolkit paths besides drivers locations. Assuming a clean and fully functional installation of both CUDA 5.0 toolkit and MSVC2010 Pro, in order to compile your 64-bit CUDA code with the x64 version of MSVC2010 the best way to set everything up properly is to run the Visual Studio x64 Command Prompt. You can find this into the start menu Visual Studio 2010/Tools/Visual Studio x64 Command Prompt (I suppose also a cross-platform x64 could work for this). Remember to run it with administrative privileges (Amministratore == Administrator in my birth-language in the screen below)
Notice in the above screenshot the "Setting environment.." line: that makes sure all of the appropriate environment variables relative to the x64 version of the MSVC compiler. From the log you posted nvcc should be immediately found and be able to detect the compiler you're supplying to it.
Programs which frown upon executables calling other executables whose work files are inside administrative-righted folders might need to be dealt with: in simple terms anti-viruses defenders (e.g. Comodo) and active protections filters may prevent nvcc and the tools it uses from getting their work done, make sure to disable these if you encounter warnings / problems while debugging your issue.
Just to be clear about something else: VC/bin is the x86 version of the MSVC compiler, VC/x64 is the one you're interested in (also often referred as amd64), VC/ia64 is for the IA64 architecture (a proper 64 bit architecture, x64 systems are just x86 systems "rendered" 64 bit.. they weren't born 64 bit).
When compiling your project from the MSVC IDE make sure of the admin privileges, no active protection programs on and that you're either properly matching the x64 project type with the CUDA C/C++ architecture targeted
Make sure there are no mismatches in both the project properties and single .cu files properties. Make sure that (with a verbose output active) there's no -m32 flag when compiling stuff in a 64 bit project (or at least if you know what you're doing).

Qt VS Add-In - link external libraries

I want to include external libraries to my visual c++ Qt-add in project. Since my Qt project manager doesn't work I create a simple 'template' project with Qt-creator, and import the .pro file to Visual Studio via the add-in. I've added the commonly used libraries to the pro file in the creator, and with that I can build well, but in Visual Studio building gives me a linker error:
Error 2 error LNK1104: cannot open file 'OpenCL.lib' D:\Qt\Qt5.2.0\Tools\QtCreator\bin\qtpnds\LINK
The full .pro file I tried to import:
#-------------------------------------------------
#
# Project created by QtCreator 2013-12-28T17:27:01
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qtpnds
TEMPLATE = app
SOURCES += main.cpp\
mainwindowpnd.cpp
HEADERS += mainwindowpnd.h
FORMS += mainwindowpnd.ui
unix|win32: LIBS += -L$$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/ -lOpenCL
INCLUDEPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
DEPENDPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
unix|win32: LIBS += -L$$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/ -lFreeImage
INCLUDEPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
DEPENDPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
unix|win32: LIBS += -L$$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/ -lglew32
INCLUDEPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
DEPENDPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
unix|win32: LIBS += -L$$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/ -lglut32
INCLUDEPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
DEPENDPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
In creator I can use the library, it works well.
Using:
Qt 5.2.0 MSVC 2012 /w OpenGL.. OS: Windows 7 Ultimate SP1, x64.. Add-in version: Qt-VS-Add-In 1.2.2.. VS: Visual Studio 2012 Ultimate.
Is there any way to link libs in visual studio? #pragma comments and linking via project properties don't work, and I can't/don't know how to edit the .pro file in vs, without having to reimport it everytime I modify it.
I DID look for solutions, but I've only found posts about Qt-creator.
For those who might say use Qt-creator instead of addons, I won't.
Edit:
My opencl Lib is located in the C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/ folder, and its name is OpenCL.lib. (C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/OpenCL.lib is the full path). The same for the other libraries. The files and libraries work in Qt-creator!
The libraries added to the addittional dependencies too.
OpenCL.lib
FreeImage.lib
...
Without the Qt Add-in the files link well, but after transforming a project to Qt, they cannot be opened. I tried also creating a new .pro file with the add-in.
Edit2:
After removing the libs from the additional dependencies, I get unresolved externals for all OpenCL functions. Changing the pro file library paths to:
-L"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib" -lOpenCL \
-L"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib" -lFreeImage
does't work too.
You will need to add all the necessary Qt libraries along with their path explicitly if the conversion does not take care of that, which is the case, I am afraid. You will also need to add the opencl library along with its path.
Make sure you do not mix the debug and release builds becaues that can go haywire in the Microsoft environment.
Here you can see the two dialog where you can basically assign these additional dependencies and libraries to the default.

Resources