From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: dsmich@roadrunner.com Newsgroups: gmane.lisp.guile.devel Subject: Cross compiled guile 3.0.2 "Illegal instruction" on 32bit arm. Date: Wed, 01 Apr 2020 21:38:32 +0000 Message-ID: <807211349eb4ad0e279a6a18a7b703749852722b@webmail> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="=_01ee77635a27ebb87e6ade4cc430e951" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="78027"; mail-complaints-to="usenet@ciao.gmane.io" To: "'guile-devel@gnu.org'" Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Apr 01 23:38:49 2020 Return-path: Envelope-to: guile-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJl4T-000KBP-3G for guile-devel@m.gmane-mx.org; Wed, 01 Apr 2020 23:38:49 +0200 Original-Received: from localhost ([::1]:37758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJl4R-0005I1-T4 for guile-devel@m.gmane-mx.org; Wed, 01 Apr 2020 17:38:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:54963) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJl4H-0005Hd-3c for guile-devel@gnu.org; Wed, 01 Apr 2020 17:38:38 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJl4F-0001Jl-AS for guile-devel@gnu.org; Wed, 01 Apr 2020 17:38:36 -0400 Original-Received: from p-impout005aa.msg.pkvw.co.charter.net ([47.43.26.136]:58066 helo=p-impout001.msg.pkvw.co.charter.net) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jJl4F-0001Fi-3R for guile-devel@gnu.org; Wed, 01 Apr 2020 17:38:35 -0400 Original-Received: from localhost ([34.233.51.36]) by cmsmtp with ESMTP id Jl4CjBfC6dRE0Jl4CjCQ3c; Wed, 01 Apr 2020 21:38:33 +0000 X-Authority-Analysis: v=2.3 cv=INN89TnG c=1 sm=1 tr=0 a=TrnfHZhGi+cGSPqA0dbxTQ==:117 a=TrnfHZhGi+cGSPqA0dbxTQ==:17 a=dSg6v7tjMxUA:10 a=pACV-hGOPzdj9A3WIfUA:9 a=QEXdDO2ut3YA:10 a=AMzK0a3qHjxbrSBORhgA:9 a=_zejYUfJnLq_jBM7:21 a=_W_S_7VecoQA:10 a=pHzHmUro8NiASowvMSCR:22 a=nt3jZW36AmriUCFCBwmW:22 X-Mailer: Atmail X-Originating-IP: [65.185.85.154] X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal X-CMAE-Envelope: MS4wfOjLku0PY3xaYx6y1yZxj3/dASq4AMq+cjWGedYow0DbPFpsii4oV2DCnYP9KDxRNJjCuHA9Ut+60g6Xkr/sEmbc/I/CeeAexFCAAENaQDkpksrXPPcC NCVLrV9B7W1a3sUgs3v04ARh4YzQ5ugeB04XiB75D7oTUsglnINWRSEA X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 47.43.26.136 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20481 Archived-At: --=_01ee77635a27ebb87e6ade4cc430e951 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I'm attempting to use buildroot to cross compile guile 3.0.2 for 32bit= =0Aarm (rpi3).=0A=0ANote that guile runs fine with the jit disabled by= =0AGUILE_JIT_THRESHOLD=3D-1=0A=0AWhen guile starts, I get an "Illegal in= struction".=0A=0A# GUILE_JIT_LOG=3D3 guile=0Ajit: allocated code arena,= 0x74f43000-0x74f83000=0Ajit: mcode: 0x74f43000,+44=0Ajit: mcode: 0x74f4= 3030,+56=0Ajit: mcode: 0x74f43070,+8=0Ajit: vcode: start=3D0xa2261c,+6 e= ntry=3D+0=0Ajit: Instruction first seen at vcode 0xa2261c: instrument-en= try=0Ajit: Instruction at vcode 0xa2261c: instrument-entry=0Ajit: Instru= ction first seen at vcode 0xa22624: assert-nargs-ee=0Ajit: Instruction a= t vcode 0xa22624: assert-nargs-ee=0Ajit: Instruction first seen at vcode= 0xa22628: subr-call=0Ajit: Instruction at vcode 0xa22628: subr-call=0Aj= it: Instruction first seen at vcode 0xa2262c: handle-interrupts=0Ajit: I= nstruction at vcode 0xa2262c: handle-interrupts=0Ajit: Instruction first= seen at vcode 0xa22630: return-values=0Ajit: Instruction at vcode 0xa22= 630: return-values=0Ajit: mcode: 0x74f43080,+200=0Ajit: created /tmp/per= f-287.map=0Ajit: entering mcode: 0x74f43080=0AIllegal instruction=0A=0AI= got cross-gdb working. Here is another run, with the disassembled=0Acod= e=0A=0Ajit: mcode: 0x74edb080,+200=0Ajit: created /tmp/perf-252.map=0Aji= t: entering mcode: 0x74edb080=0A=0ADump of assembler code from 0x74edb08= 0 to 0x74edb148:=0A 0x74edb080: 0d 1a subs r5, r1, r0=0A 0x74edb082: 20= 2d cmp r5, #32=0A 0x74edb084: 40 f0 35 80 bne.w 0x74edb0f2=0A=0A 0x74ed= b088: 4e f2 28 65 movw r5, #58920 ; 0xe628=0A 0x74edb08c: c0 f2 cb 05 mo= vt r5, #203 ; 0xcb=0A 0x74edb090: 65 60 str r5, [r4, #4]=0A 0x74edb092:= d0 f8 10 c0 ldr.w r12, [r0, #16]=0A 0x74edb096: 81 68 ldr r1, [r0, #8]= =0A 0x74edb098: 02 68 ldr r2, [r0, #0]=0A 0x74edb09a: 60 46 mov r0, r12= =0A 0x74edb09c: 00 f0 48 e8 blx 0x74edb130 ; 0x74edb130: 00 4f ldr r7,= =0A[pc, #0] ; (0x74edb134)=0A 0x74edb132: bf 46 mov pc, r7 ; pc --=_01ee77635a27ebb87e6ade4cc430e951 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I'm attempting to use buildroot to cross compile guile 3.0.2= for 32bit arm (rpi3).

Note that guile runs fine with the jit dis= abled by GUILE_JIT_THRESHOLD=3D-1

When guile starts, I get an "Il= legal instruction".

# GUILE_JIT_LOG=3D3 guile
jit: allocated c= ode arena, 0x74f43000-0x74f83000
jit: mcode: 0x74f43000,+44
jit: m= code: 0x74f43030,+56
jit: mcode: 0x74f43070,+8
jit: vcode: start= =3D0xa2261c,+6 entry=3D+0
jit: Instruction first seen at vcode 0xa226= 1c: instrument-entry
jit: Instruction at vcode 0xa2261c: instrument-e= ntry
jit: Instruction first seen at vcode 0xa22624: assert-nargs-eejit: Instruction at vcode 0xa22624: assert-nargs-ee
jit: Instructio= n first seen at vcode 0xa22628: subr-call
jit: Instruction at vcode 0= xa22628: subr-call
jit: Instruction first seen at vcode 0xa2262c: han= dle-interrupts
jit: Instruction at vcode 0xa2262c: handle-interrupts<= br>jit: Instruction first seen at vcode 0xa22630: return-values
jit:= Instruction at vcode 0xa22630: return-values
jit: mcode: 0x74f43080,= +200
jit: created /tmp/perf-287.map
jit: entering mcode: 0x74f4308= 0
Illegal instruction

I got cross-gdb working.  Here is a= nother run, with the disassembled code

jit: mcode: 0x74edb080,+20= 0
jit: created /tmp/perf-252.map
jit: entering mcode: 0x74edb080
Dump of assembler code from 0x74edb080 to 0x74edb148:
 &nb= sp; 0x74edb080:  0d 1a       &nb= sp;   subs    r5, r1, r0
   0x74ed= b082:  20 2d         &= nbsp; cmp     r5, #32
   0x74edb084:&nb= sp; 40 f0 35 80     bne.w   0x74edb0f2
=
   0x74edb088:  4e f2 28 65     m= ovw    r5, #58920      ; 0xe628<= br>   0x74edb08c:  c0 f2 cb 05     mo= vt    r5, #203       = ; 0xcb
   0x74edb090:  65 60    &= nbsp;      str     r5, [r4,= #4]
   0x74edb092:  d0 f8 10 c0   &nbs= p; ldr.w   r12, [r0, #16]
   0x74edb096:  81= 68           ldr = ;    r1, [r0, #8]
   0x74edb098:  02 68=            ldr &n= bsp;   r2, [r0, #0]
   0x74edb09a:  60 46&nb= sp;          mov  = ;   r0, r12
   0x74edb09c:  00 f0 48 e8 = ;    blx     0x74edb130   ;= <- lr reg indicates failing code called from here.

 &nbs= p; 0x74edb0a0:  06 46       &nbs= p;   mov     r6, r0
   0x74ed= b0a2:  16 f0 06 0f     tst.w   r6, #6=
   0x74edb0a6:  40 f0 07 80     b= ne.w   0x74edb0b8

   0x74edb0aa:  56 f8= 00 5e     ldrt    r5, [r6]
 =   0x74edb0ae:  05 f0 7f 05     and.w =   r5, r5, #127    ; 0x7f
   0x74edb0b2:=   3f 2d          = cmp     r5, #63 ; 0x3f
   0x74edb0b4:&= nbsp; 00 f0 25 80     beq.w   0x74edb102  
   0x74edb0b8:  e1 68   = ;        ldr    = r1, [r4, #12]
   0x74edb0ba:  a1 f1 08 00  =    sub.w   r0, r1, #8
   0x74edb0be:&nb= sp; a0 60           st= r     r0, [r4, #8]
   0x74edb0c0: = 40 f8 00 6e     strt    r6, [r0]
=
   0x74edb0c4:  04 f1 48 05     a= dd.w   r5, r4, #72     ; 0x48
 &nb= sp; 0x74edb0c8:  bf f3 5b 8f     dmb  = ;   ish
   0x74edb0cc:  55 f8 00 5e &nb= sp;   ldrt    r5, [r5]
   0x74edb0= d0:  bf f3 5b 8f     dmb    = ; ish
   0x74edb0d4:  40 f2 04 3c   &nb= sp; movw    r12, #772      = ; 0x304
   0x74edb0d8:  b5 eb 0c 0f   =   cmp.w   r5, r12
   0x74edb0dc:  40 f0= 19 80     bne.w   0x74edb112

 = ;  0x74edb0e0:  e5 68       = ;    ldr     r5, [r4, #12]
 &= nbsp; 0x74edb0e2:  29 69       &= nbsp;   ldr     r1, [r5, #16]
 &nb= sp; 0x74edb0e4:  c9 00       &nb= sp;   lsls    r1, r1, #3
   0x74ed= b0e6:  69 18         &= nbsp; adds    r1, r5, r1
   0x74edb0e8: = ; e1 60           str&= nbsp;    r1, [r4, #12]
   0x74edb0ea: = 55 f8 00 ee     ldrt    lr, [r5]
=    0x74edb0ee:  70 47      =      bx      lr

&nbs= p;  0x74edb0f0:  00 be      &nbs= p;    bkpt    0x0000

   0= x74edb0f2:  4e f2 24 65     movw  &nb= sp; r5, #58916      ; 0xe624
   0x= 74edb0f6:  c0 f2 cb 05     movt  &nbs= p; r5, #203        ; 0xcb
 &n= bsp; 0x74edb0fa:  65 60       &n= bsp;   str     r5, [r4, #4]
  = ; 0x74edb0fc:  20 46        = ;   mov     r0, r4
   0x74edb= 0fe:  00 f0 1b e8        &n= bsp;            ;= <UNDEFINED> instruction: 0xf000e81b

   0x74edb10= 2:  20 46         &nbs= p; mov     r0, r4
   0x74edb104: = 31 46           mov&n= bsp;    r1, r6
   0x74edb106:  00 f0 1b= e8           &nb= sp;         ; <UNDEFINED>= instruction: 0xf000e81b
   0x74edb10a:  a0 68 &n= bsp;         ldr  &nbs= p;  r0, [r4, #8]
   0x74edb10c:  e1 68  = ;         ldr   &= nbsp; r1, [r4, #12]
   0x74edb10e:  ff f7 d9 bf &= nbsp;   b.w     0x74edb0c4

 &n= bsp; 0x74edb112:  e5 6c       &n= bsp;   ldr     r5, [r4, #76]   ;= 0x4c
   0x74edb114:  00 2d    &nb= sp;      cmp     r5, #0
=    0x74edb116:  7f f4 e3 af     bne.w=    0x74edb0e0

   0x74edb11a:  4e f2 2c 6= 5     movw    r5, #58924  &= nbsp;   ; 0xe62c
   0x74edb11e:  c0 f2 cb 05=      movt    r5, #203  &nbs= p;     ; 0xcb
   0x74edb122:  65 6= 0           str &= nbsp;   r5, [r4, #4]
   0x74edb124:  ff f7 8= 4 ff     bl      0x74edb030=

   0x74edb128:  e1 68    &nbs= p;      ldr     r1, [r4, #1= 2]
   0x74edb12a:  ff f7 cb bf    = b.w     0x74edb0c4

   0x74edb12e:&= nbsp; 00 be          = bkpt    0x0000

;; Here is the pc at Illegal instr= uction time.
=3D> 0x74edb130:  00 4f    &= nbsp;      ldr     r7, [pc,= #0]    ; (0x74edb134)
   0x74edb132: = bf 46           mov&n= bsp;    pc, r7       &= nbsp;  ; pc <- 0x76e9_8d18
   0x74edb134:  18= 8d e9 76     ; data 0x76e9_8d18

  = 0x74edb138:  00 4f        =    ldr     r7, [pc, #0]   = ; (0x74edb13c)
   0x74edb13a:  bf 46   = ;        mov    = pc, r7          ; pc <-= 0x76e8_8e48
   0x74edb13c:  48 8e e8 76  &n= bsp;  ; data 0x76e8_8e48

   0x74edb140:  00 4= f           ldr &= nbsp;   r7, [pc, #0]    ; (0x74edb144)
 = ;  0x74edb142:  bf 46       = ;    mov     pc, r7   =        ; pc <- 0x76e_e3758
 &nb= sp; 0x74edb144:  58 37 ee 76     ;  data 0= x76ee_3758


(gdb) info registers
r0    =          0x75106880  &= nbsp;       1964009600
r1  &n= bsp;          0x750f2930&nb= sp;         1963927856
r2&nbs= p;            0x7= 4f7b7a8          1962391464=
r3           =   0x74edb001         = 1961734145
r4         &= nbsp;   0x76931e00       &n= bsp;  1989352960
r5       &nb= sp;     0xcbe628      =       13362728
r6    &nb= sp;        0x76931e00  &nbs= p;       1989352960
r7   = ;          0x74edb080 =          1961734272
r8 &= nbsp;           0x76f6= 1ec0          1995841216r9           &nb= sp; 0xcbe61c          =   13362716
r10        &n= bsp;   0x4        &nbs= p;        4
r11   &= nbsp;        0x76f2c000  &n= bsp;       1995620352
r12  &n= bsp;         0x75106880 &nb= sp;        1964009600
sp &nbs= p;           0x7ef6557= 8          0x7ef65578
lr=             = 0x74edb0a1          196173= 4305
pc          &n= bsp;  0x74edb130        &nb= sp; 0x74edb130
cpsr        &n= bsp;  0x60000010        &nb= sp; 1610612752
fpscr        &= nbsp; 0x0          &nb= sp;      0


Now, I'm not very familia= r with arm and arm-thumb, but that code *seems* to be right to me.
Lo= oks like it was generated by emit_veneer() in libguile/lightening/lighte= ning/arm-cpu.c

So what could be wrong here?  How could this= code generate an illegal instruction error?

Where do I go from h= ere?

Thanks,
    -Dale

--=_01ee77635a27ebb87e6ade4cc430e951--