IoLanguage / io

Io programming language. Inspired by Self, Smalltalk and LISP.
http://iolanguage.org
Other
2.66k stars 298 forks source link

ARM compilation fails: #226

Open limburgher opened 12 years ago

limburgher commented 12 years ago

[ 11%] Building C object libs/coroutine/CMakeFiles/coroutine.dir/source/context.c.o /home/limb/fedora/git/Io-language/stevedekorte-io-23afbcc/libs/coroutine/source/context.c: In function 'makecontext': /home/limb/fedora/git/Io-language/stevedekorte-io-23afbcc/libs/coroutine/source/context.c:104:18: error: 'mcontext_t' has no member named 'gregs' /home/limb/fedora/git/Io-language/stevedekorte-io-23afbcc/libs/coroutine/source/context.c:106:17: error: 'mcontext_t' has no member named 'gregs' /home/limb/fedora/git/Io-language/stevedekorte-io-23afbcc/libs/coroutine/source/context.c:107:17: error: 'mcontext_t' has no member named 'gregs' make[2]: * [libs/coroutine/CMakeFiles/coroutine.dir/source/context.c.o] Error 1 make[1]: * [libs/coroutine/CMakeFiles/coroutine.dir/all] Error 2

Looks like a libs/coroutine/source/arm-ucontext.h file is needed. I'm using Fedora 17 on a raspberry pi, so I might be able to assist in creating this, but I'm not sure how to do it.

https://bugzilla.redhat.com/show_bug.cgi?id=837972

Thanks, Jon, Fedora Io-language maintainer.

limburgher commented 12 years ago

This gets a bit farther:

--- libs/coroutine/source/context.c~    2011-09-12 17:14:12.000000000 -0500
+++ libs/coroutine/source/context.c     2012-09-18 08:39:08.443336951 -0500
@@ -97,14 +97,17 @@
 {
        int i, *sp;
        va_list arg;
-       
        sp = (int*)uc->uc_stack.ss_sp+uc->uc_stack.ss_size/4;
        va_start(arg, argc);
-       for(i=0; i<4 && i<argc; i++)
-               uc->uc_mcontext.gregs[i] = va_arg(arg, uint);
+       
+       if(argc-- > 0) uc->uc_mcontext.arm_r0 = va_arg(arg, uint);
+       if(argc-- > 0) uc->uc_mcontext.arm_r1 = va_arg(arg, uint);
+       if(argc-- > 0) uc->uc_mcontext.arm_r2 = va_arg(arg, uint);
+       if(argc-- > 0) uc->uc_mcontext.arm_r3 = va_arg(arg, uint);
+       
        va_end(arg);
-       uc->uc_mcontext.gregs[13] = (uint)sp;
-       uc->uc_mcontext.gregs[14] = (uint)fn;
+       uc->uc_mcontext.arm_sp = (uint)sp;
+       uc->uc_mcontext.arm_lr = (uint)fn;
 }
 #endif
limburgher commented 12 years ago

Add this and it builds.

--- libs/coroutine/source/taskimpl.h~   2011-09-12 17:14:12.000000000 -0500
+++ libs/coroutine/source/taskimpl.h    2012-09-18 09:54:37.832740691 -0500
@@ -143,8 +143,8 @@
 #if defined(__arm__)
 int getmcontext(mcontext_t*);
 void setmcontext(const mcontext_t*);
-#define        setcontext(u)   setmcontext(&(u)->uc_mcontext)
-#define        getcontext(u)   getmcontext(&(u)->uc_mcontext)
+#define    setcontext(u)    setmcontext((void *)&((u)->uc_mcontext.arm_r0))
+#define    getcontext(u)    getmcontext((void *)&((u)->uc_mcontext.arm_r0))
 #endif

 /*
limburgher commented 12 years ago

Inspired by: https://github.com/zedshaw/mongrel2/commit/6189aa581358913b00dc7ba7a668bc45e4238aad http://bnpcs.blogspot.com/2010_12_01_archive.html

gatesphere commented 12 years ago

Thanks for these patches. Managed to get Io to build on the latest Raspian Wheezy with this.

If you make a pull request, Steve will probably pull it into master.

limburgher commented 12 years ago

On Thu, Sep 20, 2012 at 8:11 PM, Jacob Peck notifications@github.comwrote:

Thanks for these patches. Managed to get Io to build on the latest Raspian Wheezy with this.

If you make a pull request, Steve will probably pull it into master.

You're very welcome! Pull request created.

-J

— Reply to this email directly or view it on GitHubhttps://github.com/stevedekorte/io/issues/226#issuecomment-8750922.

http://cecinestpasunefromage.wordpress.com/

in your fear, seek only peace in your fear, seek only love

-d. bowie

scooter-dangle commented 11 years ago

The current version of master is not compiling for me on ARM running Ubuntu 12.04.

Everything runs without error through the first 55% of compilation. The only warnings I get are the following:

/home/ubuntu/io/stevedekorte-io-8956a60/libs/basekit/source/UArray_math.c:30:3: warning: #warning Uncomment the IO_USE_SIMD define to turn on SIMD acceleration [-Wcpp]
In file included from /home/ubuntu/io/stevedekorte-io-8956a60/libs/basekit/source/UArray_math.c:34:0:
/home/ubuntu/io/stevedekorte-io-8956a60/libs/basekit/source/simd_cph/include/simd_cp_emu.h:81:2: warning: #warning "using SIMD Emulation" [-Wcpp]
/home/ubuntu/io/stevedekorte-io-8956a60/libs/basekit/source/UArray_math.c:30:3: warning: #warning Uncomment the IO_USE_SIMD define to turn on SIMD acceleration [-Wcpp]
In file included from /home/ubuntu/io/stevedekorte-io-8956a60/libs/basekit/source/UArray_math.c:34:0:
/home/ubuntu/io/stevedekorte-io-8956a60/libs/basekit/source/simd_cph/include/simd_cp_emu.h:81:2: warning: #warning "using SIMD Emulation" [-Wcpp]

And then here's the last chunk of stdout before segmentation fault:

This program built for arm-unknown-linux-gnueabi
Reading makefiles...
Updating goal targets....
 File `addons/AsyncRequest/CMakeFiles/IoAsyncRequest.dir/depend' does not exist.
   File `../addons/AsyncRequest/source/IoAsyncRequestInit.c' does not exist.
  Must remake target `../addons/AsyncRequest/source/IoAsyncRequestInit.c'.
[ 55%] Generating ../../../addons/AsyncRequest/source/IoAsyncRequestInit.c

And the compilation ends with segfault:

Segmentation fault
make[2]: *** [../addons/AsyncRequest/source/IoAsyncRequestInit.c] Error 139
make[1]: *** [addons/AsyncRequest/CMakeFiles/IoAsyncRequest.dir/all] Error 2
make: *** [all] Error 2

My C is limited to a semester comm college course, so my looking at the source code didn't give me anything to add to the discussion. I'd really appreciate any time anyone is willing to allocate to this.

gatesphere commented 11 years ago

I ran into a compiler bug with gcc a while back that only manifested itself when compiling Io... it was gcc version 4.6.3 that failed, where gcc 4.7.2 worked fine.

Just out of curiosity, what does gcc -v say? And if it's in the 4.6 series, try upgrading to gcc 4.7 (a sudo apt-get update; sudo apt-get install gcc-4.7 should do the trick on Ubuntu), then delete your build directory and start over.

If this doesn't help, it's likely a bug in the source... but the segfault is leading me to believe it's a compiler bug.

limburgher commented 11 years ago

git master builds fine for me on Fedora 18 arm on my rpi, gcc 4.7.2

scooter-dangle commented 11 years ago

Yeah, my installed gcc is a 4.6. (4.6.2, I think.) I tried installing 4.7 with apt-get last night, but it didn't add anything to (or change anything in) any of the bin directories as far as I could tell. Version was still 4.6. Forgot to run apt-get update first, but I feel like I must have already done that recently. I'll make sure I do that when I get back to this tonight (can't connect personal electronics to my work network) and will try building 4.7 from source if I need to.

Thanks for the quick response.

(Running chroot Ubuntu 12.04 (sans gui) image alongside Android on Asus Transformer Infinity (ARMv7 instruction set), my main development device.)

scooter-dangle commented 11 years ago

Needed to add an Ubuntu development/test repo to install gcc-4.7. Compilation still stops at the same spot with the same error (after getting rid of _build/ and build/).

Just to try to rule out anything in my install of gcc-4.7 that might be causing this, here's my full gcc -v output:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabi/4.7/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.2-11precise2' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --enable-plugin --enable-objc-gc --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=softfp --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabi --host=arm-linux-gnueabi --target=arm-linux-gnueabi
Thread model: posix
gcc version 4.7.2 (Ubuntu/Linaro 4.7.2-11precise2) 

Update: This afternoon I realized that g++ was still version 4.6. I updated it as well (and modified the symlink in /usr/bin), but compilation still fails at the same point as before.

scooter-dangle commented 11 years ago

Update: I was able to compile after commenting out all of the addon lines in addons/CMakeLists.txt. I tried commenting them out one by one as they caused errors during compilation, but after doing this for maybe 10 of them, I commented them out in broad swathes between compilation attempts until there were none left.

Should I file an issue about addon compilation on ARM?