mono build error with swp instruction
I ran into an interesting build error this morning that might be worth documenting ...
When building mono with the latest toolchains built with OE, I get:
/tmp/ccYsXwlg.s:3067: Error: selected processor does not support `swp r2,r0,[r4]'/tmp/ccYsXwlg.s:3161: Error: selected processor does not support `swp r2,r0,[r4]'/tmp/ccYsXwlg.s:3272: Error: selected processor does not support `swp r3,r4,[r5]'
In the libgc code, there is the following:
# ifdef ARM32
inline static int GC_test_and_set(volatile unsigned int *addr) {
int oldval;
/* SWP on ARM is very similar to XCHG on x86. Doesn't lock the
* bus because there are no SMP ARM machines. If/when there are,
* this code will likely need to be updated. */
/* See linuxthreads/sysdeps/arm/pt-machine.h in glibc-2.1 */
__asm__ __volatile__("swp %0, %1, [%2]"
: "=&r"(oldval)
: "r"(1), "r"(addr)
: "memory");
return oldval;
}The solution was to set ARM_INSTRUCTION_SET = "arm" in the mono recipe.
Thanks,
Cliff
Signature · 3 lines
======================= Cliff Brake http://bec-systems.com
Quoted 2 lines · Cliff Brake
I ran into an interesting build error this morning that might be worth documenting ...
Already known:
Quoted 31 lines
When building mono with the latest toolchains built with OE, I get:
/tmp/ccYsXwlg.s:3067: Error: selected processor does not support `swp r2,r0,[r4]'/tmp/ccYsXwlg.s:3161: Error: selected processor does not support `swp r2,r0,[r4]'/tmp/ccYsXwlg.s:3272: Error: selected processor does not support `swp r3,r4,[r5]'In the libgc code, there is the following:
# ifdef ARM32
inline static int GC_test_and_set(volatile unsigned int *addr) { int oldval; /* SWP on ARM is very similar to XCHG on x86. Doesn't lock the * bus because there are no SMP ARM machines. If/when there are, * this code will likely need to be updated. */ /* See linuxthreads/sysdeps/arm/pt-machine.h in glibc-2.1 */ __asm__ __volatile__("swp %0, %1, [%2]" : "=&r"(oldval) : "r"(1), "r"(addr) : "memory"); return oldval; }The solution was to set
ARM_INSTRUCTION_SET= "arm" in the mono recipe.Thanks,
Cliff
Quoted 28 lines · Cliff Brake
I ran into an interesting build error this morning that might be worth documenting ...
When building mono with the latest toolchains built with OE, I get:
/tmp/ccYsXwlg.s:3067: Error: selected processor does not support `swp r2,r0,[r4]'/tmp/ccYsXwlg.s:3161: Error: selected processor does not support `swp r2,r0,[r4]'/tmp/ccYsXwlg.s:3272: Error: selected processor does not support `swp r3,r4,[r5]'In the libgc code, there is the following:
# ifdef ARM32
inline static int GC_test_and_set(volatile unsigned int *addr) { int oldval; /* SWP on ARM is very similar to XCHG on x86. Doesn't lock the * bus because there are no SMP ARM machines. If/when there are, * this code will likely need to be updated. */ /* See linuxthreads/sysdeps/arm/pt-machine.h in glibc-2.1 */ __asm__ __volatile__("swp %0, %1, [%2]" : "=&r"(oldval) : "r"(1), "r"(addr) : "memory"); return oldval; }
Quoted 1 line
The solution was to set
ARM_INSTRUCTION_SET= "arm" in the mono recipe.
On armv6 and higher, you want to use LDREX and STREX instead of SWP. This makes your code SMP ready (and a few other benefits I suspect) :)
Philip
Quoted 4 lines
Thanks,
Cliff