Skip to content

Commit 38017c3

Browse files
authored
Leftover Utf8String defines are causing ILLinker warnings (#41680)
The CreateRuntimeRootILLinkDescriptorFile task, which generates most of S.P.CoreLib's ILLink.Descriptor file for coreclr, doesn't respect #ifdefs. So even though FEATURE_UTF8STRING is disabled in the release/5.0 branch, it is still generating entries for Char8 and Utf8String. But since these managed types do not exist, the ILLinker is raising warnings. To fix this, comment the DEFINE_CLASS entries out of the header file. Fix #41654
1 parent 1186d1f commit 38017c3

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/coreclr/src/vm/corelib.h

+19-13
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,12 @@ DEFINE_CLASS(ENCODING, Text, Encoding)
318318

319319
DEFINE_CLASS(RUNE, Text, Rune)
320320

321-
#ifdef FEATURE_UTF8STRING
322-
DEFINE_CLASS(CHAR8, System, Char8)
323-
#endif // FEATURE_UTF8STRING
321+
// https://github.com/dotnet/runtime/issues/41654 - having DEFINE_CLASS (even under #ifdef) causes an entry
322+
// in System.Private.CoreLib's ILLink.Descriptor.xml which causes warnings
323+
// Use /// comments because CreateRuntimeRootILLinkDescriptorFile will still match `// DEFINE_CLASS`
324+
/// #ifdef FEATURE_UTF8STRING
325+
/// DEFINE_CLASS(CHAR8, System, Char8)
326+
/// #endif // FEATURE_UTF8STRING
324327

325328
DEFINE_CLASS(ENUM, System, Enum)
326329

@@ -849,16 +852,19 @@ DEFINE_METHOD(STRING, WCSLEN, wcslen,
849852
DEFINE_METHOD(STRING, STRLEN, strlen, SM_PtrByte_RetInt)
850853
DEFINE_PROPERTY(STRING, LENGTH, Length, Int)
851854

852-
#ifdef FEATURE_UTF8STRING
853-
DEFINE_CLASS(UTF8_STRING, System, Utf8String)
854-
DEFINE_METHOD(UTF8_STRING, CTORF_READONLYSPANOFBYTE,Ctor, IM_ReadOnlySpanOfByte_RetUtf8Str)
855-
DEFINE_METHOD(UTF8_STRING, CTORF_READONLYSPANOFCHAR,Ctor, IM_ReadOnlySpanOfChar_RetUtf8Str)
856-
DEFINE_METHOD(UTF8_STRING, CTORF_BYTEARRAY_START_LEN,Ctor, IM_ArrByte_Int_Int_RetUtf8Str)
857-
DEFINE_METHOD(UTF8_STRING, CTORF_BYTEPTR, Ctor, IM_PtrByte_RetUtf8Str)
858-
DEFINE_METHOD(UTF8_STRING, CTORF_CHARARRAY_START_LEN,Ctor, IM_ArrChar_Int_Int_RetUtf8Str)
859-
DEFINE_METHOD(UTF8_STRING, CTORF_CHARPTR, Ctor, IM_PtrChar_RetUtf8Str)
860-
DEFINE_METHOD(UTF8_STRING, CTORF_STRING, Ctor, IM_String_RetUtf8Str)
861-
#endif // FEATURE_UTF8STRING
855+
// https://github.com/dotnet/runtime/issues/41654 - having DEFINE_CLASS (even under #ifdef) causes an entry
856+
// in System.Private.CoreLib's ILLink.Descriptor.xml which causes warnings.
857+
// Use /// comments because CreateRuntimeRootILLinkDescriptorFile will still match `// DEFINE_CLASS`
858+
/// #ifdef FEATURE_UTF8STRING
859+
/// DEFINE_CLASS(UTF8_STRING, System, Utf8String)
860+
/// DEFINE_METHOD(UTF8_STRING, CTORF_READONLYSPANOFBYTE,Ctor, IM_ReadOnlySpanOfByte_RetUtf8Str)
861+
/// DEFINE_METHOD(UTF8_STRING, CTORF_READONLYSPANOFCHAR,Ctor, IM_ReadOnlySpanOfChar_RetUtf8Str)
862+
/// DEFINE_METHOD(UTF8_STRING, CTORF_BYTEARRAY_START_LEN,Ctor, IM_ArrByte_Int_Int_RetUtf8Str)
863+
/// DEFINE_METHOD(UTF8_STRING, CTORF_BYTEPTR, Ctor, IM_PtrByte_RetUtf8Str)
864+
/// DEFINE_METHOD(UTF8_STRING, CTORF_CHARARRAY_START_LEN,Ctor, IM_ArrChar_Int_Int_RetUtf8Str)
865+
/// DEFINE_METHOD(UTF8_STRING, CTORF_CHARPTR, Ctor, IM_PtrChar_RetUtf8Str)
866+
/// DEFINE_METHOD(UTF8_STRING, CTORF_STRING, Ctor, IM_String_RetUtf8Str)
867+
/// #endif // FEATURE_UTF8STRING
862868

863869
DEFINE_CLASS(STRING_BUILDER, Text, StringBuilder)
864870
DEFINE_PROPERTY(STRING_BUILDER, LENGTH, Length, Int)

0 commit comments

Comments
 (0)