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

[mono] Reenable C4244 MSVC warning and fix occurrences #91395

Merged
merged 8 commits into from
Sep 5, 2023

Conversation

akoeplinger
Copy link
Member

@akoeplinger akoeplinger commented Aug 31, 2023

Fixes #91249

We originally fixed the warnings with #69236 but due to add_compile_options() calls in zlib.cmake all of the mono native libs - not just the zlib components - were being built with C4244 disabled and a few couple more leaked in.

This fixes the occurrences and reworks the .cmake files a bit to hopefully prevent this in the future.

src/mono/mono/mini/aot-runtime.c Outdated Show resolved Hide resolved
src/mono/mono/eventpipe/ep-rt-mono-runtime-provider.c Outdated Show resolved Hide resolved
src/mono/mono/eventpipe/ep-rt-mono-runtime-provider.c Outdated Show resolved Hide resolved
src/mono/mono/metadata/icall.c Outdated Show resolved Hide resolved
src/mono/mono/mini/graph.c Outdated Show resolved Hide resolved
src/mono/mono/mini/helpers.c Outdated Show resolved Hide resolved
src/mono/mono/mini/interp/transform.c Outdated Show resolved Hide resolved
src/mono/mono/mini/interp/transform.c Outdated Show resolved Hide resolved
src/mono/mono/mini/interp/transform.c Outdated Show resolved Hide resolved
src/mono/mono/mini/interp/transform.c Outdated Show resolved Hide resolved
Copy link
Member

@fanyang-mono fanyang-mono left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, the change looks good to me.

Copy link
Member

@lateralusX lateralusX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, great work. Mainly a couple of additional places to use different conversion macros or opportunity to add a new more precise conversion macro.

The only thing to look out for is the mword SGenDescriptor related changes, mword is based on host size while SGenDescriptor is based on target size, so changing the type we will need to make sure that it doesn't introduce changed behavior or potentially loss of precision in case you have different host/target pointer sizes.

src/mono/mono/metadata/sgen-client-mono.h Show resolved Hide resolved
src/mono/mono/metadata/sgen-mono.c Show resolved Hide resolved
src/mono/mono/mini/aot-compiler.c Outdated Show resolved Hide resolved
src/mono/mono/mini/aot-compiler.c Outdated Show resolved Hide resolved
src/mono/mono/mini/aot-compiler.c Outdated Show resolved Hide resolved
src/mono/mono/mini/method-to-ir.c Outdated Show resolved Hide resolved
src/mono/mono/mini/mini-llvm.c Outdated Show resolved Hide resolved
src/mono/mono/mini/mini-x86.c Outdated Show resolved Hide resolved
@@ -14,7 +14,7 @@
* "start" will point to the start of the next object, if the scanned
* object contained references. If not, the value of "start" should
* be considered undefined after executing this code. The object's
* GC descriptor must be in the variable "mword desc".
* GC descriptor must be in the variable "SgenDescriptor desc".
Copy link
Member

@lateralusX lateralusX Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are different type depending on host/target, mword is host machine word while SgenDescriptor is target machine word, have you validated that calls only uses SgenDescriptor and we don't end up casting mword to SgenDescriptor or SgenDescriptor to mword since that can lead to data loss depending on host/target combinations or depend on size of desc in logic etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep I checked all the callsites and they are all called with SgenDescriptor type without casting.

src/mono/mono/metadata/sgen-mono.c Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mono build disables required warning C4244 under MSVC
3 participants