From 223e837366789cd74bfdd5eae54b1722bae0dbfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 6 Jul 2023 16:19:52 +0900 Subject: [PATCH 1/9] Something that works --- .../Microsoft.NETCore.Native.targets | 17 -- .../Win32Resources/ResourceData.Reader.cs | 0 .../ResourceData.ResourcesDataModel.cs | 0 .../ResourceData.UpdateResourceDataModel.cs | 0 .../ResourceData.Win32Structs.cs | 0 .../Compiler}/Win32Resources/ResourceData.cs | 38 +-- .../DumpNativeResources.cs | 255 ------------------ .../Compiler/Win32ResourcesRootProvider.cs | 154 +++++++++++ .../ILCompiler.Compiler.csproj | 6 + .../ILCompiler.ReadyToRun.csproj | 10 +- src/coreclr/tools/aot/ILCompiler/Program.cs | 4 + .../reproNative/reproNative.vcxproj | 3 + 12 files changed, 194 insertions(+), 293 deletions(-) rename src/coreclr/tools/{aot/ILCompiler.ReadyToRun => Common/Compiler}/Win32Resources/ResourceData.Reader.cs (100%) rename src/coreclr/tools/{aot/ILCompiler.ReadyToRun => Common/Compiler}/Win32Resources/ResourceData.ResourcesDataModel.cs (100%) rename src/coreclr/tools/{aot/ILCompiler.ReadyToRun => Common/Compiler}/Win32Resources/ResourceData.UpdateResourceDataModel.cs (100%) rename src/coreclr/tools/{aot/ILCompiler.ReadyToRun => Common/Compiler}/Win32Resources/ResourceData.Win32Structs.cs (100%) rename src/coreclr/tools/{aot/ILCompiler.ReadyToRun => Common/Compiler}/Win32Resources/ResourceData.cs (92%) delete mode 100644 src/coreclr/tools/aot/ILCompiler.Build.Tasks/DumpNativeResources.cs create mode 100644 src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index 3b40c7a1e7598..c2c16378e4bc8 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -311,22 +311,6 @@ The .NET Foundation licenses this file to you under the MIT license. - - <_Win32ResFile>$(NativeIntermediateOutputPath)$(TargetName).res - - - - - - - - - - diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.Reader.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Reader.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.Reader.cs rename to src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Reader.cs diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.ResourcesDataModel.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.ResourcesDataModel.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.ResourcesDataModel.cs rename to src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.ResourcesDataModel.cs diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.UpdateResourceDataModel.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.UpdateResourceDataModel.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.UpdateResourceDataModel.cs rename to src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.UpdateResourceDataModel.cs diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.Win32Structs.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Win32Structs.cs similarity index 100% rename from src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.Win32Structs.cs rename to src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Win32Structs.cs diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs similarity index 92% rename from src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.cs rename to src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs index d88d0308e15a0..a6b5f1ab31a0c 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Win32Resources/ResourceData.cs +++ b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs @@ -82,6 +82,11 @@ public bool IsEmpty } public void WriteResources(ISymbolNode nodeAssociatedWithDataBuilder, ref ObjectDataBuilder dataBuilder) + { + WriteResources(nodeAssociatedWithDataBuilder, ref dataBuilder, ref dataBuilder); + } + + public void WriteResources(ISymbolNode nodeAssociatedWithDataBuilder, ref ObjectDataBuilder dataBuilder, ref ObjectDataBuilder contentBuilder) { Debug.Assert(dataBuilder.CountBytes == 0); @@ -126,6 +131,23 @@ public void WriteResources(ISymbolNode nodeAssociatedWithDataBuilder, ref Object } } + // Emit byte arrays of resource data, capture the offsets + foreach (Tuple language in resLanguages) + { + contentBuilder.PadAlignment(8); // Data in resource files is 8 byte aligned + dataEntryTable.Add(language.Item1, contentBuilder.CountBytes); + contentBuilder.EmitBytes(language.Item1.DataEntry); + } + contentBuilder.PadAlignment(8); // Data in resource files is 8 byte aligned + + dataBuilder.PadAlignment(4); // resource data entries are 4 byte aligned + foreach (Tuple language in resLanguages) + { + dataBuilder.EmitInt(language.Item2, dataBuilder.CountBytes); + IMAGE_RESOURCE_DATA_ENTRY.Write(ref dataBuilder, nodeAssociatedWithDataBuilder, dataEntryTable[language.Item1], language.Item1.DataEntry.Length); + } + dataBuilder.PadAlignment(4); // resource data entries are 4 byte aligned + // Emit name table dataBuilder.PadAlignment(2); // name table is 2 byte aligned foreach (KeyValuePair> name in nameTable) @@ -141,22 +163,6 @@ public void WriteResources(ISymbolNode nodeAssociatedWithDataBuilder, ref Object dataBuilder.EmitUShort((ushort)c); } } - - // Emit byte arrays of resource data, capture the offsets - foreach (Tuple language in resLanguages) - { - dataBuilder.PadAlignment(4); // Data in resource files is 4 byte aligned - dataEntryTable.Add(language.Item1, dataBuilder.CountBytes); - dataBuilder.EmitBytes(language.Item1.DataEntry); - } - - dataBuilder.PadAlignment(4); // resource data entries are 4 byte aligned - foreach (Tuple language in resLanguages) - { - dataBuilder.EmitInt(language.Item2, dataBuilder.CountBytes); - IMAGE_RESOURCE_DATA_ENTRY.Write(ref dataBuilder, nodeAssociatedWithDataBuilder, dataEntryTable[language.Item1], language.Item1.DataEntry.Length); - } - dataBuilder.PadAlignment(4); // resource data entries are 4 byte aligned } } } diff --git a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/DumpNativeResources.cs b/src/coreclr/tools/aot/ILCompiler.Build.Tasks/DumpNativeResources.cs deleted file mode 100644 index 374a9fd613781..0000000000000 --- a/src/coreclr/tools/aot/ILCompiler.Build.Tasks/DumpNativeResources.cs +++ /dev/null @@ -1,255 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.IO; -using System.Reflection.Metadata; -using System.Reflection.PortableExecutable; -using System.Text; - -using Microsoft.Build.Framework; -using Microsoft.Build.Utilities; - -namespace Build.Tasks -{ - /// - /// Dumps native Win32 resources in the given assembly into a specified *.res file. - /// - public class DumpNativeResources : Task - { - /// - /// File name of the assembly with Win32 resources to be dumped. - /// - [Required] - public string MainAssembly - { - get; - set; - } - - /// - /// File name into which to dump the Win32 resources. - /// - [Required] - public string ResourceFile - { - get; - set; - } - - public override bool Execute() - { - using (FileStream fs = File.OpenRead(MainAssembly)) - using (PEReader peFile = new PEReader(fs)) - { - DirectoryEntry resourceDirectory = peFile.PEHeaders.PEHeader.ResourceTableDirectory; - if (resourceDirectory.Size != 0 - && peFile.PEHeaders.TryGetDirectoryOffset(resourceDirectory, out int rsrcOffset)) - { - using (var bw = new BinaryWriter(File.OpenWrite(ResourceFile))) - { - ResWriter.WriteResources(peFile, rsrcOffset, resourceDirectory.Size, bw); - } - } - else - { - if (File.Exists(ResourceFile)) - { - try - { - File.Delete(ResourceFile); - } - catch { } - } - } - } - - return true; - } - } - - /// - /// Helper class that converts from a Win32 PE resource directory format to - /// a set of RESOURCEHEADER structures (https://docs.microsoft.com/en-us/windows/desktop/menurc/resourceheader) - /// that form the basis of Win32 RES files. - /// - internal sealed class ResWriter - { - private readonly PEMemoryBlock _memoryBlock; - private readonly PEReader _peReader; - private readonly int _rsrcOffset; - private readonly int _rsrcSize; - private readonly BinaryWriter _bw; - - private object _typeIdOrName; - private object _resourceIdOrName; - private int _languageId; - - private ResWriter(PEMemoryBlock memoryBlock, PEReader peReader, int rsrcOffset, int rsrcSize, BinaryWriter bw) - { - _memoryBlock = memoryBlock; - _peReader = peReader; - _rsrcOffset = rsrcOffset; - _rsrcSize = rsrcSize; - _bw = bw; - } - - public static void WriteResources(PEReader reader, int rsrcOffset, int rsrcSize, BinaryWriter bw) - { - var rw = new ResWriter(reader.GetEntireImage(), reader, rsrcOffset, rsrcSize, bw); - - // First entry is a null resource entry - - bw.Write(new byte[] { - 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }); - - rw.DumpDirectory(reader.GetEntireImage().GetReader(rsrcOffset, rsrcSize), 0); - } - - private void DumpDirectory(BlobReader br, int level) - { - // Skip characteristics - br.ReadInt32(); - - // Skip time/date stamp - br.ReadInt32(); - - // Skip time/date stamp - br.ReadInt32(); - - ushort numNamed = br.ReadUInt16(); - ushort numId = br.ReadUInt16(); - - for (int i = 0; i < numNamed + numId; i++) - { - int nameOffsetOrId = br.ReadInt32(); - uint entryTableOrSubdirectoryOffset = br.ReadUInt32(); - - if (i < numNamed) - { - nameOffsetOrId = nameOffsetOrId &= 0x7FFFFFFF; - BlobReader nameReader = _memoryBlock.GetReader(_rsrcOffset + nameOffsetOrId, _rsrcSize - nameOffsetOrId); - ushort nameLength = nameReader.ReadUInt16(); - StringBuilder sb = new StringBuilder(nameLength); - for (int charIndex = 0; charIndex < nameLength; charIndex++) - sb.Append((char)nameReader.ReadUInt16()); - string name = sb.ToString(); - - if (level == 0) - { - _typeIdOrName = name; - } - else if (level == 1) - { - _resourceIdOrName = name; - } - else - throw new BadImageFormatException(); - } - else - { - if (level == 0) - { - _typeIdOrName = nameOffsetOrId; - } - else if (level == 1) - { - _resourceIdOrName = nameOffsetOrId; - } - else if (level == 2) - { - _languageId = nameOffsetOrId; - } - else - throw new BadImageFormatException(); - } - - if (level < 2) - { - if ((entryTableOrSubdirectoryOffset & 0x80000000) == 0) - throw new BadImageFormatException(); - entryTableOrSubdirectoryOffset &= 0x7FFFFFFF; - DumpDirectory(_memoryBlock.GetReader(_rsrcOffset + (int)entryTableOrSubdirectoryOffset, _rsrcSize - (int)entryTableOrSubdirectoryOffset), level + 1); - } - else - { - DumpEntry(_memoryBlock.GetReader(_rsrcOffset + (int)entryTableOrSubdirectoryOffset, _rsrcSize - (int)entryTableOrSubdirectoryOffset)); - } - } - } - - private void DumpEntry(BlobReader br) - { - int dataRva = br.ReadInt32(); - int size = br.ReadInt32(); - - // Skip codepage - br.ReadInt32(); - - // Skip reserved - br.ReadInt32(); - - var ms = new MemoryStream(); - var hdr = new BinaryWriter(ms, System.Text.Encoding.Unicode); - - hdr.Write(size); // DataSize - hdr.Write(0); // HeaderSize - hdr.WriteNameOrId(_typeIdOrName); // TYPE - hdr.WriteNameOrId(_resourceIdOrName); // NAME - - // round up to "DWORD" offset - long curHeaderSize = hdr.BaseStream.Position; - while (curHeaderSize % 4 != 0) - { - hdr.Write((byte)0); - curHeaderSize++; - } - - hdr.Write(0); // DataVersion - hdr.Write((short)0); // MemoryFlags - hdr.Write((ushort)_languageId); // LanguageId - hdr.Write(0); // Version - hdr.Write(0); // Characteristics - - // Patch up HeaderSize - var headerSize = hdr.Seek(0, SeekOrigin.Current); - hdr.Seek(4, SeekOrigin.Begin); - hdr.Write((int)headerSize); - - var hdrData = ms.ToArray(); - - _bw.Write(hdrData); - _bw.Write(_peReader.GetSectionData(dataRva).GetReader().ReadBytes(size)); - - // Make sure we are DWORD aligned - var totalSize = hdrData.Length + size; - while (totalSize % 4 != 0) - { - _bw.Write((byte)0); - totalSize++; - } - - } - } - - internal static class ResourceHelper - { - public static void WriteNameOrId(this BinaryWriter bw, object nameOrId) - { - if (nameOrId is string s) - { - // String - bw.Write(s.ToCharArray()); - bw.Write((short)0); - } - else - { - // Integer - bw.Write((short)-1); - bw.Write((short)(int)nameOrId); - } - } - } -} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs new file mode 100644 index 0000000000000..502076528939a --- /dev/null +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs @@ -0,0 +1,154 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; + +using ILCompiler.DependencyAnalysis; +using ILCompiler.DependencyAnalysisFramework; +using ILCompiler.Win32Resources; + +using Internal.Text; +using Internal.TypeSystem.Ecma; + +using Debug = System.Diagnostics.Debug; + +namespace ILCompiler +{ + public class Win32ResourcesRootProvider : ICompilationRootProvider + { + private readonly EcmaModule _resourceModule; + + public Win32ResourcesRootProvider(EcmaModule resourceModule) + => _resourceModule = resourceModule; + + void ICompilationRootProvider.AddCompilationRoots(IRootingServiceProvider rootProvider) + { + var resData = new ResourceData(_resourceModule); + if (!resData.IsEmpty) + { + var rsrc1 = new ObjectDataNode("_rsrc1", new ObjectNodeSection(".rsrc$01", SectionType.ReadOnly)); + var rsrc2 = new ObjectDataNode("_rsrc2", new ObjectNodeSection(".rsrc$02", SectionType.ReadOnly)); + + var rsrc1data = new ObjectDataBuilder(_resourceModule.Context.Target, relocsOnly: true); + var rsrc2data = new ObjectDataBuilder(_resourceModule.Context.Target, relocsOnly: true); + + resData.WriteResources(rsrc2, ref rsrc1data, ref rsrc2data); + + var data1 = rsrc1data.ToObjectData(); + var data2 = rsrc2data.ToObjectData(); + + ArrayBuilder symbolDefs = default; + symbolDefs.Add(rsrc2); + ArrayBuilder relocs = default; + foreach (Relocation reloc in data1.Relocs) + { + Debug.Assert(reloc.RelocType == RelocType.IMAGE_REL_BASED_ADDR32NB); + int targetOffset = + data1.Data[reloc.Offset] + | data1.Data[reloc.Offset + 1] << 8 + | data1.Data[reloc.Offset + 2] << 16 + | data1.Data[reloc.Offset + 3] << 24; + data1.Data[reloc.Offset] = 0; + data1.Data[reloc.Offset + 1] = 0; + data1.Data[reloc.Offset + 2] = 0; + data1.Data[reloc.Offset + 3] = 0; + var newSymbolDef = new ObjectAndOffsetSymbolNode(rsrc2, targetOffset, string.Format("$R{0:X8}", targetOffset), false); + relocs.Add(new Relocation(RelocType.IMAGE_REL_BASED_ABSOLUTE, reloc.Offset, newSymbolDef)); + symbolDefs.Add(newSymbolDef); + } + + data1 = new ObjectNode.ObjectData(data1.Data, relocs.ToArray(), 1, new ISymbolDefinitionNode[] { rsrc1 }); + data2 = new ObjectNode.ObjectData(data2.Data, Array.Empty(), 1, symbolDefs.ToArray()); + + rsrc1.SetData(data1); + rsrc2.SetData(data2); + + System.IO.File.WriteAllBytes("c:\\temp\\rsrc", data1.Data); + + rootProvider.AddCompilationRoot(rsrc1, "Resource section from input module"); + rootProvider.AddCompilationRoot(rsrc2, "Resource section from input module"); + } + } + + public class ObjectAndOffsetSymbolNode : DependencyNodeCore, ISymbolDefinitionNode + { + private ObjectNode _object; + private int _offset; + private Utf8String _name; + private bool _includeCompilationUnitPrefix; + + public ObjectAndOffsetSymbolNode(ObjectNode obj, int offset, Utf8String name, bool includeCompilationUnitPrefix) + { + _object = obj; + _offset = offset; + _name = name; + _includeCompilationUnitPrefix = includeCompilationUnitPrefix; + } + + protected override string GetName(NodeFactory factory) => $"Symbol {_name} at offset {_offset.ToStringInvariant()}"; + + public override bool HasConditionalStaticDependencies => false; + public override bool HasDynamicDependencies => false; + public override bool InterestingForDynamicDependencyAnalysis => false; + public override bool StaticDependenciesAreComputed => true; + + public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) + { + if (_includeCompilationUnitPrefix) + sb.Append(nameMangler.CompilationUnitPrefix); + sb.Append(_name); + } + + int ISymbolNode.Offset => 0; + int ISymbolDefinitionNode.Offset => _offset; + public bool RepresentsIndirectionCell => false; + + public void SetSymbolOffset(int offset) + { + _offset = offset; + } + + public ObjectNode Target => _object; + + public override IEnumerable GetStaticDependencies(NodeFactory factory) + { + return new DependencyListEntry[] { new DependencyListEntry(_object, "ObjectAndOffsetDependency") }; + } + + public override IEnumerable GetConditionalStaticDependencies(NodeFactory factory) => null; + public override IEnumerable SearchDynamicDependencies(List> markedNodes, int firstNode, NodeFactory factory) => null; + } + + private sealed class ObjectDataNode : ObjectNode, ISymbolDefinitionNode + { + private readonly string _name; + private readonly ObjectNodeSection _section; + private ObjectData _data; + + public ObjectDataNode(string name, ObjectNodeSection section) + => (_name, _section) = (name, section); + + public int Offset => 0; + + public override bool IsShareable => false; + + public override int ClassCode => -45678932; + + public override bool StaticDependenciesAreComputed => true; + + public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) => sb.Append(_name); + + public override ObjectNodeSection GetSection(NodeFactory factory) => _section; + + protected override string GetName(NodeFactory factory) => this.GetMangledName(factory.NameMangler); + + public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) => _data; + + public override int CompareToImpl(ISortableNode other, CompilerComparer comparer) + => _name.CompareTo(((ObjectDataNode)other)._name); + + public void SetData(ObjectData data) => _data = data; + } + } +} diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj index f04589d2cf7ee..9d537f7d5ef43 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj @@ -30,6 +30,11 @@ + + + + + IL\DelegateInfo.cs @@ -605,6 +610,7 @@ + diff --git a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj index 21edfddd49605..e516549c90460 100644 --- a/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj +++ b/src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj @@ -122,6 +122,11 @@ + + + + + @@ -265,11 +270,6 @@ - - - - - diff --git a/src/coreclr/tools/aot/ILCompiler/Program.cs b/src/coreclr/tools/aot/ILCompiler/Program.cs index db1160afc4022..3b4ff5032726c 100644 --- a/src/coreclr/tools/aot/ILCompiler/Program.cs +++ b/src/coreclr/tools/aot/ILCompiler/Program.cs @@ -231,6 +231,10 @@ public int Run() compilationRoots.Add(new RuntimeConfigurationRootProvider(settingsBlobName, runtimeOptions)); compilationRoots.Add(new RuntimeConfigurationRootProvider(knobsBlobName, runtimeKnobs)); compilationRoots.Add(new ExpectedIsaFeaturesRootProvider(instructionSetSupport)); + if (typeSystemContext.Target.IsWindows) + { + compilationRoots.Add(new Win32ResourcesRootProvider(entrypointModule)); + } if (SplitExeInitialization) { compilationRoots.Add(new NativeLibraryInitializerRootProvider(typeSystemContext.GeneratedAssembly, CreateInitializerList(typeSystemContext))); diff --git a/src/coreclr/tools/aot/ILCompiler/reproNative/reproNative.vcxproj b/src/coreclr/tools/aot/ILCompiler/reproNative/reproNative.vcxproj index f3905c84906a1..16243fe377d29 100644 --- a/src/coreclr/tools/aot/ILCompiler/reproNative/reproNative.vcxproj +++ b/src/coreclr/tools/aot/ILCompiler/reproNative/reproNative.vcxproj @@ -59,12 +59,15 @@ false + false false + false false + false From 92771a8b559e7604f6dfaa30546f184cd95e5e29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 6 Jul 2023 16:25:01 +0900 Subject: [PATCH 2/9] Put back name table --- .../Compiler/Win32Resources/ResourceData.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs index a6b5f1ab31a0c..7947423902054 100644 --- a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs +++ b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs @@ -131,6 +131,22 @@ public void WriteResources(ISymbolNode nodeAssociatedWithDataBuilder, ref Object } } + // Emit name table + dataBuilder.PadAlignment(2); // name table is 2 byte aligned + foreach (KeyValuePair> name in nameTable) + { + foreach (ObjectDataBuilder.Reservation reservation in name.Value) + { + dataBuilder.EmitUInt(reservation, (uint)dataBuilder.CountBytes | 0x80000000); + } + + dataBuilder.EmitUShort(checked((ushort)name.Key.Length)); + foreach (char c in name.Key) + { + dataBuilder.EmitUShort((ushort)c); + } + } + // Emit byte arrays of resource data, capture the offsets foreach (Tuple language in resLanguages) { @@ -147,22 +163,6 @@ public void WriteResources(ISymbolNode nodeAssociatedWithDataBuilder, ref Object IMAGE_RESOURCE_DATA_ENTRY.Write(ref dataBuilder, nodeAssociatedWithDataBuilder, dataEntryTable[language.Item1], language.Item1.DataEntry.Length); } dataBuilder.PadAlignment(4); // resource data entries are 4 byte aligned - - // Emit name table - dataBuilder.PadAlignment(2); // name table is 2 byte aligned - foreach (KeyValuePair> name in nameTable) - { - foreach (ObjectDataBuilder.Reservation reservation in name.Value) - { - dataBuilder.EmitUInt(reservation, (uint)dataBuilder.CountBytes | 0x80000000); - } - - dataBuilder.EmitUShort(checked((ushort)name.Key.Length)); - foreach (char c in name.Key) - { - dataBuilder.EmitUShort((ushort)c); - } - } } } } From fca9d53e9877e7752f5fb6ad677fcabcce73a1be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 6 Jul 2023 16:28:05 +0900 Subject: [PATCH 3/9] Undo padding --- .../tools/Common/Compiler/Win32Resources/ResourceData.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs index 7947423902054..c8d42fada8f17 100644 --- a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs +++ b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs @@ -150,11 +150,10 @@ public void WriteResources(ISymbolNode nodeAssociatedWithDataBuilder, ref Object // Emit byte arrays of resource data, capture the offsets foreach (Tuple language in resLanguages) { - contentBuilder.PadAlignment(8); // Data in resource files is 8 byte aligned + contentBuilder.PadAlignment(4); // Data in resource files is 4 byte aligned dataEntryTable.Add(language.Item1, contentBuilder.CountBytes); contentBuilder.EmitBytes(language.Item1.DataEntry); } - contentBuilder.PadAlignment(8); // Data in resource files is 8 byte aligned dataBuilder.PadAlignment(4); // resource data entries are 4 byte aligned foreach (Tuple language in resLanguages) From 509ace9bedf548e789e7aad019e8c52503750ac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 6 Jul 2023 16:35:04 +0900 Subject: [PATCH 4/9] Undo rewriting --- .../ResourceData.Win32Structs.cs | 8 +- .../Compiler/Win32ResourcesRootProvider.cs | 83 +------------------ 2 files changed, 11 insertions(+), 80 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Win32Structs.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Win32Structs.cs index 114acad5a87d6..98e95b78a9b06 100644 --- a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Win32Structs.cs +++ b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Win32Structs.cs @@ -84,7 +84,13 @@ public IMAGE_RESOURCE_DATA_ENTRY(ref BlobReader blobReader) public static void Write(ref ObjectDataBuilder dataBuilder, ISymbolNode node, int offsetFromSymbol, int sizeOfData) { - dataBuilder.EmitReloc(node, RelocType.IMAGE_REL_BASED_ADDR32NB, offsetFromSymbol); + dataBuilder.EmitReloc(node, +#if READYTORUN + RelocType.IMAGE_REL_BASED_ADDR32NB, +#else + RelocType.IMAGE_REL_BASED_ABSOLUTE, +#endif + offsetFromSymbol); dataBuilder.EmitInt(sizeOfData); dataBuilder.EmitInt(1252); // CODEPAGE = DEFAULT_CODEPAGE dataBuilder.EmitInt(0); // RESERVED diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs index 502076528939a..e517211477ca6 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs @@ -31,95 +31,20 @@ void ICompilationRootProvider.AddCompilationRoots(IRootingServiceProvider rootPr var rsrc2 = new ObjectDataNode("_rsrc2", new ObjectNodeSection(".rsrc$02", SectionType.ReadOnly)); var rsrc1data = new ObjectDataBuilder(_resourceModule.Context.Target, relocsOnly: true); + rsrc1data.AddSymbol(rsrc1); var rsrc2data = new ObjectDataBuilder(_resourceModule.Context.Target, relocsOnly: true); + rsrc2data.AddSymbol(rsrc2); resData.WriteResources(rsrc2, ref rsrc1data, ref rsrc2data); - var data1 = rsrc1data.ToObjectData(); - var data2 = rsrc2data.ToObjectData(); - - ArrayBuilder symbolDefs = default; - symbolDefs.Add(rsrc2); - ArrayBuilder relocs = default; - foreach (Relocation reloc in data1.Relocs) - { - Debug.Assert(reloc.RelocType == RelocType.IMAGE_REL_BASED_ADDR32NB); - int targetOffset = - data1.Data[reloc.Offset] - | data1.Data[reloc.Offset + 1] << 8 - | data1.Data[reloc.Offset + 2] << 16 - | data1.Data[reloc.Offset + 3] << 24; - data1.Data[reloc.Offset] = 0; - data1.Data[reloc.Offset + 1] = 0; - data1.Data[reloc.Offset + 2] = 0; - data1.Data[reloc.Offset + 3] = 0; - var newSymbolDef = new ObjectAndOffsetSymbolNode(rsrc2, targetOffset, string.Format("$R{0:X8}", targetOffset), false); - relocs.Add(new Relocation(RelocType.IMAGE_REL_BASED_ABSOLUTE, reloc.Offset, newSymbolDef)); - symbolDefs.Add(newSymbolDef); - } - - data1 = new ObjectNode.ObjectData(data1.Data, relocs.ToArray(), 1, new ISymbolDefinitionNode[] { rsrc1 }); - data2 = new ObjectNode.ObjectData(data2.Data, Array.Empty(), 1, symbolDefs.ToArray()); - - rsrc1.SetData(data1); - rsrc2.SetData(data2); - - System.IO.File.WriteAllBytes("c:\\temp\\rsrc", data1.Data); + rsrc1.SetData(rsrc1data.ToObjectData()); + rsrc2.SetData(rsrc2data.ToObjectData()); rootProvider.AddCompilationRoot(rsrc1, "Resource section from input module"); rootProvider.AddCompilationRoot(rsrc2, "Resource section from input module"); } } - public class ObjectAndOffsetSymbolNode : DependencyNodeCore, ISymbolDefinitionNode - { - private ObjectNode _object; - private int _offset; - private Utf8String _name; - private bool _includeCompilationUnitPrefix; - - public ObjectAndOffsetSymbolNode(ObjectNode obj, int offset, Utf8String name, bool includeCompilationUnitPrefix) - { - _object = obj; - _offset = offset; - _name = name; - _includeCompilationUnitPrefix = includeCompilationUnitPrefix; - } - - protected override string GetName(NodeFactory factory) => $"Symbol {_name} at offset {_offset.ToStringInvariant()}"; - - public override bool HasConditionalStaticDependencies => false; - public override bool HasDynamicDependencies => false; - public override bool InterestingForDynamicDependencyAnalysis => false; - public override bool StaticDependenciesAreComputed => true; - - public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb) - { - if (_includeCompilationUnitPrefix) - sb.Append(nameMangler.CompilationUnitPrefix); - sb.Append(_name); - } - - int ISymbolNode.Offset => 0; - int ISymbolDefinitionNode.Offset => _offset; - public bool RepresentsIndirectionCell => false; - - public void SetSymbolOffset(int offset) - { - _offset = offset; - } - - public ObjectNode Target => _object; - - public override IEnumerable GetStaticDependencies(NodeFactory factory) - { - return new DependencyListEntry[] { new DependencyListEntry(_object, "ObjectAndOffsetDependency") }; - } - - public override IEnumerable GetConditionalStaticDependencies(NodeFactory factory) => null; - public override IEnumerable SearchDynamicDependencies(List> markedNodes, int firstNode, NodeFactory factory) => null; - } - private sealed class ObjectDataNode : ObjectNode, ISymbolDefinitionNode { private readonly string _name; From 9fbac43fbf36822fe820fb9f928118a51d8f82d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Thu, 6 Jul 2023 17:53:33 +0900 Subject: [PATCH 5/9] Cleanups --- .../Microsoft.NETCore.Native.targets | 3 +- .../Compiler/Win32ResourcesRootProvider.cs | 7 --- .../aot/ILCompiler/ILCompilerRootCommand.cs | 3 ++ src/coreclr/tools/aot/ILCompiler/Program.cs | 11 ++-- .../Win32Resources/Win32Resources.cs | 49 ++++++++++++++++++ .../Win32Resources/Win32Resources.csproj | 13 +++++ .../SmokeTests/Win32Resources/build.cmd | 2 + .../SmokeTests/Win32Resources/test.rc | 6 +++ .../SmokeTests/Win32Resources/test.res | Bin 0 -> 192 bytes 9 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 src/tests/nativeaot/SmokeTests/Win32Resources/Win32Resources.cs create mode 100644 src/tests/nativeaot/SmokeTests/Win32Resources/Win32Resources.csproj create mode 100644 src/tests/nativeaot/SmokeTests/Win32Resources/build.cmd create mode 100644 src/tests/nativeaot/SmokeTests/Win32Resources/test.rc create mode 100644 src/tests/nativeaot/SmokeTests/Win32Resources/test.res diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index c2c16378e4bc8..322187ca8c0f0 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -255,6 +255,7 @@ The .NET Foundation licenses this file to you under the MIT license. + @@ -314,7 +315,7 @@ The .NET Foundation licenses this file to you under the MIT license. + DependsOnTargets="$(LinkNativeDependsOn)"> diff --git a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs index e517211477ca6..d699e6e07be82 100644 --- a/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs +++ b/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Win32ResourcesRootProvider.cs @@ -1,18 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System; -using System.Collections.Generic; - using ILCompiler.DependencyAnalysis; -using ILCompiler.DependencyAnalysisFramework; using ILCompiler.Win32Resources; using Internal.Text; using Internal.TypeSystem.Ecma; -using Debug = System.Diagnostics.Debug; - namespace ILCompiler { public class Win32ResourcesRootProvider : ICompilationRootProvider @@ -41,7 +35,6 @@ void ICompilationRootProvider.AddCompilationRoots(IRootingServiceProvider rootPr rsrc2.SetData(rsrc2data.ToObjectData()); rootProvider.AddCompilationRoot(rsrc1, "Resource section from input module"); - rootProvider.AddCompilationRoot(rsrc2, "Resource section from input module"); } } diff --git a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs index aff106ef45589..b561489614a92 100644 --- a/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs +++ b/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs @@ -51,6 +51,8 @@ internal sealed class ILCompilerRootCommand : CliRootCommand new("--verbose") { Description = "Enable verbose logging" }; public CliOption SystemModuleName { get; } = new("--systemmodule") { DefaultValueFactory = _ => Helpers.DefaultSystemModule, Description = "System module name (default: System.Private.CoreLib)" }; + public CliOption Win32ResourceModuleName { get; } = + new("--win32resourcemodule") { Description = "Name of the module from which to copy Win32 resources (Windows target only)" }; public CliOption MultiFile { get; } = new("--multifile") { Description = "Compile only input files (do not compile referenced assemblies)" }; public CliOption WaitForDebugger { get; } = @@ -178,6 +180,7 @@ public ILCompilerRootCommand(string[] args) : base(".NET Native IL Compiler") Options.Add(GenerateFullScanDgmlLog); Options.Add(IsVerbose); Options.Add(SystemModuleName); + Options.Add(Win32ResourceModuleName); Options.Add(MultiFile); Options.Add(WaitForDebugger); Options.Add(Resilient); diff --git a/src/coreclr/tools/aot/ILCompiler/Program.cs b/src/coreclr/tools/aot/ILCompiler/Program.cs index 3b4ff5032726c..b87e04f05ac07 100644 --- a/src/coreclr/tools/aot/ILCompiler/Program.cs +++ b/src/coreclr/tools/aot/ILCompiler/Program.cs @@ -231,16 +231,19 @@ public int Run() compilationRoots.Add(new RuntimeConfigurationRootProvider(settingsBlobName, runtimeOptions)); compilationRoots.Add(new RuntimeConfigurationRootProvider(knobsBlobName, runtimeKnobs)); compilationRoots.Add(new ExpectedIsaFeaturesRootProvider(instructionSetSupport)); - if (typeSystemContext.Target.IsWindows) - { - compilationRoots.Add(new Win32ResourcesRootProvider(entrypointModule)); - } if (SplitExeInitialization) { compilationRoots.Add(new NativeLibraryInitializerRootProvider(typeSystemContext.GeneratedAssembly, CreateInitializerList(typeSystemContext))); } } + string win32resourcesModule = Get(_command.Win32ResourceModuleName); + if (typeSystemContext.Target.IsWindows && !string.IsNullOrEmpty(win32resourcesModule)) + { + EcmaModule module = typeSystemContext.GetModuleForSimpleName(win32resourcesModule); + compilationRoots.Add(new Win32ResourcesRootProvider(module)); + } + foreach (var unmanagedEntryPointsAssembly in Get(_command.UnmanagedEntryPointsAssemblies)) { if (typeSystemContext.InputFilePaths.ContainsKey(unmanagedEntryPointsAssembly)) diff --git a/src/tests/nativeaot/SmokeTests/Win32Resources/Win32Resources.cs b/src/tests/nativeaot/SmokeTests/Win32Resources/Win32Resources.cs new file mode 100644 index 0000000000000..1dfc7a8424792 --- /dev/null +++ b/src/tests/nativeaot/SmokeTests/Win32Resources/Win32Resources.cs @@ -0,0 +1,49 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.InteropServices; + +unsafe +{ + nint lib = 0; + + if (GetIntValueFromResource(lib, (ushort*)(nuint)(ushort)10, 0x041B) != 3) + throw new Exception(); + + ReadOnlySpan resName = "funny"; + fixed (char* pResName = resName) + if (GetIntValueFromResource(lib, (ushort*)pResName, 0x041B) != 1) + throw new Exception(); + + return 100; + + static int GetIntValueFromResource(nint hModule, ushort* lpName, ushort wLanguage) + { + ushort* RT_RCDATA = (ushort*)(nuint)(ushort)10; + + nint hResInfo = FindResourceExW(hModule, RT_RCDATA, lpName, wLanguage); + if (hResInfo == 0) + throw new Exception("Resource not found"); + + if (SizeofResource(hModule, hResInfo) != 4) + throw new Exception("Wrong size of resource"); + + nint hResData = LoadResource(hModule, hResInfo); + int val = *(int*)LockResource(hResData); + + return val; + } + + [DllImport("kernel32")] + static extern nint FindResourceExW(nint hModule, ushort* lpType, ushort* lpName, ushort wLanguage); + + [DllImport("kernel32")] + static extern nint LoadResource(nint hModule, nint hResInfo); + + [DllImport("kernel32")] + static extern void* LockResource(nint hResData); + + [DllImport("kernel32")] + static extern uint SizeofResource(nint hModule, nint hResInfo); +} diff --git a/src/tests/nativeaot/SmokeTests/Win32Resources/Win32Resources.csproj b/src/tests/nativeaot/SmokeTests/Win32Resources/Win32Resources.csproj new file mode 100644 index 0000000000000..cfeddf3ef0763 --- /dev/null +++ b/src/tests/nativeaot/SmokeTests/Win32Resources/Win32Resources.csproj @@ -0,0 +1,13 @@ + + + Exe + BuildAndRun + 0 + true + true + test.res + + + + + diff --git a/src/tests/nativeaot/SmokeTests/Win32Resources/build.cmd b/src/tests/nativeaot/SmokeTests/Win32Resources/build.cmd new file mode 100644 index 0000000000000..3d2411d0613f6 --- /dev/null +++ b/src/tests/nativeaot/SmokeTests/Win32Resources/build.cmd @@ -0,0 +1,2 @@ +rem Produces test.res +@rc test.rc diff --git a/src/tests/nativeaot/SmokeTests/Win32Resources/test.rc b/src/tests/nativeaot/SmokeTests/Win32Resources/test.rc new file mode 100644 index 0000000000000..cce35e2d589d6 --- /dev/null +++ b/src/tests/nativeaot/SmokeTests/Win32Resources/test.rc @@ -0,0 +1,6 @@ +LANGUAGE 0x041B, 0 +funny RCDATA { 1L } +10 RCDATA { 3L } +LANGUAGE 0x0405, 0 +funny RCDATA { 2L } +10 RCDATA { 4L } diff --git a/src/tests/nativeaot/SmokeTests/Win32Resources/test.res b/src/tests/nativeaot/SmokeTests/Win32Resources/test.res new file mode 100644 index 0000000000000000000000000000000000000000..4844d68f3714fcbbd9dfec01716942fdfc02baaf GIT binary patch literal 192 zcmZQzU|>)H;{X347|28cEI^(H5dZ(r#o)#e%HRitkx&%|4ALNJFkl3dAdUhMgVcgB c2q3Fr2J-Qn#|k%(3942BNTZsEPy Date: Thu, 6 Jul 2023 18:16:53 +0900 Subject: [PATCH 6/9] analyzer garbage "for better performance!!!!!11111" in files I'm not even touching --- .../Win32Resources/ResourceData.ResourcesDataModel.cs | 6 +++--- .../Compiler/Win32Resources/ResourceData.Win32Structs.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.ResourcesDataModel.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.ResourcesDataModel.cs index c7f315eb45dfa..3a2fdc1aaff4f 100644 --- a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.ResourcesDataModel.cs +++ b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.ResourcesDataModel.cs @@ -11,7 +11,7 @@ public unsafe partial class ResourceData private readonly SortedDictionary _resTypeHeadID = new SortedDictionary(); private readonly SortedDictionary _resTypeHeadName = new SortedDictionary(StringComparer.Ordinal); - private class ResLanguage + private sealed class ResLanguage { public ResLanguage(byte[] data) { @@ -22,12 +22,12 @@ public ResLanguage(byte[] data) public byte[] DataEntry; } - private class ResName + private sealed class ResName { public SortedDictionary Languages = new SortedDictionary(); } - private class ResType + private sealed class ResType { public SortedDictionary NameHeadName = new SortedDictionary(StringComparer.Ordinal); public SortedDictionary NameHeadID = new SortedDictionary(); diff --git a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Win32Structs.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Win32Structs.cs index 98e95b78a9b06..2045a0b9aeb4c 100644 --- a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Win32Structs.cs +++ b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.Win32Structs.cs @@ -49,7 +49,7 @@ public IMAGE_RESOURCE_DIRECTORY_ENTRY(ref BlobReader blobReader) OffsetToData = blobReader.ReadUInt32(); } - public static ObjectDataBuilder.Reservation Write(ref ObjectDataBuilder dataBuilder, string name, IDictionary> nameTable) + public static ObjectDataBuilder.Reservation Write(ref ObjectDataBuilder dataBuilder, string name, SortedDictionary> nameTable) { List relatedNameReferences; if (!nameTable.TryGetValue(name, out relatedNameReferences)) From 9c6a097ff92d264c4ceacb39f650fce865473b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 7 Jul 2023 12:18:52 +0900 Subject: [PATCH 7/9] Update Microsoft.NETCore.Native.targets --- .../nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index 322187ca8c0f0..109a584104064 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -255,7 +255,7 @@ The .NET Foundation licenses this file to you under the MIT license. - + From 32c8d5bf49e3289d010bc4593487c397bbda645c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Fri, 7 Jul 2023 13:45:25 +0900 Subject: [PATCH 8/9] Disable for multifile for now Don't know how to properly condition this to "leaf assemblies". --- .../nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index 109a584104064..fbd9e29972b5e 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -255,7 +255,7 @@ The .NET Foundation licenses this file to you under the MIT license. - + From 2a40622212e552dc034bc0959ac91fbdf27372be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Tue, 11 Jul 2023 15:42:02 +0900 Subject: [PATCH 9/9] Another attempt --- .../BuildIntegration/Microsoft.NETCore.Native.targets | 2 +- src/tests/Directory.Build.targets | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets index fbd9e29972b5e..18b47fb61793b 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets @@ -255,7 +255,7 @@ The .NET Foundation licenses this file to you under the MIT license. - + diff --git a/src/tests/Directory.Build.targets b/src/tests/Directory.Build.targets index 6a6bdcba99dfd..e00069e87a8ff 100644 --- a/src/tests/Directory.Build.targets +++ b/src/tests/Directory.Build.targets @@ -522,6 +522,9 @@ true + + false + partial