-
Notifications
You must be signed in to change notification settings - Fork 48
Add RISCV64 TargetArchitecture #171
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ public enum TargetArchitecture { | |
| ARM = 0x01c0, | ||
| ARMv7 = 0x01c4, | ||
| ARM64 = 0xaa64, | ||
| RiscV64 = 0x5064, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you need to define the enum value when it is no longer used in the rest Cecil? It is ok to have unnamed enum values.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is checked in the linker here: https://github.com/dotnet/runtime/blob/fa1164c327052042120bf0d3b6fc81e86cfab69d/src/tools/illink/src/linker/Linker.Steps/OutputStep.cs#L79. Perhaps we can remove that validation and cleanup the enum?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I have just made the same suggestion above.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you so much. I have a question.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cecil uses it to determine Windows native image offsets, while linker is using it for Windows PE machine type, which is irrelevant in .NET Core. I think returning 0 for new architectures from https://github.com/dotnet/runtime/blob/fa1164c327052042120bf0d3b6fc81e86cfab69d/src/tools/illink/src/linker/Linker.Steps/OutputStep.cs#L128 (while keeping the existing ones for .NET Framework compat) is more desirable. See how relaxed the readers are implemented: https://github.com/dotnet/runtime/blob/fa1164c327052042120bf0d3b6fc81e86cfab69d/src/coreclr/System.Private.CoreLib/src/System/Reflection/AssemblyName.CoreCLR.cs#L144 and similar discussion in dotnet/runtime#77697. I think this patch +/- test adjustment will do it for now: --- a/runtime/src/tools/illink/src/linker/Linker.Steps/OutputStep.cs
+++ b/runtime/src/tools/illink/src/linker/Linker.Steps/OutputStep.cs
@@ -76,7 +76,8 @@ TargetArchitecture CalculateArchitecture (TargetArchitecture readyToRunArch)
if (architectureMap.TryGetValue ((ushort) readyToRunArch, out TargetArchitecture pureILArch)) {
return pureILArch;
}
- throw new BadImageFormatException ("unrecognized module attributes");
+
+ return 0; // Unknown architecture which ultimately translates to AnyCPU in .NET Core
}
protected override bool ConditionToProcess ()
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would go even further, delete the CalculateArchitecture method, and change this line to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jkotas @am11 I think I misunderstood something.
I think it is good. I made a PR. dotnet/runtime#101038 |
||
| } | ||
|
|
||
| [Flags] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add LA64 while touching it:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I will add AnyCPU for RiscV64 and LoongArch64 as jkotas reviewed.