Closed QuellaZhang closed 3 years ago
Yes, this is a known issue and we have a current work item on our backlog to support newer versions of CMAKE.
Hey @QuellaZhang can you try building on CMake 3.20? I'm getting a successful build with the update version.
@danewalton thanks for the tips, I tried to build latest source 642ba0af4851e2db7c8afd670e94c202106802ae on cmake 3.20.1 and got the same error. Have you tried x86 bit? this is an x86 only issue. If so, it would be strange.
I have this reproduced and am looking into it.
Hi @QuellaZhang
It looks like this is a change of behavior of CMake which changes how the /TP
flag does or does not get appended.
https://discourse.cmake.org/t/compiling-c-as-c-in-cmake-3-18/2172/2
I'll quote one of the engineers from Kitware here:
The regression, issue, and fix Ben mentioned were all in the 3.19 series.
To answer the original question, don’t try to use /TP directly. You need to tell CMake that you want the file treated as C++ by setting the LANGUAGE source file property to CXX. There is also ongoing work to make that work in more cases.
Meanwhile, I suggest creating a pthread.cxx that just has #include "pthread.c", and list pthread.cxx as the source instead.
More relevant to what is happening here is the CompileAs
option is missing in 3.19 and above but not in 3.17 or below.
3.15:
3.20:
There's another issue here. It looks like the fix for us would have to be to create new .cpp
files which just #include
the whole .c
files as is as the Kitware engineers suggested.
Hi @QuellaZhang can you try the fix I have here? I have tried it on CMake version 3.20 and it looks to be compiling alright for me with the -A Win32
option.
@danewalton .Thanks for the fix. I pulled your branch and tested it on x86 with the -A Win32
, no error! It's a clean build. But I found new error when testing on x64 with -A x64
. The error as below:
build_x86_passed.log build_x64_failed.log
F:\gitP\azure\azure-iot-sdk-c\iothub_client\tests\iothubtr_amqp_tel_msgr_ut\iothubtr_amqp_tel_msgr_ut.c : fatal error C1128: <func:#0, Mod:F:\gitP\azure\azure-iot-sdk-c\iothub_client\tests\iothubtr_amqp_tel_msgr_ut\iothubtr_amqp_tel_msgr_ut.c> number of sections exceeded object file format limit: compile with /bigobj [F:\gitP\azure\azure-iot-sdk-c\build_x64\iothub_client\tests\iothubtr_amqp_tel_msgr_ut\iothubtr_amqp_tel_msgr_ut_exe.vcxproj]
I've pushed an update with the flags to enable the bigobj
it's asking for if you could try that out.
I wasn't using the x86 native tools command prompt before so just built with
cmake -Drun_unittests=ON -A x64 ..
and it looks to be working with the latest changes.
@danewalton Thanks for your efforts, now the build of x86 and x64 are all clean.:)
@danewalton Thanks for your efforts, now the build of x86 and x64 are all clean.:)
Thanks for the time and helping us fix this! We'll get it in shortly.
Hi All,
After we upgrading cmake to 3.19.6, azure-iot-sdk-c x86 failed to build on MSVC. Verified that we can get a clean build when the cmake version is lower than 3.19.4.
I compare the build command line, and found "CPP_UNITTEST" "USE_CTEST" "/TP" "/TC" does not seem to match correctly. This may be related to CMake Policy CMP0077(cmake --help-policy CMP0077).
Build steps:
Build log: build_cmake_v3.17.0-passed.log build_cmake_v3.19.6-failed.log
Error message: F:\gitP\azure\azure-iot-sdk-c\build_x86>cmake --version cmake version 3.17.0 F:\gitP\azure\azure-iot-sdk-c\build_x86>CL.exe /c /I"F:\gitP\azure\azure-iot-sdk-c\deps\azure-macro-utils-c\inc" /I"F:\gitP\azure\azure-iot-sdk-c\deps\umock-c\inc" /I"F:\gitP\azure\azure-iot-sdk-c\c-utility\inc" /I"F:\gitP\azure\azure-iot-sdk-c\c-utility\pal\windows" /I"F:\gitP\azure\azure-iot-sdk-c\serializer..\deps\parson" /I"F:\gitP\azure\azure-iot-sdk-c\serializer\inc" /I"F:\gitP\azure\azure-iot-sdk-c\iothub_client\inc" /I"F:\gitP\azure\azure-iot-sdk-c\c-utility\testtools\micromock\inc" /I"F:\gitP\azure\azure-iot-sdk-c\deps\azure-c-testrunnerswitcher\inc" /I"F:\gitP\azure\azure-iot-sdk-c\deps\azure-ctest\inc" /I"F:\gitP\azure\azure-iot-sdk-c\c-utility\src" /I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\UnitTest\include" /nologo /W4 /WX /diagnostics:column /O2 /Ob2 /Oy- /D CPPUNITTEST_SYMBOL=some_symbol_for_cppunittest_1 /D WIN32 /D _WINDOWS /D NDEBUG /D CPP_UNITTEST /D _CRT_SECURE_NO_WARNINGS /D ARCHITECTURE_x86=1 /D GB_MEASURE_MEMORY_FOR_THIS /D GB_DEBUG_ALLOC /D "CMAKE_INTDIR=\"Release\"" /D _MBCS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"serializer_dt_ut_testsonly_lib.dir\Release\" /Fd"serializer_dt_ut_testsonly_lib.dir\Release\serializer_dt_ut_testsonly_lib.pdb" /Gd /TP /wd4232 /analyze- /errorReport:queue "F:\gitP\azure\azure-iot-sdk-c\serializer\tests\serializer_dt_ut\serializer_dt_ut.c" -I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\VS\UnitTest\include" serializer_dt_ut.c F:\gitP\azure\azure-iot-sdk-c\build_x86>
F:\gitP\azure\azure-iot-sdk-c\build_x86>cmake --version cmake version 3.19.6 F:\gitP\azure\azure-iot-sdk-c\build_x86>CL.exe /c /I"F:\gitP\azure\azure-iot-sdk-c\deps\azure-macro-utils-c\inc" /I"F:\gitP\azure\azure-iot-sdk-c\deps\umock-c\inc" /I"F:\gitP\azure\azure-iot-sdk-c\c-utility\inc" /I"F:\gitP\azure\azure-iot-sdk-c\c-utility\pal\windows" /I"F:\gitP\azure\azure-iot-sdk-c\serializer..\deps\parson" /I"F:\gitP\azure\azure-iot-sdk-c\serializer\inc" /I"F:\gitP\azure\azure-iot-sdk-c\iothub_client\inc" /I"F:\gitP\azure\azure-iot-sdk-c\c-utility\testtools\micromock\inc" /I"F:\gitP\azure\azure-iot-sdk-c\deps\azure-c-testrunnerswitcher\inc" /I"F:\gitP\azure\azure-iot-sdk-c\deps\azure-ctest\inc" /I"F:\gitP\azure\azure-iot-sdk-c\c-utility\src" /I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\UnitTest\include" /nologo /W4 /WX /diagnostics:column /O2 /Ob2 /Oy- /D CPPUNITTEST_SYMBOL=some_symbol_for_cppunittest_1 /D WIN32 /D _WINDOWS /D NDEBUG /D CPP_UNITTEST /D _CRT_SECURE_NO_WARNINGS /D ARCHITECTURE_x86=1 /D GB_MEASURE_MEMORY_FOR_THIS /D GB_DEBUG_ALLOC /D "CMAKE_INTDIR=\"Release\"" /D _MBCS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"serializer_dt_ut_testsonly_lib.dir\Release\" /Fd"serializer_dt_ut_testsonly_lib.dir\Release\serializer_dt_ut_testsonly_lib.pdb" /Gd /TC /wd4232 /analyze- /errorReport:queue "F:\gitP\azure\azure-iot-sdk-c\serializer\tests\serializer_dt_ut\serializer_dt_ut.c" -I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\VS\UnitTest\include" serializer_dt_ut.c C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\cstdlib(23,62): error C2061: syntax error: identifier 'noexcept' C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\cstdlib(23,62): error C2059: syntax error: ';' C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\cstdlib(23,90): error C2449: found '{' at file scope (missing function header?) C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\cstdlib(25,1): error C2059: syntax error: '}' C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\cstdlib(31,72): error C2061: syntax error: identifier 'noexcept' C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\cstdlib(31,72): error C2059: syntax error: ';'