dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.17k stars 4.72k forks source link

C4242 error when compiling CoreCLR on Windows with -msbuild #100207

Closed AustinWise closed 6 months ago

AustinWise commented 7 months ago

Description

Compiling with the -msbuild flag fails with many C4242 errors in libunwind.

Reproduction Steps

On commit 4e0d5d4bb45ecd9a74f651a0682b8d5371c9695b

build.cmd -s clr -c debug -msbuild

Expected behavior

Compiles successfully. Note that that compiling with Ninja works fine:

build.cmd -s clr -c debug -ninja

Actual behavior

Many errors like this:

src\native\external\libunwind\include\libunwind_i.h(342,13): error C4242: '=': conversion from 'ssize_t' to 'int', possible loss of data [artifacts\obj\external\libunwind\libunwind_xdac.vcxproj] (compiling source file 'src/native/external/libunwind/src/os-linux.c')

Regression?

Presumably this has something to do with #99470.

Known Workarounds

No response

Configuration

Other information

It looks like the intention was to not enable this warning for libunwind:

https://github.com/dotnet/runtime/blob/6c685e3302ebdc2aeb008a40ff475d3d3b9f2a78/src/native/external/libunwind_extras/CMakeLists.txt#L143

One thing I notice is that eng\native\configurecompiler.cmake turns this warning on guarded by if (MSVC) while src/native/external/libunwind_extras/CMakeLists.txt tries to turn this off guarded by if(CLR_CMAKE_HOST_WIN32). I'm not enough of an expert on CMake to know if this is a problem or not.

dotnet-policy-service[bot] commented 7 months ago

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries See info in area-owners.md if you want to be subscribed.

filipnavara commented 7 months ago

I can reproduce. I have a branch that fixes enough of the C4242 warnings to pass through this. Generally the work is tracked in #99471.