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

Cataclysm-DDA failed to build with "error C2011: '_CONTEXT': 'struct' type redefinition" with MSVC on Windows arm64 #62594

Closed
YangYang129 opened this issue Dec 6, 2022 · 10 comments
Labels
Code: Build Issues regarding different builds and build environments OS: Windows Issues related to Windows operating system (S1 - Need confirmation) Report waiting on confirmation of reproducibility stale Closed for lack of activity, but still valid.

Comments

@YangYang129
Copy link

YangYang129 commented Dec 6, 2022

Describe the bug

Cataclysm-DDA failed to build with "winnt.h(6097,16): error C2011: '_CONTEXT': 'struct' type redefinition (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp)" with MSVC on Windows arm64. It can reproduce on latest version on master branch. Could you please help look at this issue?

Error info:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(6097,16): error C2011: '_CONTEXT': 'struct' type redefinition (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp) [F:\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles-common.vcxproj]
	Line  108:      8>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(6177,33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp) [F:\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles-common.vcxproj]
	Line  109:      8>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(6177,26): error C2146: syntax error: missing ';' before identifier 'CONTEXT' (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp) [F:\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles-common.vcxproj]
	Line  110:      8>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(6177,33): error C2059: syntax error: ',' (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp) [F:\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles-common.vcxproj]
	Line  112:      8>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(6190,52): error C2371: 'RUNTIME_FUNCTION': redefinition; different basic types (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp) [F:\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles-common.vcxproj]
	Line  116:      8>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(6190,71): error C2371: 'PRUNTIME_FUNCTION': redefinition; different basic types (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp) [F:\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles-common.vcxproj]
	Line  118:      8>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(6195,27): error C2371: 'SCOPE_TABLE': redefinition; different basic types (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp) [F:\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles-common.vcxproj]
	Line  120:      8>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(6195,41): error C2371: 'PSCOPE_TABLE': redefinition; different basic types (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp) [F:\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles-common.vcxproj]
	Line  122:      8>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(6211,44): error C2011: '_UNWIND_HISTORY_TABLE_ENTRY': 'struct' type redefinition (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp) [F:\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles-common.vcxproj]
	Line  124:      8>C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winnt.h(6216,38): error C2011: '_UNWIND_HISTORY_TABLE': 'struct' type redefinition (compiling source file F:\Cataclysm-DDA\src\catacharset.cpp) [F:\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles-common.vcxproj]

Steps to reproduce

  1. open x64 native tools command prompt for VS 2019
  2. set VSCMD_SKIP_SENDTELEMETRY=1 & "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=arm64
  3. git clone https://github.com/CleverRaven/Cataclysm-DDA F:\Cataclysm-DDA
  4. git -C "F:\Cataclysm-DDA" apply F:\DDA_ARM64.patch --ignore-space-change --ignore-whitespace --whitespace=nowarn
  5. cd F:\Cataclysm-DDA
  6. set VCPKG_ROOT=F:/vcpkg
  7. mkdir build_arm64ec & cd build_arm64ec
  8. cmake -G "Visual Studio 16 2019" -A arm64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DCMAKE_BUILD_TYPE=Release -DCURSES=OFF -DLOCALIZE=OFF -DTILES=1 -DBUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=F:/Cataclysm-DDA/build-scripts/MSVC.cmake -DVCPKG_TARGET_TRIPLET=arm64-windows ..
  9. set PATH=C:\tools\msys64\usr\bin;%PATH%
  10. set CL=/D ARM64
  11. msbuild /m /p:Platform=arm64 /p:Configuration=Release CataclysmDDA.sln /t:Rebuild

Expected behavior

I expected build fine and does not error

Screenshots

No response

Versions and configuration

OS: Windows Server 2022 Datacenter
VS: Visual Studio 2019(16.11.21)

Additional context

Error log:

Cataclysm-DDA_arm64_build.log

patch log:

DDA_ARM64.patch.log

@YangYang129 YangYang129 added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Dec 6, 2022
@BrettDong BrettDong added Code: Build Issues regarding different builds and build environments OS: Windows Issues related to Windows operating system labels Dec 6, 2022
@BrettDong
Copy link
Member

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\arm64\CL.exe /c /I"F:\Cataclysm-DDA\build_arm64ec\vcpkg_installed\arm64-windows\include\SDL2" /I"F:\Cataclysm-DDA\build_arm64ec\vcpkg_installed\arm64-windows\include" /I"F:\Cataclysm-DDA\src\third-party" /nologo /W1 /WX- /diagnostics:column /sdl- /MP /O2 /Ob2 /Oy- **/D _ARM64_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1 /D _MBCS /D WIN32 /D _WINDOWS /D NDEBUG /D TILES /D _SCL_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_WARNINGS /D WIN32_LEAN_AND_MEAN /D LOCALIZE /D USE_VCPKG /D CMAKE /D GIT_VERSION /D RELEASE /D AMD64 /D BACKTRACE /D USE_HOME_DIR /D USE_WINMAIN /D "CMAKE_INTDIR="Release"" /GF /Gm- /EHsc /MT /GS- /Gy /fp:precise /permissive- /Zc:wchar_t /Zc:forScope /Zc:inline /std:c++14 /Yc"F:/Cataclysm-DDA/build_arm64ec/src/CMakeFiles/cataclysm-tiles-common.dir/Release/cmake_pch.hxx" /Fp"F:/Cataclysm-DDA/build_arm64ec/src/cataclysm-tiles-common.dir/Release/cmake_pch.pch" /Fo"cataclysm-tiles-common.dir\Release\" /Fd"cataclysm-tiles-common.dir\Release\cataclysm-tiles-common.pdb" /external:W1 /Gd /TP /wd4068 /wd4146 /wd4819 /wd6237 /wd6319 /wd26444 /wd26451 /wd26495 /FI"F:/Cataclysm-DDA/build_arm64ec/src/CMakeFiles/cataclysm-tiles-common.dir/Release/cmake_pch.hxx" /analyze- /FC /errorReport:queue /utf-8 /bigobj "F:\Cataclysm-DDA\build_arm64ec\src\CMakeFiles\cataclysm-tiles-common.dir\cmake_pch.cxx"

