1
General / Compiling on msvc with Clang with MSVC2015 codegen (v140_clang_c2 toolset)
« on: March 23, 2017, 06:10:59 am »
Apologies if this isn't the right place for this!
But I'm encountering weird behavior with cmake project generation with MSVC when I'm using Clang codegen. I suspect I may be rolling into the "currently unsupported" territory here, but I wanted to give it a shot to see cross compiling could be possible.
Generating a project with "v140_clang_c2" toolset it seems to not find some bundled libraries:
I found setting CMAKE_LIBRARY_PATH manually seems to workaround this:
But I seem to encounter a compilation failure after shortly trying to build said generated project:
Errors seem to indicate that its because the toolset isn't happy with a <windows.h> include:
https://connect.microsoft.com/VisualStudio/feedback/details/3005617/clang-platform-toolset-unable-to-compile-any-project-that-includes-windows-h
So seems like a long shot, but has anyone else got this working?
But I'm encountering weird behavior with cmake project generation with MSVC when I'm using Clang codegen. I suspect I may be rolling into the "currently unsupported" territory here, but I wanted to give it a shot to see cross compiling could be possible.
Generating a project with "v140_clang_c2" toolset it seems to not find some bundled libraries:
Code: [Select]
$ cmake -G"Visual Studio 14 2015" -T"v140_clang_c2" "C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-repo"
-- The C compiler identification is Clang 3.8.0
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/ClangC2/bin/x86/clang.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/ClangC2/bin/x86/clang.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/ClangC2/bin/x86/clang.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/ClangC2/bin/x86/clang.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
-- Found OpenGL: opengl32
CMake Error at C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find JPEG (missing: JPEG_LIBRARY)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.7/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.7/Modules/FindJPEG.cmake:32 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
src/SFML/Graphics/CMakeLists.txt:125 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/tehph/Proj/Build/CMakeFiles/CMakeOutput.log".
I found setting CMAKE_LIBRARY_PATH manually seems to workaround this:
Code: [Select]
$ CMAKE_LIBRARY_PATH="C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/extlibs/libs-msvc-universal/x86/" cmake -G"Visual Studio 14 2015" -T"v140_clang_c2" "C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-repo"
PATH IS: C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/extlibs/headers;C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/extlibs/headers/jpeg;C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/extlibs/headers/freetype2
LIBPATH IS:
-- Found JPEG: C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/extlibs/libs-msvc-universal/x86/jpeg.lib
-- Found OpenAL: C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/extlibs/libs-msvc-universal/x86/openal32.lib
-- Found VORBIS: C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/extlibs/libs-msvc-universal/x86/vorbis.lib
-- Found FLAC: C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/extlibs/libs-msvc-universal/x86/flac.lib
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/tehph/Proj/Build
But I seem to encounter a compilation failure after shortly trying to build said generated project:
Code: [Select]
1>------ Build started: Project: ZERO_CHECK, Configuration: Debug Win32 ------
1> Checking Build System
1> CMake does not need to re-run because C:/Users/tehph/Proj/Build/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/tehph/Proj/Build/src/SFML/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/tehph/Proj/Build/src/SFML/System/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/tehph/Proj/Build/src/SFML/Main/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/tehph/Proj/Build/src/SFML/Window/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/tehph/Proj/Build/src/SFML/Network/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/tehph/Proj/Build/src/SFML/Graphics/CMakeFiles/generate.stamp is up-to-date.
1> CMake does not need to re-run because C:/Users/tehph/Proj/Build/src/SFML/Audio/CMakeFiles/generate.stamp is up-to-date.
2>------ Build started: Project: sfml-system, Configuration: Debug Win32 ------
3>------ Build started: Project: sfml-main, Configuration: Debug Win32 ------
2> Building Custom Rule C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/src/SFML/System/CMakeLists.txt
2> CMake does not need to re-run because C:\Users\tehph\Proj\Build\src\SFML\System\CMakeFiles\generate.stamp is up-to-date.
2> Clock.cpp
2> Err.cpp
3> Building Custom Rule C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/src/SFML/Main/CMakeLists.txt
3> CMake does not need to re-run because C:\Users\tehph\Proj\Build\src\SFML\Main\CMakeFiles\generate.stamp is up-to-date.
3> MainWin32.cpp
3> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML\Main\MainWin32.cpp:42:
3> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\windows.h:210:
3> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\ole2.h:32:
3> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\objbase.h:27:
3>C:\Program Files (x86)\Windows Kits\8.1\Include\um\combaseapi.h(229,21): error : unknown type name 'IUnknown'
3> static_cast<IUnknown*>(*pp); // make sure everyone derives from IUnknown
3> ^
3> 1 error generated.
2> Lock.cpp
2> Mutex.cpp
2> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML\System\Mutex.cpp:31:
2> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML/System/Win32/MutexImpl.hpp:32:
2> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\windows.h:210:
2> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\ole2.h:32:
2> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\objbase.h:27:
2>C:\Program Files (x86)\Windows Kits\8.1\Include\um\combaseapi.h(229,21): error : unknown type name 'IUnknown'
2> static_cast<IUnknown*>(*pp); // make sure everyone derives from IUnknown
2> ^
2> 1 error generated.
4>------ Build started: Project: sfml-window, Configuration: Debug Win32 ------
5>------ Build started: Project: sfml-audio, Configuration: Debug Win32 ------
6>------ Build started: Project: sfml-network, Configuration: Debug Win32 ------
4> Building Custom Rule C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/src/SFML/Window/CMakeLists.txt
5> Building Custom Rule C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/src/SFML/Audio/CMakeLists.txt
4> CMake does not need to re-run because C:\Users\tehph\Proj\Build\src\SFML\Window\CMakeFiles\generate.stamp is up-to-date.
5> CMake does not need to re-run because C:\Users\tehph\Proj\Build\src\SFML\Audio\CMakeFiles\generate.stamp is up-to-date.
5> ALCheck.cpp
4> Context.cpp
4> GlContext.cpp
6> Building Custom Rule C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/src/SFML/Network/CMakeLists.txt
6> CMake does not need to re-run because C:\Users\tehph\Proj\Build\src\SFML\Network\CMakeFiles\generate.stamp is up-to-date.
6> Ftp.cpp
5> AlResource.cpp
4> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML\Window\GlContext.cpp:34:
4> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\include\SFML/OpenGL.hpp:43:
4> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\windows.h:210:
4> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\ole2.h:32:
4> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\objbase.h:27:
4>C:\Program Files (x86)\Windows Kits\8.1\Include\um\combaseapi.h(229,21): error : unknown type name 'IUnknown'
4> static_cast<IUnknown*>(*pp); // make sure everyone derives from IUnknown
4> ^
4> 1 error generated.
7>------ Build started: Project: sfml-graphics, Configuration: Debug Win32 ------
6> Http.cpp
7> Building Custom Rule C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/src/SFML/Graphics/CMakeLists.txt
7> CMake does not need to re-run because C:\Users\tehph\Proj\Build\src\SFML\Graphics\CMakeFiles\generate.stamp is up-to-date.
7> BlendMode.cpp
7> Color.cpp
5> AudioDevice.cpp
7> Font.cpp
5> Listener.cpp
6> IpAddress.cpp
5> Music.cpp
6> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML\Network\IpAddress.cpp:30:
6> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML/Network/SocketImpl.hpp:33:
6> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML/Network/Win32/SocketImpl.hpp:40:
6> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\winsock2.h:53:
6> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\windows.h:210:
6> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\ole2.h:32:
6> In file included from C:\Program Files (x86)\Windows Kits\8.1\Include\um\objbase.h:27:
6>C:\Program Files (x86)\Windows Kits\8.1\Include\um\combaseapi.h(229,21): error : unknown type name 'IUnknown'
6> static_cast<IUnknown*>(*pp); // make sure everyone derives from IUnknown
6> ^
6>C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML\Network\IpAddress.cpp(92,12): warning : 'inet_ntoa' is deprecated: Use inet_ntop() or InetNtop() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings [-Wdeprecated-declarations]
6> return inet_ntoa(address);
6> ^
6> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winsock2.h(1868,1) : note: 'inet_ntoa' has been explicitly marked deprecated here
6> inet_ntoa(
6> ^
6>C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML\Network\IpAddress.cpp(184,21): warning : 'inet_addr' is deprecated: Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings [-Wdeprecated-declarations]
6> Uint32 ip = inet_addr(address.c_str());
6> ^
6> C:\Program Files (x86)\Windows Kits\8.1\Include\um\winsock2.h(1850,1) : note: 'inet_addr' has been explicitly marked deprecated here
6> inet_addr(
6> ^
6> 2 warnings and 1 error generated.
7> Glsl.cpp
5> Sound.cpp
7> GLCheck.cpp
5> SoundBuffer.cpp
7> GLExtensions.cpp
5> SoundBufferRecorder.cpp
7> Image.cpp
5> InputSoundFile.cpp
7> ImageLoader.cpp
5> OutputSoundFile.cpp
7> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML\Graphics\ImageLoader.cpp:34:
7>C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\extlibs\headers\stb_image\stb_image_write.h(180,8): warning : 'fopen' is deprecated: This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
7> f = fopen(filename, "wb");
7> ^
7> C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205,24) : note: 'fopen' has been explicitly marked deprecated here
7> _ACRTIMP FILE* __cdecl fopen(
7> ^
7> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML\Graphics\ImageLoader.cpp:34:
7>C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\extlibs\headers\stb_image\stb_image_write.h(300,14): warning : unused variable 'runstart' [-Wunused-variable]
7> int runstart = 0, head = 0, rlerun = 0;
7> ^
7>C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\extlibs\headers\stb_image\stb_image_write.h(300,28): warning : unused variable 'head' [-Wunused-variable]
7> int runstart = 0, head = 0, rlerun = 0;
7> ^
7>C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\extlibs\headers\stb_image\stb_image_write.h(300,38): warning : unused variable 'rlerun' [-Wunused-variable]
7> int runstart = 0, head = 0, rlerun = 0;
7> ^
7>C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\extlibs\headers\stb_image\stb_image_write.h(343,8): warning : 'fopen' is deprecated: This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
7> f = fopen(filename, "wb");
7> ^
7> C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205,24) : note: 'fopen' has been explicitly marked deprecated here
7> _ACRTIMP FILE* __cdecl fopen(
7> ^
7> In file included from C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML\Graphics\ImageLoader.cpp:34:
7>C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\extlibs\headers\stb_image\stb_image_write.h(671,8): warning : 'fopen' is deprecated: This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
7> f = fopen(filename, "wb");
7> ^
7> C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205,24) : note: 'fopen' has been explicitly marked deprecated here
7> _ACRTIMP FILE* __cdecl fopen(
7> ^
7>C:\Users\tehph\OneDrive\Projects\github\GameEngine\extinclude\SFML-Repo\src\SFML\Graphics\ImageLoader.cpp(285,18): warning : 'fopen' is deprecated: This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations]
7> FILE* file = fopen(filename.c_str(), "wb");
7> ^
7> C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\stdio.h(205,24) : note: 'fopen' has been explicitly marked deprecated here
7> _ACRTIMP FILE* __cdecl fopen(
7> ^
7>C:\Users\tehph\Proj\Build\src\SFML\Graphics\ImageLoader.cpp : fatal error C1001: An internal error has occurred in the compiler.
7> (compiler file 'c:\agent\build\cache\git\vctools\vctools\compiler\utc\src\p2\main.c', line 249)
7> To work around this problem, try simplifying or changing the program near the locations listed above.
7> Please choose the Technical Support command on the Visual C++
7> Help menu, or open the Technical Support help file for more information
7> clang!DllGetC2Telemetry()+0x1d5138
7> clang!DllGetC2Telemetry()+0x1d5138
7> clang!LLVM_IR_InvokeCompilerPassW()+0xccb7
7> clang!LLVM_IR_InvokeCompilerPassW()+0xce65
7> clang!LLVM_IR_InvokeCompilerPassW()+0xd61d
7> clang!LLVM_IR_InvokeCompilerPassW()+0x16578
7> clang!LLVM_IR_InvokeCompilerPassW()+0x14f24
7> clang!LLVM_IR_InvokeCompilerPassW()+0xce9a
7> clang!LLVM_IR_InvokeCompilerPassW()+0xdf36
7> clang!LLVM_IR_InvokeCompilerPassW()+0xe17b
7> clang!DllGetC2Telemetry()+0xf880e
7> clang!DllGetC2Telemetry()+0xf6592
7> clang!DllGetC2Telemetry()+0x10399c
7> clang!DllGetC2Telemetry()+0x1d2281
7> clang!DllGetC2Telemetry()+0x1d221b
7> clang!o__CIpow()+0x4f
7>
7> INTERNAL COMPILER ERROR in 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ClangC2\bin\x86\clang.exe'
7> Please choose the Technical Support command on the Visual C++
7> Help menu, or open the Technical Support help file for more information
5> SoundRecorder.cpp
5> SoundSource.cpp
5> SoundStream.cpp
5> SoundFileFactory.cpp
5> SoundFileReaderFlac.cpp
5> SoundFileReaderOgg.cpp
5> SoundFileReaderWav.cpp
5> SoundFileWriterFlac.cpp
5> SoundFileWriterOgg.cpp
5> SoundFileWriterWav.cpp
5>LINK : fatal error LNK1104: cannot open file '..\..\..\lib\Debug\sfml-system-d.lib'
8>------ Build started: Project: ALL_BUILD, Configuration: Debug Win32 ------
8> Building Custom Rule C:/Users/tehph/OneDrive/Projects/github/GameEngine/extinclude/SFML-Repo/CMakeLists.txt
8> CMake does not need to re-run because C:\Users\tehph\Proj\Build\CMakeFiles\generate.stamp is up-to-date.
9>------ Skipped Build: Project: INSTALL, Configuration: Debug Win32 ------
9>Project not selected to build for this solution configuration
========== Build: 2 succeeded, 6 failed, 0 up-to-date, 1 skipped ==========
Errors seem to indicate that its because the toolset isn't happy with a <windows.h> include:
https://connect.microsoft.com/VisualStudio/feedback/details/3005617/clang-platform-toolset-unable-to-compile-any-project-that-includes-windows-h
So seems like a long shot, but has anyone else got this working?