Re: [ats-lang-users] atscc as cross-compiler
Unleashing the potentials of types and templates
Status: Beta
Brought to you by:
ats-hwxi
From: Chris D. <chr...@do...> - 2012-03-26 03:26:38
|
On Fri, Jun 25, 2010 at 2:56 AM, Likai Liu <li...@cs...> wrote: > > Here is my proposal for you. Try to use atsopt, and let us know how > you are going to be compiling the generated C source and link the > objects in a cross compiling setting. We'll see if there is anything > we can change about the build system and atscc script to make that > more convenient. Sorry to revive such an old thread but I've recently been trying to get ATS working for producing executables that will run on an Android system. This is the steps I took to get a simple "hello world' working. It requires the Android SDK and NDK to be installed. From the NDK I generated a "standalone toolchain". Instructions to do this are in "docs/STANDALONE-TOOLCHAIN.html" in the NDK. The 'bin' for the directory where the standalone toolchain was created should be added to your path. This contains 'arm-linux-androideabi-gcc' and related binaries for compilation. I built ATS from SVN as normal to get a working atsopt. I'm on 64 bit linux so the runtime library for this is in 'ccomp/lib64'. I modified 'utils/scripts/atslib.dats' so that instead of using 'gcc' (which seems to be hardcoded instead of pulling from the ATSCCOMP environment variable) it used 'arm-linux-androideabi-gcc'. I also changed 'utils/scripts/atslib_main.dats' so that a "--arm' command line switch was added to set 'wordsize_target_set (4)' (similar to "-m32" but doesn't add it to the gcc command line). I rebuilt 'atslib' and ran it with: atslib --arm --libats This compiled the ATS standard library into 'ccomp/lib'. Since I'm running a 64 built build normally this doesn't clash with the standard library the host ATS build used. Ideally this should be put into a different directory but for testing this worked fine. I also had to modify a couple of files to build under android, and edit ".libfiles_local" to remove entries that android doesn't support (complex numbers, gmp, etc). In 'utils/scripts/atslib_main.dats' I added a "-arm" switch to once again do "wordsize_target_set (4)' without adding to the gcc command line. I rebuilt 'atscc' and ran it on my hello world application as: ATSCCOMP=arm-linux-androideabi-gcc ./ats-lang/utils/scripts/atscc -arm hello.dats This generated an 'a.out' that I copied to the android device (using "adb push") and ran on the device (inside "adb shell"). So to support an additional platform like this it looks like 'atslib' needs to be tweaked to allow different runtime library directories, selecting the C compiler and some way to identify files that can't be built on the target platform. 'atscc' just needs a way to select which runtime library directory to use. Currently it does this based on word size of the compiling platform but this can be different. Chris. -- http://www.bluishcoder.co.nz |