The _AMD64_ macro is defined for a ARM64 target cross-compile. It seems off to me.

@BrettDong
Copy link
Member

The fix for _AMD64_ being defined for ARM target was merged. Could you retry the latest master branch?

@YangYang129
Copy link
Author

YangYang129 commented Dec 7, 2022

@BrettDong I update to latest commit and rebuild, display two error:

         CVTRES : fatal error CVT1100: duplicate resource.  type:MANIFEST, name:1, language:0x0409 [F:\aa\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles.vcxproj]
         LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt [F:\aa\Cataclysm-DDA\build_arm64ec\src\cataclysm-tiles.vcxproj]

Error log:
DDA_rebuild_CVT1100.log

Steps to reproduce

  1. open x64 native tools command prompt for VS 2019
  2. set VSCMD_SKIP_SENDTELEMETRY=1 & "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -host_arch=amd64 -arch=arm64
  3. git clone https://github.com/CleverRaven/Cataclysm-DDA F:\aa\Cataclysm-DDA
  4. cd F:/vcpkg
  5. bootstrap-vcpkg.bat
  6. vcpkg.exe install --recurse zlib sdl2 sdl2-ttf sdl2-image --triplet arm64-windows --clean-after-build
  7. cd F:\aa\Cataclysm-DDA
  8. mkdir build_arm64ec & cd build_arm64ec
  9. cmake -G "Visual Studio 16 2019" -A arm64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DCMAKE_BUILD_TYPE=Release -DCURSES=OFF -DLOCALIZE=OFF -DTILES=1 -DBUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=F:\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=arm64-windows
  10. set PATH=C:\tools\msys64\usr\bin;%PATH%
  11. set CL=/utf-8 /permissive-
  12. msbuild /m /p:Platform=arm64 /p:Configuration=Release CataclysmDDA.sln /t:Rebuild

According to description of https://stackoverflow.com/questions/10888391/error-link-fatal-error-lnk1123-failure-during-conversion-to-coff-file-inval or https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/cvtres-fatal-error-cvt1100?view=msvc-170, run set _LINK_=/incremental:no or set _LINK_=/TLBID:20, these two errors still display

@BrettDong
Copy link
Member

I have no problem cross-compiling to ARM64 on a x64 host with Visual Studio 2022. My commands are

mkdir build_arm64
cd build_arm64
cmake -D CMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A arm64 -D LOCALIZE=OFF -D TILES=1 -D BUILD_TESTING=OFF -D CMAKE_TOOLCHAIN_FILE=../build-scripts/MSVC.cmake -D VCPKG_TARGET_TRIPLET=arm64-windows ..
msbuild /m /p:Platform=arm64 /p:Configuration=Release CataclysmDDA.sln /t:Rebuild

Microsoft Visual Studio Community 2022 (64-bit) Version 17.4.2
cl.exe Version 19.34.31935
Windows 11 22H2 22621.900 x64

@YangYang129
Copy link
Author

YangYang129 commented Dec 8, 2022

@BrettDong We need to build this project on VS2019, I run cmake -G "Visual Studio 16 2019" -A arm64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DCMAKE_BUILD_TYPE=Release -DCURSES=OFF -DLOCALIZE=OFF -DTILES=1 -DBUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=../build-scripts/MSVC.cmake -DVCPKG_TARGET_TRIPLET=arm64-windows .., failed:

 Could not find a package configuration file provided by "sdl2-ttf" with any
  of the following names:

    sdl2-ttfConfig.cmake
    sdl2-ttf-config.cmake

  Add the installation prefix of "sdl2-ttf" to CMAKE_PREFIX_PATH or set
  "sdl2-ttf_DIR" to a directory containing one of the above files.  If
  "sdl2-ttf" provides a separate development package or SDK, be sure it has
  been installed.

OS: Windows Server 2022 Datacenter
VS: Visual Studio 2019(16.11.21)

Error log:
DDA_cmake_fail.log
CMakeOutput.log
CMakeError.log

@BrettDong
Copy link
Member

Is there a reason you are unable to move to Visual Studio 2022?

@YangYang129
Copy link
Author

@BrettDong Yes, we need to build this project on VS2019 and are unable to move to VS2022 now.

@BrettDong
Copy link
Member

Now that the project compiles smoothly on Visual Studio 2022, I don't think there is fundamental incompatibility problem in our code base.

@akrieger
Copy link
Member

akrieger commented Dec 9, 2022

The official Microsoft recommendation for ARM64EC at https://devblogs.microsoft.com/cppblog/arm64ec-support-in-visual-studio/ states you need to be using 'The latest Windows Insider SDK build which is available through the Windows Insider program' at the time. That was, on August 10 2021, version 22621. Your error messages say you are using 10.0.18362.0. Please update your windows 10 sdk and see if your problems are resolved.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2023

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. Please do not bump or comment on this issue unless you are actively working on it. Stale issues, and stale issues that are closed are still considered.

@github-actions github-actions bot added the stale Closed for lack of activity, but still valid. label Jan 8, 2023
@BrettDong BrettDong closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code: Build Issues regarding different builds and build environments OS: Windows Issues related to Windows operating system (S1 - Need confirmation) Report waiting on confirmation of reproducibility stale Closed for lack of activity, but still valid.
Projects
None yet
Development

No branches or pull requests

3 participants