www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DMD 2.090.1: SIGILL, Illegal instruction on (ahem) intel Pentium III

reply kdevel <kdevel vogtner.de> writes:
```test.d
void main ()
{
    int [] v = new int [10];
}
```

$ [...]linux/bin32/dmd test
$ gdb test
[...]
(gdb) r
[...]
Program received signal SIGILL, Illegal instruction.
0x0809ad14 in 
_D2gc4impl12conservativeQw3Gcx10smallAllocMFNbkKkkxC8TypeInfoZPv 
()
[...]
(gdb) disass
[...]
0x0809ad14 
<_D2gc4impl12conservativeQw3Gcx10smallAllocMFNbkKkkxC8TypeInfoZPv+172>:	movsd 
-0x58(%ebp),%xmm0

Does this exception relate to [1] and shall I file a bug or do I 
have to decommission my PIII?

Stefan

[1] https://dlang.org/changelog/2.087.0.html#xmm-linux-changelog
Feb 26 2020
parent reply Seb <seb wilzba.ch> writes:
On Thursday, 27 February 2020 at 00:36:49 UTC, kdevel wrote:
 ```test.d
 void main ()
 {
    int [] v = new int [10];
 }
 ```

 $ [...]linux/bin32/dmd test
 $ gdb test
 [...]
 (gdb) r
 [...]
 Program received signal SIGILL, Illegal instruction.
 0x0809ad14 in 
 _D2gc4impl12conservativeQw3Gcx10smallAllocMFNbkKkkxC8TypeInfoZPv ()
 [...]
 (gdb) disass
 [...]
 0x0809ad14 
 <_D2gc4impl12conservativeQw3Gcx10smallAllocMFNbkKkkxC8TypeInfoZPv+172>:	movsd 
-0x58(%ebp),%xmm0

 Does this exception relate to [1] and shall I file a bug or do 
 I have to decommission my PIII?
I think so. Have you tried: 1) LDC on your machine? 2) the DMD version before this change?
Feb 26 2020
parent reply kdevel <kdevel vogtner.de> writes:
On Thursday, 27 February 2020 at 07:44:57 UTC, Seb wrote:
 On Thursday, 27 February 2020 at 00:36:49 UTC, kdevel wrote:
[...]
 Program received signal SIGILL, Illegal instruction.
[...]
 Does this exception relate to [1] and shall I file a bug or do 
 I have to decommission my PIII?
[...]
 I think so.
File a bug report?
 Have you tried:
 1) LDC on your machine?
Not yet.
 2) the DMD version before this change?
2.086.1 good 2.087.0 bad
Feb 27 2020
parent reply Rainer Schuetze <r.sagitario gmx.de> writes:
On 27/02/2020 11:30, kdevel wrote:
 On Thursday, 27 February 2020 at 07:44:57 UTC, Seb wrote:
 On Thursday, 27 February 2020 at 00:36:49 UTC, kdevel wrote:
[...]
 Program received signal SIGILL, Illegal instruction.
[...]
 Does this exception relate to [1] and shall I file a bug or do I have
 to decommission my PIII?
[...]
 I think so.
File a bug report?
 Have you tried:
 1) LDC on your machine?
Not yet.
 2) the DMD version before this change?
2.086.1 good 2.087.0 bad
From the 2.087 changelog: "32 Bit Linux now uses XMM registers for float and double rather than the x87. This should substantially speed up routine float and double processing. SIMD vector operations, however, are still not support on 32 bit Linux code because of issues with 16 byte stack alignment. This means that generated code will no longer work on older x86 processors that do not have XMM registers. If this is an issue, please file a bug report."
Feb 27 2020
next sibling parent reply Johan <j j.nl> writes:
On Thursday, 27 February 2020 at 18:07:40 UTC, Rainer Schuetze 
wrote:
 On 27/02/2020 11:30, kdevel wrote:
 On Thursday, 27 February 2020 at 07:44:57 UTC, Seb wrote:
 On Thursday, 27 February 2020 at 00:36:49 UTC, kdevel wrote:
[...]
 Program received signal SIGILL, Illegal instruction.
[...]
 Does this exception relate to [1] and shall I file a bug or 
 do I have to decommission my PIII?
[...]
 I think so.
File a bug report?
 Have you tried:
 1) LDC on your machine?
Not yet.
 2) the DMD version before this change?
