Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with clang-cl due to override of CMAKE_CXX_COMPILER(?) #2384

Closed
emmenlau opened this issue Sep 4, 2020 · 7 comments
Closed

Build fails with clang-cl due to override of CMAKE_CXX_COMPILER(?) #2384

emmenlau opened this issue Sep 4, 2020 · 7 comments

Comments

@emmenlau
Copy link

emmenlau commented Sep 4, 2020

I'm trying to build json 3.9.1 with clang-cl 10.0.0 (from Visual Studio 2019 current latest) on MSVC. The build fails for me already in the cmake configure stage. I could track the problem down to a line in cmake/download_test_data.cmake that overrides the detected compiler:

set(CXX_VERSION_RESULT "${CXX_VERSION_RESULT}; MSVC_VERSION=${MSVC_VERSION}; MSVC_TOOLSET_VERSION=${MSVC_TOOLSET_VERSION}")

I'm under the impression that the semicolon surrounding ... MSVC_VERSION=${MSVC_VERSION}; ... is interpreted by clang-cl as an end-of-line. There are related reports on the internet that would indicate this being the problem.

Here is the output from cmake:

-- The CXX compiler identification is Clang 10.0.0 with MSVC-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using the multi-header code from C:/gitlabci/local/builds/XTJyb_7r/0/json/include/
-- Found Git: C:/cygwin64/bin/git.exe (found version "2.21.0") 
-- Operating system: Windows-10.0.19041; CYGWIN_NT-10.0 Aidan02 3.1.4(0.340/5/3) 2020-02-19 08:49 x86_64 Cygwin
-- Compiler: clang-cl: error: no input files
-- Configuring done
-- Generating done

Here are a few examples of the failling build:

-- Build files have been written to: C:/data/stable-tmp-MSVC-Haswell-7-x64-cl19.27.29111_clang10.0.0/Debug/json
[1/99] "clang-cl: error: no input files; MSVC_VERSION=1927; MSVC_TOOLSET_VERSION=142"   -TP  -IC:\gitlabci\local\builds\XTJyb_7r\0\json\test\thirdparty\doctest /MDd /Zi /arch:AVX2 /DDEBUG /DWINVER=_WIN32_WINNT_WIN7 /D_WIN32_WINNT=_WIN32_WINNT_WIN7 /D_ITERATOR_DEBUG_LEVEL=0 /D_CRT_SECURE_NO_DEPRECATE /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS    /DWIN32 /D_WINDOWS /W4 /GR /EHsc /wd4566 /wd4996 /MDd /Zi /Ob0 /Od /RTC1 /bigobj /showIncludes /Fotest\CMakeFiles\doctest_main.dir\src\unit.cpp.obj /Fdtest\CMakeFiles\doctest_main.dir\ -c C:\gitlabci\local\builds\XTJyb_7r\0\json\test\src\unit.cpp
FAILED: test/CMakeFiles/doctest_main.dir/src/unit.cpp.obj 
"clang-cl: error: no input files; MSVC_VERSION=1927; MSVC_TOOLSET_VERSION=142"   -TP  -IC:\gitlabci\local\builds\XTJyb_7r\0\json\test\thirdparty\doctest /MDd /Zi /arch:AVX2 /DDEBUG /DWINVER=_WIN32_WINNT_WIN7 /D_WIN32_WINNT=_WIN32_WINNT_WIN7 /D_ITERATOR_DEBUG_LEVEL=0 /D_CRT_SECURE_NO_DEPRECATE /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS    /DWIN32 /D_WINDOWS /W4 /GR /EHsc /wd4566 /wd4996 /MDd /Zi /Ob0 /Od /RTC1 /bigobj /showIncludes /Fotest\CMakeFiles\doctest_main.dir\src\unit.cpp.obj /Fdtest\CMakeFiles\doctest_main.dir\ -c C:\gitlabci\local\builds\XTJyb_7r\0\json\test\src\unit.cpp
CreateProcess failed: The system cannot find the file specified.

I'm a bit puzzled what the override of CXX_VERSION_RESULT is used for. When I remove this line everything seems to work fine... is there a good reason to enforce an override?

@stale
Copy link

stale bot commented Oct 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Oct 4, 2020
@emmenlau
Copy link
Author

emmenlau commented Oct 5, 2020

Help would be greatly appreciated...

@stale stale bot removed the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Oct 5, 2020
@tan-wei
Copy link

tan-wei commented Oct 22, 2020

I've met the same issue here with Clang-11.

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Dec 25, 2020
@nlohmann nlohmann removed the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Dec 30, 2020
@nlohmann
Copy link
Owner

Maybe related: #2343

@nlohmann
Copy link
Owner

Thanks for reporting, and sorry for the late response.

As written in #2343 (comment), the goal of CXX_VERSION_RESULT is to have as much detail on the compiler as possible. I played around a bit with the variables provided by CMake, but every now and then missed a detail.

I am confused why setting variable CXX_VERSION_RESULT influences calling clang-cl. Unfortunately, I cannot reproduce the issue in the CI - https://github.com/nlohmann/json/runs/1625144503?check_suite_focus=true#step:3:1 runs without problems:

cmake -S . -B build -G "Visual Studio 16 2019" -A x64 -T ClangCL -DJSON_BuildTests=On
-- The CXX compiler identification is Clang 10.0.0 with MSVC-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/Llvm/x64/bin/clang-cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Using the single-header code from D:/a/json/json/single_include/
-- Found Git: C:/Program Files/Git/bin/git.exe (found version "2.29.2.windows.3") 
-- Operating system: Windows-10.0.17763; MSYS_NT-10.0-17763 fv-az68-689 3.1.7-340.x86_64 2020-10-23 13:08 UTC x86_64 Msys
-- Compiler: clang-cl: error: no input files; MSVC_VERSION=1928; MSVC_TOOLSET_VERSION=142
-- Configuring done
-- Generating done
-- Build files have been written to: D:/a/json/json/build

Can you please re-try with the latest develop versions to make sure the issue still persists?

@nlohmann nlohmann added the platform: visual studio related to MSVC label Dec 30, 2020
@emmenlau
Copy link
Author

emmenlau commented Jan 9, 2021

Dear @nlohmann thanks for the kind help! Indeed its like you say, the problem comes up only with v3.9.1 (current latest release), but not with the latest develop version! I have no problem using develop, so that resolves the issue for me! Thanks!

@emmenlau emmenlau closed this as completed Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants