dotnet / runtime

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

Method to Find Compiler Definition Mismatch between Native and Managed (MSCORLIB) #5752

Closed myungjoo closed 4 years ago

myungjoo commented 8 years ago

Compiler definitions for native parts (c++) are managed by CMake scripts. Compiler definitions for managed parts (C# / mscorlib.dll) are supposed to be consistent with those for native parts while they are managed independently by other scripts. (xml/props files)

This recently has introduced inconsistency between the two parts of CoreCLR, which was only discovered by an application running on CoreCLR. In general test cases or example application, the inconsistency was not observed because their execution paths did not hit it.

Although we have assertions that let us know when we hit the point that such inconsistency becomes critical; however, such an inconsistency is supposed to be detected statically at build time.

I have just started writing scripts to support such static check. (the hurdle is that I'm not familiar with cmake or c# building tools :) )

Anyway,

myungjoo commented 8 years ago

With the WIP scripts, checkdefinitions.pl, ARM/Linux build shows the following inconsistency between the two builds (native vs managed):

  File: 62, String: 46
  Both has ARM
  --- Managed Omitted BUILDENV_CHECKED=1
  +++ Managed Added CODE_ANALYSIS_BASELINE
  +++ Managed Added DBG
  --- Managed Omitted DBG_TARGET_32BIT=1
  --- Managed Omitted DBG_TARGET_ARM=1
  --- Managed Omitted DBG_TARGET_ARM_UNIX
  Both has DEBUG
  --- Managed Omitted DEBUGGING_SUPPORTED
  --- Managed Omitted DISABLE_CONTRACTS
  Both has FEATURE_APPDOMAIN_RESOURCE_MONITORING
  Both has FEATURE_ARRAYSTUB_AS_IL
  +++ Managed Added FEATURE_ASCII
  --- Managed Omitted FEATURE_ASYNC_IO
  Both has FEATURE_BCL_FORMATTING
  Both has FEATURE_COLLECTIBLE_TYPES
  Both has FEATURE_CORECLR
  Both has FEATURE_COREFX_GLOBALIZATION
  Both has FEATURE_CORESYSTEM
  Both has FEATURE_CORRUPTING_EXCEPTIONS
  --- Managed Omitted FEATURE_DBGIPC_TRANSPORT_DI
  --- Managed Omitted FEATURE_DBGIPC_TRANSPORT_VM
  +++ Managed Added FEATURE_ENCODINGNLS
  +++ Managed Added FEATURE_EVENTSOURCE_XPLAT
  --- Managed Omitted FEATURE_EVENTSOURCE_XPLAT=1
  Both has FEATURE_EXCEPTIONDISPATCHINFO
  Both has FEATURE_HOSTED_BINDER
  Both has FEATURE_HOST_ASSEMBLY_RESOLVER
  --- Managed Omitted FEATURE_ICASTABLE
  --- Managed Omitted FEATURE_IMPLICIT_TLS
  --- Managed Omitted FEATURE_ISYM_READER
  +++ Managed Added FEATURE_LATIN1
  Both has FEATURE_LOADER_OPTIMIZATION
  Both has FEATURE_MAIN_CLR_MODULE_USES_CORE_NAME
  --- Managed Omitted FEATURE_MANAGED_ETW
  Both has FEATURE_MANAGED_ETW_CHANNELS
  --- Managed Omitted FEATURE_MERGE_CULTURE_SUPPORT_AND_ENGINE
  --- Managed Omitted FEATURE_MERGE_JIT_AND_ENGINE
  --- Managed Omitted FEATURE_MULTICOREJIT
  Both has FEATURE_NORM_IDNA_ONLY
  Both has FEATURE_PAL
  --- Managed Omitted FEATURE_PAL_ANSI
  --- Managed Omitted FEATURE_PAL_SXS
  --- Managed Omitted FEATURE_PERFMAP
  --- Managed Omitted FEATURE_PREJIT
  Both has FEATURE_RANDOMIZED_STRING_HASHING
  Both has FEATURE_READYTORUN
  --- Managed Omitted FEATURE_STANDALONE_SN
  --- Managed Omitted FEATURE_STRONGNAME_DELAY_SIGNING_ALLOWED
  Both has FEATURE_STRONGNAME_MIGRATION
  +++ Managed Added FEATURE_STUBS_AS_IL
  --- Managed Omitted FEATURE_SVR_GC
  Both has FEATURE_SYMDIFF
  Both has FEATURE_SYNTHETIC_CULTURES
  Both has FEATURE_USE_ASM_GC_WRITE_BARRIERS
  +++ Managed Added FEATURE_UTF32
  +++ Managed Added FEATURE_UTF7
  Both has FEATURE_VERSIONING
  --- Managed Omitted FEATURE_WIN32_REGISTRY
  Both has FEATURE_WINDOWSPHONE
  Both has FEATURE_WINMD_RESILIENT
  +++ Managed Added INSIDE_CLR
  --- Managed Omitted LINUX32
  +++ Managed Added PLATFORM_UNIX
  --- Managed Omitted PLATFORM_UNIX=1
  Both has PROFILING_SUPPORTED
  +++ Managed Added RESOURCE_SATELLITE_CONFIG
  +++ Managed Added SIGNED
  +++ Managed Added TRACE
  --- Managed Omitted UNIX_ARM_ABI
  --- Managed Omitted URTBLDENV_FRIENDLY=Checked
  +++ Managed Added WIN32
  --- Managed Omitted _ARM_
  --- Managed Omitted _BLD_CLR
  --- Managed Omitted _DBG
  Both has _DEBUG
  +++ Managed Added _LOGGING
  --- Managed Omitted _TARGET_ARM_=1
  +++ Managed Added _USE_NLS_PLUS_TABLE

Could someone enlighten me on which are OK and which are alarming?

For now, for Managed Omitted words, I assume that it is OK if /src/mscorlib$ grep -r "OMITTED_WORD" shows nothing. For Managed Added words, I assume that it is OK if /src$ grep -r "ADDED_WORD" shows nothing except from /src/mscorlib directory.

myungjoo commented 8 years ago

So far, potentially dangerous inconsistencies are:

FEATURE_MANAGED_ETW: omitted but used in mscorlib C# code. FEATURE_MULTICOREJIT: omitted but used in mscorlib C# code. FEATURE_WIN32_REGISTRY: why in the hell do we have this defined in ARM/Linux native build?

(I didn't check "added" words, yet)