2.086.1 good 2.087.0 bad
From the 2.087 changelog: "32 Bit Linux now uses XMM registers for float and double rather than the x87. This should substantially speed up routine float and double processing. SIMD vector operations, however, are still not support on 32 bit Linux code because of issues with 16 byte stack alignment. This means that generated code will no longer work on older x86 processors that do not have XMM registers. If this is an issue, please file a bug report."
Detail: the problem is not the absence of XMM (Pentium3 has SSE, hence has XMM registers), but that DMD is emitting an SSE2 instruction (movsd). LDC will work fine if told what processor you have: https://d.godbolt.org/z/5hrzgm -m32 -mcpu=pentium3 (-mcpu=native should also work). cheers, Johan
Feb 27 2020
parent reply kdevel <kdevel vogtner.de> writes:
On Thursday, 27 February 2020 at 19:24:39 UTC, Johan wrote:
 LDC will work fine if told what processor you have: 
 https://d.godbolt.org/z/5hrzgm
 -m32 -mcpu=pentium3   (-mcpu=native should also work).
When I "cross compile" on an AMD 64 Bit machine for pentium3 [AMD 64 bit] $ ldc2 -m32 -mcpu=pentium3 --linker=bfd vec.d and execute the binary on the Pentium-III I get [PIII] $ gdb ./vec [...] This GDB was configured as "i586-suse-linux". For bug reporting instructions, please see: <http://bugs.opensuse.org/>... Dwarf Error: wrong version in compilation unit header (is 4, should be 2) [in module /[...]/tmp/vec] (gdb) r Starting program: /[...]/tmp/vec (no debugging symbols found) (no debugging symbols found) [Thread debugging using libthread_db enabled] Program received signal SIGILL, Illegal instruction. 0x08051baa in ?? () Disassembly on the AMD 64 it reveals that ldc also emits the movds instructions: 0x08051ba2 <+434>: call 0x804f680 <_D2rt5minfo11ModuleGroup6__ctorMFNbNcNiAyPS6object10ModuleInfoZSQCkQCkQCh> 0x08051ba7 <+439>: sub $0x8,%esp 0x08051baa <+442>: movsd 0x30(%esp),%xmm0 0x08051bb0 <+448>: movsd 0x38(%esp),%xmm1
Mar 11 2020
next sibling parent kinke <noone nowhere.com> writes:
On Wednesday, 11 March 2020 at 22:18:04 UTC, kdevel wrote:
 Disassembly on the AMD 64 it reveals that ldc also emits the 
 movds instructions:

    0x08051ba2 <+434>:	call   0x804f680 
 <_D2rt5minfo11ModuleGroup6__ctorMFNbNcNiAyPS6object10ModuleInfoZSQCkQCkQCh>
    0x08051ba7 <+439>:	sub    $0x8,%esp
    0x08051baa <+442>:	movsd  0x30(%esp),%xmm0
    0x08051bb0 <+448>:	movsd  0x38(%esp),%xmm1
That's in druntime, not your cross-compiled code; you'll need to cross-compile druntime and Phobos first, see https://wiki.dlang.org/Building_LDC_runtime_libraries.
Mar 11 2020
prev sibling parent Johan <j j.nl> writes:
On Wednesday, 11 March 2020 at 22:18:04 UTC, kdevel wrote:
 On Thursday, 27 February 2020 at 19:24:39 UTC, Johan wrote:
 LDC will work fine if told what processor you have: 
 https://d.godbolt.org/z/5hrzgm
 -m32 -mcpu=pentium3   (-mcpu=native should also work).
When I "cross compile" on an AMD 64 Bit machine for pentium3 [AMD 64 bit] $ ldc2 -m32 -mcpu=pentium3 --linker=bfd vec.d
If you run `ldc2 -m32 -mcpu=pentium3 --linker=bfd vec.d --output-s` you should get file `vec.s` with the assembly that LDC generated. I'd be _very_ surprised if it contained SSE2 instructions (i.e. the "movsd xmm0" instruction). Are you sure that the druntime you are linking with was also built with -m32 -mcpu=pentium3? Thanks, Johan
Mar 11 2020
prev sibling parent kdevel <kdevel vogtner.de> writes:
On Thursday, 27 February 2020 at 18:07:40 UTC, Rainer Schuetze 
wrote:
 "If this is an issue, please file a bug report."
Issue 20621 - Since DMD 2.087.0: 32 Bit Linux now uses XMM registers: SIGILL, Illegal instruction on intel Pentium III
Feb 27 2020