Following
Cannot compile CSCORE after retargeting to .NET 4.7.2
and
Failure using ilasm, but no reason given
Trying to build CSCore in VS2019. Initially the postbuild script had paths incompatible with my environment, so I fixed them. Now it kind of works, except it breaks in the postbuild script when it invokes it's InlineILCompiler to inject CLR code in the library.
More precisely, it breaks at approx line 350 of InlineILCompiler\Program.cs, at the step when it invokes the external ilasm.exe to reassemble everything up, using 'disasm.il' as input.
I managed to get a copy of disasm.il before it gets deleted, and I tried to reissue the ilasm command myself, with just the same parameters InlineILCompiler is providing... and it failed like this:
[...looong output here]
Assembled method CSCore.Codecs.AIFF.AiffBinaryReader::ReadUInt32
Assembled method CSCore.Codecs.AIFF.AiffBinaryReader::ReadInt16
Assembled method CSCore.Codecs.AIFF.AiffBinaryReader::ReadUInt16
Assembled method CSCore.Codecs.AIFF.AiffBinaryReader::Skip
Assembled method CSCore.Codecs.AIFF.AiffBinaryReader::ReadBytes
D:\cscore-master\CSCore\Codecs\AIFF\AiffBinaryReader.cs(97) : error : syntax error at token '-' in: IL_00ad: ldc.r8 -nan(ind)
I don't know much about IL, but I still investigated and found out the offending line seems to be in block:
.method private hidebysig instance float64
ConvertFromIeeeExtended(uint8[] bytes) cil managed
{
// Code size 275 (0x113)
.maxstack 8
.locals init ([0] float64 f,
[1] int32 expon,
[2] uint64 hiMant,
[3] uint64 loMant,
[4] bool V_4,
[5] bool V_5,
[6] bool V_6,
[7] float64 V_7)
.line 75,75 : 9,10 ''
IL_0000: nop
.line 80,80 : 13,66 ''
IL_0001: ldarg.1
IL_0002: ldc.i4.0
IL_0003: ldelem.u1
IL_0004: ldc.i4.s 127
IL_0006: and
IL_0007: ldc.i4.8
IL_0008: shl
IL_0009: ldarg.1
IL_000a: ldc.i4.1
IL_000b: ldelem.u1
IL_000c: ldc.i4 0xff
IL_0011: and
IL_0012: or
IL_0013: stloc.1
.line 81,84 : 13,50 ''
IL_0014: ldarg.1
IL_0015: ldc.i4.2
IL_0016: ldelem.u1
IL_0017: ldc.i4 0xff
IL_001c: and
IL_001d: conv.i8
IL_001e: ldc.i4.s 24
IL_0020: shl
IL_0021: ldarg.1
IL_0022: ldc.i4.3
IL_0023: ldelem.u1
IL_0024: ldc.i4 0xff
IL_0029: and
IL_002a: conv.i8
IL_002b: ldc.i4.s 16
IL_002d: shl
IL_002e: or
IL_002f: ldarg.1
IL_0030: ldc.i4.4
IL_0031: ldelem.u1
IL_0032: ldc.i4 0xff
IL_0037: and
IL_0038: conv.i8
IL_0039: ldc.i4.8
IL_003a: shl
IL_003b: or
IL_003c: ldarg.1
IL_003d: ldc.i4.5
IL_003e: ldelem.u1
IL_003f: ldc.i4 0xff
IL_0044: and
IL_0045: conv.i8
IL_0046: or
IL_0047: stloc.2
.line 85,88 : 13,50 ''
IL_0048: ldarg.1
IL_0049: ldc.i4.6
IL_004a: ldelem.u1
IL_004b: ldc.i4 0xff
IL_0050: and
IL_0051: conv.i8
IL_0052: ldc.i4.s 24
IL_0054: shl
IL_0055: ldarg.1
IL_0056: ldc.i4.7
IL_0057: ldelem.u1
IL_0058: ldc.i4 0xff
IL_005d: and
IL_005e: conv.i8
IL_005f: ldc.i4.s 16
IL_0061: shl
IL_0062: or
IL_0063: ldarg.1
IL_0064: ldc.i4.8
IL_0065: ldelem.u1
IL_0066: ldc.i4 0xff
IL_006b: and
IL_006c: conv.i8
IL_006d: ldc.i4.8
IL_006e: shl
IL_006f: or
IL_0070: ldarg.1
IL_0071: ldc.i4.s 9
IL_0073: ldelem.u1
IL_0074: ldc.i4 0xff
IL_0079: and
IL_007a: conv.i8
IL_007b: or
IL_007c: stloc.3
.line 90,90 : 13,58 ''
IL_007d: ldloc.1
IL_007e: brtrue.s IL_008a
IL_0080: ldloc.2
IL_0081: brtrue.s IL_008a
IL_0083: ldloc.3
IL_0084: ldc.i4.0
IL_0085: conv.i8
IL_0086: ceq
IL_0088: br.s IL_008b
IL_008a: ldc.i4.0
IL_008b: stloc.s V_4
.line 16707566,16707566 : 0,0 ''
IL_008d: ldloc.s V_4
IL_008f: brfalse.s IL_009d
.line 91,91 : 17,23 ''
IL_0091: ldc.r8 0.0
IL_009a: stloc.0
IL_009b: br.s IL_00ef
.line 93,93 : 13,14 ''
IL_009d: nop
.line 94,94 : 17,37 ''
IL_009e: ldloc.1
IL_009f: ldc.i4 0x7fff
IL_00a4: ceq
IL_00a6: stloc.s V_5
.line 16707566,16707566 : 0,0 ''
IL_00a8: ldloc.s V_5
IL_00aa: brfalse.s IL_00ba
.line 95,95 : 17,18 ''
IL_00ac: nop
.line 97,97 : 21,36 ''
IL_00ad: ldc.r8 -nan(ind)
IL_00b6: stloc.0
.line 98,98 : 17,18 ''
IL_00b7: nop
IL_00b8: br.s IL_00ee
.line 100,100 : 17,18 ''
IL_00ba: nop
.line 101,101 : 21,36 ''
IL_00bb: ldloc.1
IL_00bc: ldc.i4 0x3fff
IL_00c1: sub
IL_00c2: stloc.1
.line 102,102 : 21,69 ''
IL_00c3: ldarg.0
IL_00c4: ldarg.0
IL_00c5: ldloc.2
IL_00c6: call instance float64 CSCore.Codecs.AIFF.AiffBinaryReader::UnsignedToFloat(uint64)
IL_00cb: ldloc.1
IL_00cc: ldc.i4.s 31
IL_00ce: sub
IL_00cf: dup
IL_00d0: stloc.1
IL_00d1: call instance float64 CSCore.Codecs.AIFF.AiffBinaryReader::ldexp(float64,
int32)
IL_00d6: stloc.0
.line 103,103 : 21,70 ''
IL_00d7: ldloc.0
IL_00d8: ldarg.0
IL_00d9: ldarg.0
IL_00da: ldloc.3
IL_00db: call instance float64 CSCore.Codecs.AIFF.AiffBinaryReader::UnsignedToFloat(uint64)
IL_00e0: ldloc.1
IL_00e1: ldc.i4.s 32
IL_00e3: sub
IL_00e4: dup
IL_00e5: stloc.1
IL_00e6: call instance float64 CSCore.Codecs.AIFF.AiffBinaryReader::ldexp(float64,
int32)
IL_00eb: add
IL_00ec: stloc.0
.line 104,104 : 17,18 ''
IL_00ed: nop
.line 105,105 : 13,14 ''
IL_00ee: nop
.line 107,107 : 13,43 ''
IL_00ef: ldarg.1
IL_00f0: ldc.i4.0
IL_00f1: ldelem.u1
IL_00f2: ldc.i4 0x80
IL_00f7: and
IL_00f8: ldc.i4 0x80
IL_00fd: ceq
IL_00ff: stloc.s V_6
.line 16707566,16707566 : 0,0 ''
IL_0101: ldloc.s V_6
IL_0103: brfalse.s IL_010b
.line 108,108 : 17,27 ''
IL_0105: ldloc.0
IL_0106: neg
IL_0107: stloc.s V_7
IL_0109: br.s IL_0110
.line 109,109 : 13,22 ''
IL_010b: ldloc.0
IL_010c: stloc.s V_7
IL_010e: br.s IL_0110
.line 110,110 : 9,10 ''
IL_0110: ldloc.s V_7
IL_0112: ret
} // end of method AiffBinaryReader::ConvertFromIeeeExtended
more precisely, the line with -nan(ind):
.line 95,95 : 17,18 ''
IL_00ac: nop
.line 97,97 : 21,36 ''
IL_00ad: ldc.r8 -nan(ind)
IL_00b6: stloc.0
.line 98,98 : 17,18 ''
IL_00b7: nop
IL_00b8: br.s IL_00ee
not sure what to do now, any idea? thank you.
This is an error in Visual studio, reported but unsolved. To overcome it, I changed the source of AiffBinaryReader in Codecs.AIFF.
becomes
Not exactly INFINITY but surely a large number, enough to make CsCore work and VS to compile it! success.