ChezScheme
ChezScheme copied to clipboard
Compile error on Android ARM
I am trying to cross-compile Chez Scheme on my Lenovo tablet running termux (a unix-like environment), with help on Google Groups from Atticus and Andy Keep. I performed the following steps:
Step 1: On the host machine (an i3 desktop running Linux Mint)
cd # /home/phil
git clone https://github.com/cisco/ChezScheme.git
cd ChezScheme-master
./configure
sudo make install
mkdir boot/arm32le
cd a6le
make -f Mf-boot arm32le.boot
cd ..
./configure -m=arm32le
./configure --workarea=arm32le
cd arm32le/s
make -f Mf-cross m=a6le xm=arm32le base=../../a6le
cd ../../..
Step 2: On the target machine (a Lenovo ARM tablet running Android 5)
cd # /data/data/com.termux/files/home
scp -r phil@haydn:/home/phil/ChezScheme-master/ .
edit file ChezScheme-master/configure
change /bin/sh to /data/data/com.termux/files/usr/bin/sh
edit file ChezScheme-master/zlib/configure
change /bin/sh to /data/data/com.termux/files/usr/bin/sh
cd ChezScheme-master/arm32le/c
make
While performing this step, make encountered three errors, all in file segment.c:
at line 350, character 7, symbol build_ptr
at line 406, character 26, symbol SYMVAL
at line 406, character 12, symbol Sflonum_value
The first two errors were the same:
cast to 'ptr' (aka 'void *') from smaller integer type 'unsigned int'
The third error was a different message:
cast to 'double *' from smaller integer type 'unsigned int'
The C compiler is gcc, clang version 3.9.1, target aarch64--linux-android, thread model posix.
Please help me compile Chez Scheme.
It sounds like you're building the boot and header files for 32-bit (arm32le) and the c directory for 64-bit. If you mean to build the 32-bit version, you might need to supply the -m32 option to the C compiler.
Success build chez on android arm works for me. LOCAL_ARM_MODE := arm LOCAL_CFLAGS += -g -Wall -DANDROID -DINLINES -DGC_MACROS -DARMV6 -Wpointer-arith -Wall -Wextra -DLIBICONV_PLUG -fPIC -pie -fPIE scheme-release-1.2.apk
I added a line
CFLAGS = -m32
near the top of ChezScheme-master/arm32le/c/Makefile (above the line that defines C), and received the same three errors.
What does your C compiler report as it's target now that CFLAGS is set to target a 32-bit machine? (In your original email you indicated it was targeting aarch64--linux-android, which is definitely a 64-bit architecture).
-andy:)
On April 23, 2017 at 8:12:44 PM, pbewig ([email protected]) wrote:
I added a line
CFLAGS = -m32
near the top of ChezScheme-master/arm32le/c/Makefile (above the line that defines C), and received the same three errors.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cisco/ChezScheme/issues/163#issuecomment-296499182, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG5r4RbyUXuAlji14X4xgCOKGkPxfzgks5ry-jqgaJpZM4M-xN8 .
When I perform 'make' with the provided Makefile, as I did before my first message, I get the following error:
gcc -Wpointer-arith -Wextra -Werror -O2 -c -DARMV6 -I../boot/arm32le -I../zlib segment.c segment.c:350:7: error: cast to 'ptr' (aka 'void *') from smaller integer type 'unsigned int' [-Werror,-Wint-to-void-pointer-cast] if (build_ptr(base, 0) == addr && base + nact != ((uptr)1 << (ptr_bits - segment_offset_bits)) - 1) ^ ./types.h:109:25: note: expanded from macro 'build_ptr' #define build_ptr(s,o) ((ptr)(((uptr)(s) << segment_offset_bits) | (uptr)(o))) ^ segment.c:406:26: error: cast to 'ptr ' (aka 'void **') from smaller integer type 'unsigned int' [-Werror,-Wint-to-pointer-cast] (iptr)(Sflonum_value(SYMVAL(S_G.heap_reserve_ratio_id)) * S_G.number_of_nonstatic_segments); ^ ../boot/arm32le/equates.h:758:22: note: expanded from macro 'SYMVAL' #define SYMVAL(x) (((ptr *)((uptr)(x)+5))) ^ segment.c:406:12: error: cast to 'double ' from smaller integer type 'unsigned int' [-Werror,-Wint-to-pointer-cast] (iptr)(Sflonum_value(SYMVAL(S_G.heap_reserve_ratio_id)) * S_G.number_of_nonstatic_segments); ^ ../boot/arm32le/scheme.h:101:29: note: expanded from macro 'Sflonum_value' #define Sflonum_value(x) (((double *)((uptr)(x)+6))) ^ 3 errors generated. make: *** [Makefile:29: segment.o] Error 1
Then when I add a line 'CFLAGS = -m32' to the Makefile, I get exactly the same error, as if CFLAGS is not recognized, and in fact that appears to be the case, since the gcc line at the top of the output does not include the -m32 flag. Next I removed the 'CFLAGS = -m32' line and wrote the -m32 directly in the definition of the C variable. Here is the output of that command:
$ make gcc -m32 -Wpointer-arith -Wextra -Werror -O2 -c -DARMV6 -I../boot/arm32le -I../zlib segment.c In file included from segment.c:35: In file included from ./system.h:25: In file included from ../zlib/zlib.h:34: In file included from ../zlib/zconf.h:475: In file included from /data/data/com.termux/files/usr/include/unistd.h:34: In file included from /data/data/com.termux/files/usr/include/sys/select.h:35: In file included from /data/data/com.termux/files/usr/include/signal.h:37: /data/data/com.termux/files/usr/include/asm/sigcontext.h:44:2: error: unknown type name '__uint128_t' __uint128_t vregs[32]; ^ 1 error generated. make: *** [Makefile:29: segment.o] Error 1
I guess that's progress: we've gone from a 64-bit error to a 128-bit error. The result of 'gcc --version', both with and without the -m32 flag, is shown below:
$ gcc --version clang version 3.9.1 (tags/RELEASE_391/final) Target: aarch64--linux-android Thread model: posix InstalledDir: /data/data/com.termux/files/usr/bin $ gcc -m32 --version clang version 3.9.1 (tags/RELEASE_391/final) Target: arm--linux-android Thread model: posix InstalledDir: /data/data/com.termux/files/usr/bin
Thank you for your assistance.
Phil
I still don't have this working. I upgraded from clang 3.9.1 to clang 4.0.0, but the error remains the same.
I realize that the error points to something in the compiler, not in Chez Scheme. Do you know a better place to get help?
I found an explanation of the problem, but no solution: http://stackoverflow.com/questions/25802724/is-there-a-way-to-use-int128-t-with-the-android-ndk:
__int128_t is emulated, and its only available on 64-bit platforms. Its not available on Android, which is a 32-bit platform.
Is there anything I can do?
Just define __int128_t to int @pbewig
Android is one of most important platforms now, any plan to support ARMv7 ARM64 @dybvig ? Chez Scheme is a great fit( small and effective ) of script programming on embeded devices.
I don't know that we have any particular plans to work on this right now, but we would certainly welcome the effort if someone wanted to take the lead on the porting work.
I got Chez Scheme to compile on Android within the GnuRoot environment. See https://programmingpraxis.com/2017/09/15/compile-chez-scheme-on-android-arm/ .
On Mon, Jan 15, 2018 at 3:08 PM, Andy Keep [email protected] wrote:
I don't know that we have any particular plans to work on this right now, but we would certainly welcome the effort if someone wanted to take the lead on the porting work.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cisco/ChezScheme/issues/163#issuecomment-357789423, or mute the thread https://github.com/notifications/unsubscribe-auth/AHZz1q7sMODPyQeyY7k-E1P-DqnkUlD5ks5tK745gaJpZM4M-xN8 .
@evilbinary: On my android arm tablet, when I say (sqrt 47.9) Chez responds 6.920982589199311, exactly the same as my desktop computer.
On Tue, Jan 16, 2018 at 8:09 PM, evilbinary [email protected] wrote:
@pbewig https://github.com/pbewig android arm does not suport floating.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cisco/ChezScheme/issues/163#issuecomment-358171869, or mute the thread https://github.com/notifications/unsubscribe-auth/AHZz1vgd3G-MelrCuSeKwV68V7gh6dzqks5tLVZngaJpZM4M-xN8 .
@pbewig really? did you see this? https://github.com/cisco/ChezScheme/issues/85
@evilbinary: Don't ever doubt me.
[image: Inline image 1]
On Wed, Jan 17, 2018 at 9:10 PM, evilbinary [email protected] wrote:
@pbewig https://github.com/pbewig really? did you see this? #85 https://github.com/cisco/ChezScheme/issues/85
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cisco/ChezScheme/issues/163#issuecomment-358524133, or mute the thread https://github.com/notifications/unsubscribe-auth/AHZz1k8IBuGzZQBQ9RZWdM-5yUXOBFCDks5tLrYIgaJpZM4M-xN8 .
https://github.com/racket/racket/commit/e337c65204402ef4faf09f6a848d2d873d0e63a7