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

Windows build - warning treated as error, causing the build to fail #2884

Closed
DillonHeinenIntel opened this issue Nov 4, 2024 · 5 comments
Closed

Comments

@DillonHeinenIntel
Copy link

I'm building with the following commands in a batch script:

git clone https://github.com/DMTF/libspdm.git libspdm
cd libspdm
git submodule update --init
git submodule update
mkdir build
cd build
cmake -G"NMake Makefiles" -DARCH=x64 -DTOOLCHAIN=VS2022 -DTARGET=Debug -DCRYPTO=openssl ..
nmake copy_sample_key
nmake

...
[ 53%] Building C object library/spdm_requester_lib/CMakeFiles/spdm_requester_lib.dir/libspdm_req_encap_request.c.obj
libspdm_req_encap_request.c
E:\dheinen\libspdm\library\spdm_requester_lib\libspdm_req_encap_request.c(23): error C2220: warning treated as error - no 'object' file generated
E:\dheinen\libspdm\library\spdm_requester_lib\libspdm_req_encap_request.c(23): warning C4054: 'type cast': from function pointer 'const libspdm_get_encap_response_func' to data pointer 'void *'
E:\dheinen\libspdm\library\spdm_requester_lib\libspdm_req_encap_request.c(96): warning C4055: 'type cast': from data pointer 'void *' to function pointer 'libspdm_get_encap_response_func'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\CMake\bin\cmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.

I've tried passing --compile-no-warning-as-error to the cmake command, but this doesn't fix the issue. Is there a best known method for turning off this warning -> error behavior? My apologies if I missed something in the documentation.

@steven-bellock
Copy link
Contributor

I don't see this on my system. What does cl /? produce? I've got

Microsoft (R) C/C++ Optimizing Compiler Version 19.41.34123 for x64

@DillonHeinenIntel
Copy link
Author

DillonHeinenIntel commented Nov 5, 2024

I don't see this on my system. What does cl /? produce?

This is my cl output:

Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64

@steven-bellock
Copy link
Contributor

That's VS 2015. What happens if you use -DTOOLCHAIN=VS2015? I would imagine the same thing, so we may need to disable that warning on VS2015, or maybe fix the code.

For another issue, in CI/CD we only test with VS2019. It should at least be 2022. I'll file a separate issue for that.

@DillonHeinenIntel
Copy link
Author

DillonHeinenIntel commented Nov 5, 2024

I went ahead and updated to using VS 2022. Now the build gets to 97%, but I'm seeing what looks like a separate issue. Is it possible this is a path/filename length problem? (please see https://stackoverflow.com/questions/34074925/vs-2015-cannot-open-compiler-generated-file-invalid-argument):

[ 97%] Building C object unit_test/fuzzing/test_requester/test_spdm_requester_get_measurement_extension_log/CMakeFiles/test_spdm_requester_get_measurement_extension_log.dir///spdm_unit_fuzzing_common/common.c.obj
common.c
C:\Users\dheinen\OneDrive\Documents\libspdm\unit_test\fuzzing\spdm_unit_fuzzing_common\common.c : fatal error C1083: Cannot open compiler generated file: '': Invalid argument
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\test_spdm_requester_get_measurement_extension_log.dir__\spdm_unit_fuzzing_common\common.c.obj.d --working-dir="C:\Users\dheinen\OneDrive - Intel Corporation\Documents\libspdm\build\unit_test\fuzzing\test_requester\test_spdm_requester_get_measurement_extension_log" --filter-prefix="Note: including file: " -- C:\PROGRA1\MIB0551\2022\COMMUN1\VC\Tools\MSVC\14411.341\bin\Hostx64\x64\cl.exe @C:\Users\dheinen\AppData\Local\Temp\nm9689.tmp' : return code '0x1'
Stop.

@DillonHeinenIntel
Copy link
Author

I went ahead and updated to using VS 2022. Now the build gets to 97%, but I'm seeing what looks like a separate issue. Is it possible this is a path/filename length problem? (please see https://stackoverflow.com/questions/34074925/vs-2015-cannot-open-compiler-generated-file-invalid-argument):

[ 97%] Building C object unit_test/fuzzing/test_requester/test_spdm_requester_get_measurement_extension_log/CMakeFiles/test_spdm_requester_get_measurement_extension_log.dir///spdm_unit_fuzzing_common/common.c.obj common.c C:\Users\dheinen\OneDrive\Documents\libspdm\unit_test\fuzzing\spdm_unit_fuzzing_common\common.c : fatal error C1083: Cannot open compiler generated file: '': Invalid argument NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E cmake_cl_compile_depends --dep-file=CMakeFiles\test_spdm_requester_get_measurement_extension_log.dir____\spdm_unit_fuzzing_common\common.c.obj.d --working-dir="C:\Users\dheinen\OneDrive - Intel Corporation\Documents\libspdm\build\unit_test\fuzzing\test_requester\test_spdm_requester_get_measurement_extension_log" --filter-prefix="Note: including file: " -- C:\PROGRA1\MIB0551\2022\COMMUN1\VC\Tools\MSVC\14411.341\bin\Hostx64\x64\cl.exe @C:\Users\dheinen\AppData\Local\Temp\nm9689.tmp' : return code '0x1' Stop.

Reducing the number of levels in my directory hierarchy fixed this. I'll close this issue. Thanks for your help with the earlier issue, Steven; I really appreciate your responsiveness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants