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

Cannot build clr after installing latest VS nightly #41886

Closed
GrabYourPitchforks opened this issue Sep 4, 2020 · 12 comments · Fixed by #41900
Closed

Cannot build clr after installing latest VS nightly #41886

GrabYourPitchforks opened this issue Sep 4, 2020 · 12 comments · Fixed by #41900

Comments

@GrabYourPitchforks
Copy link
Member

GrabYourPitchforks commented Sep 4, 2020

Just updated to VS 2019 Int Preview 16.8.0 Preview 3.0 [30504.10.main], and builds are failing on my local box. Repros in both the master and the release/5.0-rc2 branches.

Error appears even after running git clean -xdf.

> build.cmd -s clr -c Release
... snip ...
    20>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winbase.h(9461,5): warning C5105: macro expansion producing 'defined' has undefined behavior (compiling source file C:\runtime\artifacts\obj\coreclr\Windows_NT.x64.Release\src\inc\idls_out\cordebug_i.c) [C:\runtime\artifacts\obj\coreclr\Windows_NT.x64.Release\src\inc\corguids_obj.vcxproj]
    20>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um\winbase.h(9461,5): error C2220: the following warning is treated as an error (compiling source file C:\runtime\artifacts\obj\coreclr\Windows_NT.x64.Release\src\inc\idls_out\cordebug_i.c) [C:\runtime\artifacts\obj\coreclr\Windows_NT.x64.Release\src\inc\corguids_obj.vcxproj]

More info on the warning: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5105

@ghost
Copy link

ghost commented Sep 4, 2020

Tagging subscribers to this area: @ViktorHofer
See info in area-owners.md if you want to be subscribed.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Sep 4, 2020
@ViktorHofer
Copy link
Member

cc @trylek @jkoritzinsky @josalem

@ViktorHofer ViktorHofer added area-Infrastructure-coreclr and removed area-Infrastructure untriaged New issue has not been triaged by the area owner labels Sep 4, 2020
@ViktorHofer ViktorHofer added this to the 6.0.0 milestone Sep 4, 2020
@GrabYourPitchforks GrabYourPitchforks changed the title Cannot build clr after latest VS nightly Cannot build clr after installing latest VS nightly Sep 4, 2020
@josalem
Copy link
Contributor

josalem commented Sep 4, 2020

For reference the file that generates that .h/.c pair hasn't been changed since the end of July: https://github.com/dotnet/runtime/blob/master/src/coreclr/src/inc/cordebug.idl

Interesting that this didn't happen before this VS update. Based on this snippet from the docs:

Microsoft-specific behavior: The MSVC compiler evaluates the defined operator normally, even under /permissive-.

This warning is new in Visual Studio 2017 version 15.8. It's only generated by the new standards-compliant preprocessor, specified by the /experimental:preprocessor compiler option.

I'm wondering if the default preprocessor warnings changed?

Looking at the checked in .cpp versions I didn't see anything that looked like the docs example, but I haven't looked at the generated .h/.c files on Windows.

CC @hoyosjs @mikem8361 have you run across this issue before when changing this file?

@GrabYourPitchforks
Copy link
Member Author

I confirmed that appending add_compile_options(/wd5105) to the following locations fixes the build on my machine.

# Disable Warnings:
# 4291: Delete not defined for new, c++ exception may cause leak.
add_compile_options(/wd4291)

add_compile_options(/wd4960 /wd4961 /wd4603 /wd4627 /wd4838 /wd4456 /wd4457 /wd4458 /wd4459 /wd4091 /we4640)

See also internal tracking items https://devdiv.visualstudio.com/DevDiv/_workitems/edit/966470 and https://microsoft.visualstudio.com/OS/_workitems/edit/23240387 for further context.

@hoyosjs
Copy link
Member

hoyosjs commented Sep 4, 2020

The CPP checked in version is just the windows C version renamed. So this is a toolset change indeed, and there's a few places where the new preprocessor will hit this - anything that touches a header like winbase.h or minwindef.h

@GrabYourPitchforks
Copy link
Member Author

GrabYourPitchforks commented Sep 5, 2020

Possible root cause is that the intermediate project file corguids_obj.vcxproj contains the following line:

<AdditionalOptions>%(AdditionalOptions) /Zm200 /Zc:strictStrings /w34092 /w34121 /w34125 /w34130 /w34132 /w34212 /w34530 /w35038 /w44177 /ZH:SHA_256 /source-charset:utf-8 -std:c11</AdditionalOptions>

Note the "-std:c11" at the end. I don't know why this intermediate project file is getting this extra option set. None of the other .vcxproj files seem to contain this setting. Per the MSVC team, this setting implies \Zc:preprocessor, which explains the warning.

Will need to hand the investigation off to somebody else, as I think I've gone as far as I can go with my current skill set. :)

@GrabYourPitchforks
Copy link
Member Author

Keeping this open to track reacting to any suggestions from MSVC / Windows SDK team.

@sebastienros
Copy link
Member

This seems to be fixed on master, but I have the same issue on release/5.0

@kkokosa
Copy link
Contributor

kkokosa commented Jan 19, 2021

What's the current status of this issue? Or in the other words - how we can compile 5.0 version on Windows? On a fresh release/5.0 branch with 10.0.18362.0 SDK & VS 2019 16.8.4 it is still the same:

C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winbase.h(9305,5): warning C5105: macro expansion producing 'defined' has undefined behavior (compiling source file F:\Github\dotnet\original\runtime\artifacts\obj\coreclr\Windows_NT.x64.Debug\src\inc\idls_out\cordebug_i.c) 
...
C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um\winbase.h(9305,5): error 
C2220: the following warning is treated as an error (compiling source file F:\Github\dotnet\original\runtime\artifacts\obj\coreclr\Windows_NT.x64.Debug\src\inc\idls_out\cordebug_i.c) 
...

Update: Just manually using PR #41900 helps, maybe it could be just merged to the release/5.0 as now it is really confusing :)

@jashook
Copy link
Contributor

jashook commented Jan 28, 2021

I can confirm that this issue also exists in release/3.1 and @GrabYourPitchforks change fixes the errors. /cc @trylek

@jashook
Copy link
Contributor

jashook commented Feb 10, 2021

3.1 port -> dotnet/coreclr#28142

@ViktorHofer
Copy link
Member

Closing as this should now be fixed in all branches that we care about.

Infrastructure Backlog automation moved this from 6.0.0 to Done May 5, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants