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

Consider getting rid of DumpNativeResources task #79634

Closed
MichalStrehovsky opened this issue Dec 14, 2022 · 2 comments · Fixed by #88464
Closed

Consider getting rid of DumpNativeResources task #79634

MichalStrehovsky opened this issue Dec 14, 2022 · 2 comments · Fixed by #88464

Comments

@MichalStrehovsky
Copy link
Member

MichalStrehovsky commented Dec 14, 2022

This task extracts native resources from the input assembly and puts them into a res file. We then pass the res file to the linker.

Looks like linker then runs cvtres to convert it to an object file. We could just dump the resources into the object file the AOT compiler is generating and get rid of the step.

Motivated by a report of:

CVTRES : fatal error CVT1103: cannot read file [REDACTED.csproj]
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt [REDACTED.csproj]
C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.DotNet.ILCompiler\build\Microsoft.NETCore.Native.targets(350,5): err
or MSB3073: The command ""C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\bin\Hostx6
4\x64\link.exe" @"obj\Release\net7.0\win-x64\native\link.rsp"" exited with code 1123. [REDACTED.csproj]
@ghost
Copy link

ghost commented Dec 14, 2022

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

Issue Details

This task extracts native resources from the input assembly and puts them into a res file. We then pass the res file to the linker.

Looks like linker then runs cvres to convert it to an object file. We could just dump the resources into the object file the AOT compiler is generating and get rid of the step.

Motivated by a report of:

CVTRES : fatal error CVT1103: cannot read file [REDACTED.csproj]
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt [REDACTED.csproj]
C:\Program Files\dotnet\sdk\7.0.101\Sdks\Microsoft.DotNet.ILCompiler\build\Microsoft.NETCore.Native.targets(350,5): err
or MSB3073: The command ""C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.34.31933\bin\Hostx6
4\x64\link.exe" @"obj\Release\net7.0\win-x64\native\link.rsp"" exited with code 1123. [REDACTED.csproj]
Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: Future

@jkotas
Copy link
Member

jkotas commented May 19, 2023

LNK1123: failure during conversion to COFF: file invalid or corrupt

dotnet/runtimelab#1436
#86493

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 6, 2023
MichalStrehovsky added a commit that referenced this issue Jul 11, 2023
Fixes #79634.

To generate Win32 resources, we'd first use an MSBuild task to dump Win32 resources from the input IL module into a `.res` file. We'd then pass the `.res` file to link.exe. Link.exe would then invoke cvtres.exe to convert the `.res` file to `.obj`. Link.exe then links the `.obj` into the final executable.

Skip all of this and instead generate the correct object data in the compiler directly. I'm reusing Win32 resource emission logic from crossgen2. It already mostly does the right thing - we just needed to split the `.rsrc` section into `.rsrc$01` and `.rsrc$02` that link.exe expects. The first part has the data directory. The second part has the actual resource data.

Contributes to #73931. The cvtres step was actually non-deterministic because it creates an object file in TEMP and embeds this temporary name into the object.
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 11, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Aug 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants