Cross compiling from arm v4t


I successfully cross compile rust programs for arm v5te (arm926ej-s) . I followed the procedure described here . I need to change the file to replace +v6 to +v5te otherwise invalid instruction was generated at runtime. (I’m using rust head version).

I would like to do the same operation for arm v4t (arm7tdmi). I adapted the source to set target option feature to +v4t. No problem to execute a basic program (hello world) on the target but when I execute a more complicated program (e.g. iron or rustless web server) I receive an illegal instruction.

gdb disassembling the core dump file gives :

   0x401e41dc <+0>:	push	{r11, lr}
   0x401e41e0 <+4>:	mov	r11, sp
   0x401e41e4 <+8>:	sub	sp, sp, #8
   0x401e41e8 <+12>:	ldr	r0, [r0]
   0x401e41ec <+16>:	str	r0, [sp, #4]
   0x401e41f0 <+20>:	mov	r0, r1
   0x401e41f4 <+24>:	ldr	r1, [sp, #4]
=> 0x401e41f8 <+28>:	blx	r1
   0x401e41fc <+32>:	and	r0, r0, #1
   0x401e4200 <+36>:	and	r0, r0, #1
   0x401e4204 <+40>:	mov	sp, r11
   0x401e4208 <+44>:	pop	{r11, lr}
   0x401e420c <+48>:	bx	lr

blx instruction is available from ARM architecture v5 and above…

Any idea why/where is this instruction generated ?

Many thanks



I finally found where this instruction was generated.

Generated by llvm : ARMFastISel.cpp UseReg variable is true causing ARMSelectCallOp function to set a BLX instruction that is not supported on armv4… :frowning:

I think that llvm is supporting armv4 architecture so I don’t why this problem happens. Any idea why, how to solve this ?

Concerning rust is there any restriction to use it on armv4 ? (excepted this possible bug).

Currently due to a problem I mentioned before (armv6 target architecture defined by default) It is not possible to cross compile rust “as-is” on armv4/5. Do you have plan to change this and let this parameter configurable via configure script by example ?

We have a lot of embedded devices with armv4 & armv5 that are running very old apps developed in C. We are thinking to re-develop these applications and we will very happy to use rust but I must be sure first that rust runs on these “old” architectures and will be compatible with them in the future.




I think LLVM is supporting ARMv4 architecture so I don’t know why this problem happens. Any idea why and how to solve this?

This seems to be an LLVM bug. You can file a bug at LLVM Bugzilla.

While doing that… LLVM has two code generators, fast one and normal one. It seems to me that only fast one has this bug. You can disable fast one with -C llvm-args=-fast-isel=0.