3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
940 stars 131 forks source link

[VS2019] Build Failure: syntax error at token 'inf' #128

Closed theoractice closed 4 years ago

theoractice commented 4 years ago

This is with the latest VS2019 version 16.4. Build log:

1>E:\Users\Administrator\git\GMMatchvs\packages\DllExport.1.6.5\tools\net.r_eg.DllExport.targets(59,5): error : C:\Users\Administrator\AppData\Local\Temp\tmp3792\GMMatchvs.x86.il(182) : error : syntax error at token 'inf' in:   .field public static literal float32 'Infinity' = float32(inf)
1>E:\Users\Administrator\git\GMMatchvs\packages\DllExport.1.6.5\tools\net.r_eg.DllExport.targets(59,5): error : 
1>     在 RGiesecke.DllExport.Parsing.IlParser.RunIlTool(String installPath, String toolFileName, String requiredPaths, String workingDirectory, String settingsName, String arguments, String toolLoggingCode, String verboseLoggingCode, IDllExportNotifier notifier, Int32 timeout, Func`2 suppressErrorOutputLine) 位置 C:\projects\dllexport\RGiesecke.DllExport\Parsing\IlParser.cs:行号 368
1>     在 RGiesecke.DllExport.Parsing.IlAsm.RunCore(CpuPlatform cpu, String fileName, String ressourceParam, String ilSuffix) 位置 C:\projects\dllexport\RGiesecke.DllExport\Parsing\ILAsm.cs:行号 143
1>     在 RGiesecke.DllExport.Parsing.IlAsm.Run(String outputFile, String ilSuffix, CpuPlatform cpu) 位置 C:\projects\dllexport\RGiesecke.DllExport\Parsing\ILAsm.cs:行号 113
1>     在 RGiesecke.DllExport.Parsing.IlAsm.ReassembleFile(String outputFile, String ilSuffix, CpuPlatform cpu) 位置 C:\projects\dllexport\RGiesecke.DllExport\Parsing\ILAsm.cs:行号 52
1>     在 RGiesecke.DllExport.DllExportWeaver.reassembleFile(IlAsm ilAsm, String outputFile, String ilSuffix, CpuPlatform cpu) 位置 C:\projects\dllexport\RGiesecke.DllExport\DllExportWeaver.cs:行号 198
1>     在 RGiesecke.DllExport.DllExportWeaver.RunIlAsm(IlAsm ilAsm) 位置 C:\projects\dllexport\RGiesecke.DllExport\DllExportWeaver.cs:行号 163
1>     在 RGiesecke.DllExport.DllExportWeaver.Run() 位置 C:\projects\dllexport\RGiesecke.DllExport\DllExportWeaver.cs:行号 89
1>     在 RGiesecke.DllExport.MSBuild.ExportTaskImplementation`1.Execute() 位置 C:\projects\dllexport\RGiesecke.DllExport.MSBuild\RGiesecke.DllExport.MSBuild\ExportTaskImplementation.cs:行号 463

Maybe this is what happened: syntax error at token 'inf' in: .field public static literal float32 'Infinity' = float32(inf).

The problematic il snippet:

...
// =============== CLASS MEMBERS DECLARATION ===================

.class public sequential ansi sealed beforefieldinit 'Mathf'
       extends ['mscorlib']'System'.'ValueType'
{
  .pack 0
  .size 1
  .field public static literal float32 'PI' = float32(3.141593)
  .field public static literal float32 'Infinity' = float32(inf)
  .field public static literal float32 'NegativeInfinity' = float32(-inf)
  .field public static literal float32 'Deg2Rad' = float32(1.7453291e-02)
  .field public static literal float32 'Rad2Deg' = float32(57.29578)
  .method public hidebysig static float32 
          'Sin'(float32 'f') cil managed
  {
    // 代码大小       9 (0x9)
    .maxstack  8
    IL_0000:  ldarg.0
    IL_0001:  conv.r8
    IL_0002:  call       float64 ['mscorlib']'System'.'Math'::'Sin'(float64)
    IL_0007:  conv.r4
    IL_0008:  ret
  } // end of method 'Mathf'::'Sin'
...

Any ideas?

theoractice commented 4 years ago

Maybe a regression in the latest ILDasm? https://developercommunity.visualstudio.com/content/problem/545431/ildasmexe-regression-with-infinum-floating-point-v.html

3F commented 4 years ago

Please clarify the following:

What DllExport version? What ILAsm/ILDasm? What project type?

Did you try our custom ilasm/ildasm versions?

And can you try with my latest 4.700.2 version: https://github.com/3F/coreclr

theoractice commented 4 years ago

Ah, never know there is a version for .net core, that's very helpful, thanks. However I'm using v1.6.5 with a .net framework dll project so this issue is not .net core related. I tried every option that I could find including the "Use our IL Assembler" one, and none of them worked.

3F commented 4 years ago

I confirm the mismatch between versions.

ILDasm 4.8.3928.0 marks this as inf/-inf While the most modern ILAsm (4.8.3761.0 on my laptop) can only process it as 0x7F800000/0xFF800000 values (for single precision of course).

So, Actually you need address it to Microsoft. Because we already provide our own modified versions. Please use this instead.

I tried every option that I could find including the "Use our IL Assembler" one, and none of them worked.

Please attach log with diagnostic key:

msbuild /v:diag

Or please minimal reproducible project sample. Because I don't see problems when our assembler.

Ah, never know there is a version for .net core, that's very helpful, thanks.

Yes, planned 1.7 provides both support for netfx and netcore.

Beta2 release is just out: https://twitter.com/GitHub3F/status/1205616579607715840

3F commented 4 years ago

1.7 Beta3 release provides now Single + Double Inf/-Inf token patching option.

Check this out.

theoractice commented 4 years ago

1.7 beta3 with the "Use our IL Assembler" option works, thanks.

Or please minimal reproducible project sample. Because I don't see problems when our assembler.

Version 1.6.5 with the "Use our IL Assembler" option yields this error: error : Failed to define security permission set for 0x20000001 Sorry I forgot to mention this type of error in previous comments, but that's how it fails. Just post here FYI.

1.7 Beta3 release provides now Single + Double Inf/-Inf token patching option.

I cannot find that option in the config window. In fact it looks like this: image And if I uncheck the "Use our IL Assembler" option, then the inf error reappears. Are there any options hidden because of the window size? I cannot resize it.

3F commented 4 years ago

1.7 beta3 with the "Use our IL Assembler" option works, thanks.

Good! FYI, This patch can be also applied for original MS assembler on netfx.

error : Failed to define security permission set for 0x20000001

This is known error: https://github.com/3F/DllExport/issues/19#issuecomment-269245014

I cannot find that option in the config window.

Yes, more like the problem with layout, again on Chinese system: https://github.com/3F/DllExport/issues/61

You can temporarily configure it manually, please update value for DllExportPatches in your settings (project files or external target depends on your choice):

You need set the first bit for mask:

/// <summary>
/// Affects ldc.r8; ldc.r4; .field;
/// 
/// inf/-inf to 0x7F800000/0xFF800000 
///             0x7FF0000000000000/0xFFF0000000000000
/// 
/// https://github.com/3F/DllExport/issues/128
/// </summary>
InfToken = 0x01,

eg.:

<DllExportPatches>here</DllExportPatches>

I cannot resize it.

It shouldn't be resized. Please continue here: https://github.com/3F/DllExport/issues/61#issuecomment-566519504

theoractice commented 4 years ago

All problems solved, thank you very much.

qysnn commented 1 year ago

I run into the exact same issue on VS 2022 and can confirm that the Single + Double Inf/-Inf token patching option solves it.