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

Warnings by default when PublishTrimmed=true TrimMode=link #41654

Closed
eerhardt opened this issue Sep 1, 2020 · 3 comments
Closed

Warnings by default when PublishTrimmed=true TrimMode=link #41654

eerhardt opened this issue Sep 1, 2020 · 3 comments
Assignees
Milestone

Comments

@eerhardt
Copy link
Member

eerhardt commented Sep 1, 2020

Description

  1. dotnet new console
  2. dotnet publish -r win-x64 /p:PublishTrimmed=true /p:TrimMode=link

This emits 2 warnings:

resource System.Private.CoreLib.xml in System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e : warning IL2008: Could not resolve type 'System.Char8' [F:\DotNetTest\Playground2\Playground2.csproj]
resource System.Private.CoreLib.xml in System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e : warning IL2008: Could not resolve type 'System.Utf8String' [F:\DotNetTest\Playground2\Playground2.csproj]

Configuration

  • Which version of .NET is the code running on? .NET 5.0.100-rc.1.20431.5
  • What OS and version, and what distro if applicable? All coreclr based configurations.

Regression?

This is a regression from previous .NET 5 builds. Previously there were no warnings by default.

Other information

We've removed the System.Char8 and System.Utf8String managed types in the 5.0 RC1 builds. This is causing the ILLinker to emit warnings by default because we generate an ILLink.Descriptor file based off the headers in coreclr:

        <type fullname="System.Char8" preserve="nothing" />
...
        <type fullname="System.Utf8String">
            <method name="Ctor" />
        </type>

If we are removing System.Char8 and System.Utf8String managed types, we need to also remove the code from coreclr's header files so the target in https://github.com/dotnet/runtime/blob/master/src/coreclr/src/System.Private.CoreLib/CreateRuntimeRootILLinkDescriptorFile.targets doesn't generate these entries in the ILLink.Descriptors file. See:

#ifdef FEATURE_UTF8STRING
DEFINE_CLASS(CHAR8, System, Char8)
#endif // FEATURE_UTF8STRING

and

#ifdef FEATURE_UTF8STRING
DEFINE_CLASS(UTF8_STRING, System, Utf8String)
DEFINE_METHOD(UTF8_STRING, CTORF_READONLYSPANOFBYTE,Ctor, IM_ReadOnlySpanOfByte_RetUtf8Str)
DEFINE_METHOD(UTF8_STRING, CTORF_READONLYSPANOFCHAR,Ctor, IM_ReadOnlySpanOfChar_RetUtf8Str)
DEFINE_METHOD(UTF8_STRING, CTORF_BYTEARRAY_START_LEN,Ctor, IM_ArrByte_Int_Int_RetUtf8Str)
DEFINE_METHOD(UTF8_STRING, CTORF_BYTEPTR, Ctor, IM_PtrByte_RetUtf8Str)
DEFINE_METHOD(UTF8_STRING, CTORF_CHARARRAY_START_LEN,Ctor, IM_ArrChar_Int_Int_RetUtf8Str)
DEFINE_METHOD(UTF8_STRING, CTORF_CHARPTR, Ctor, IM_PtrChar_RetUtf8Str)
DEFINE_METHOD(UTF8_STRING, CTORF_STRING, Ctor, IM_String_RetUtf8Str)
#endif // FEATURE_UTF8STRING

cc @vitek-karas @sbomer @GrabYourPitchforks

@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Sep 1, 2020
@jkotas jkotas added this to the 5.0.0 milestone Sep 1, 2020
@ghost
Copy link

ghost commented Sep 1, 2020

Tagging subscribers to this area: @vitek-karas, @agocke
See info in area-owners.md if you want to be subscribed.

@jeffschwMSFT jeffschwMSFT removed the untriaged New issue has not been triaged by the area owner label Sep 1, 2020
eerhardt added a commit to eerhardt/runtime that referenced this issue Sep 1, 2020
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 dotnet#41654
eerhardt added a commit that referenced this issue Sep 1, 2020
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
@eerhardt
Copy link
Member Author

eerhardt commented Sep 1, 2020

Resolved by #41680.

@eerhardt eerhardt closed this as completed Sep 1, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants